GroupsController.cs 1.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360
  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.DeepSeekAPI;
  14. using OASystem.API.OAMethodLib.File;
  15. using OASystem.API.OAMethodLib.Hub.HubClients;
  16. using OASystem.API.OAMethodLib.Hub.Hubs;
  17. using OASystem.API.OAMethodLib.JuHeAPI;
  18. using OASystem.API.OAMethodLib.KiMiApi;
  19. using OASystem.API.OAMethodLib.Logging;
  20. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  21. using OASystem.Domain.AesEncryption;
  22. using OASystem.Domain.Attributes;
  23. using OASystem.Domain.Dtos.CRM;
  24. using OASystem.Domain.Dtos.FileDto;
  25. using OASystem.Domain.Dtos.Financial;
  26. using OASystem.Domain.Dtos.Groups;
  27. using OASystem.Domain.Entities.Customer;
  28. using OASystem.Domain.Entities.Financial;
  29. using OASystem.Domain.Entities.Groups;
  30. using OASystem.Domain.ViewModels.CRM;
  31. using OASystem.Domain.ViewModels.Financial;
  32. using OASystem.Domain.ViewModels.Groups;
  33. using OASystem.Domain.ViewModels.OCR;
  34. using OASystem.Infrastructure.Repositories.CRM;
  35. using OASystem.Infrastructure.Repositories.Financial;
  36. using OASystem.Infrastructure.Repositories.Groups;
  37. using Quartz.Logging;
  38. using Quartz.Util;
  39. using SqlSugar.Extensions;
  40. using System.Collections;
  41. using System.ComponentModel.DataAnnotations;
  42. using System.Data;
  43. using System.Diagnostics;
  44. using System.Globalization;
  45. using System.IO;
  46. using System.IO.Compression;
  47. using System.Text.Json;
  48. using System.Text.RegularExpressions;
  49. using System.Web;
  50. using static OASystem.API.OAMethodLib.JWTHelper;
  51. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  52. using Bookmark = Aspose.Words.Bookmark;
  53. using Cell = Aspose.Words.Tables.Cell;
  54. using Table = Aspose.Words.Tables.Table;
  55. namespace OASystem.API.Controllers
  56. {
  57. /// <summary>
  58. /// 团组相关
  59. /// </summary>
  60. //[Authorize]
  61. [Route("api/[controller]/[action]")]
  62. public class GroupsController : ControllerBase
  63. {
  64. private readonly ILogger<GroupsController> _logger;
  65. private readonly ITextFileLogger _eec_textLogger;
  66. private readonly IGroupTextFileLogger _groupTextLogger;
  67. private readonly GrpScheduleRepository _grpScheduleRep;
  68. private readonly IMapper _mapper;
  69. private readonly DelegationInfoRepository _groupRepository;
  70. private readonly TaskAssignmentRepository _taskAssignmentRep;
  71. private readonly AirTicketResRepository _airTicketResRep;
  72. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  73. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  74. private readonly DelegationEnDataRepository _delegationEnDataRep;
  75. private readonly DelegationVisaRepository _delegationVisaRep;
  76. private readonly VisaPriceRepository _visaPriceRep;
  77. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  78. private readonly HotelPriceRepository _hotelPriceRep;
  79. private readonly CustomersRepository _customersRep;
  80. private readonly MessageRepository _message;
  81. private readonly SqlSugarClient _sqlSugar;
  82. private readonly TourClientListRepository _tourClientListRep;
  83. private readonly TeamRateRepository _teamRateRep;
  84. #region 成本相关
  85. private readonly CheckBoxsRepository _checkBoxs;
  86. private readonly GroupCostRepository _GroupCostRepository;
  87. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  88. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  89. #endregion
  90. private readonly SetDataRepository _setDataRep;
  91. private string url;
  92. private string path;
  93. private readonly EnterExitCostRepository _enterExitCostRep;
  94. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  95. private readonly UsersRepository _usersRep;
  96. private readonly IJuHeApiService _juHeApi;
  97. private readonly InvertedListRepository _invertedListRep;
  98. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  99. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  100. private readonly ThreeCodeRepository _threeCodeRepository;
  101. private readonly HotelInquiryRepository _hotelInquiryRep;
  102. private readonly FeeAuditRepository _feeAuditRep;
  103. private readonly VisaCommissionRepository _visaCommissionRep;
  104. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  105. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  106. private readonly List<CurrencyInfo> _currencyInit;
  107. private readonly List<int> _portTypeData;
  108. private readonly TableOperationRecordRepository _tableorRep;
  109. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  110. private readonly RestaurantRepository _restaurantRep;
  111. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  112. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  113. private readonly IDeepSeekService _deepSeekService;
  114. /// <summary>
  115. /// 构造函数
  116. /// </summary>
  117. /// <param name="logger"></param>
  118. /// <param name="eec_textLogger"></param>
  119. /// <param name="groupTextLogger"></param>
  120. /// <param name="mapper"></param>
  121. /// <param name="hubContext"></param>
  122. /// <param name="sqlSugar"></param>
  123. /// <param name="grpScheduleRep"></param>
  124. /// <param name="groupRepository"></param>
  125. /// <param name="taskAssignmentRep"></param>
  126. /// <param name="airTicketResRep"></param>
  127. /// <param name="decreasePaymentsRep"></param>
  128. /// <param name="InvitationOfficialActivitiesRep"></param>
  129. /// <param name="delegationEnDataRep"></param>
  130. /// <param name="enterExitCostRep"></param>
  131. /// <param name="delegationVisaRep"></param>
  132. /// <param name="message"></param>
  133. /// <param name="visaPriceRep"></param>
  134. /// <param name="carTouristGuideGroundRep"></param>
  135. /// <param name="checkBoxs"></param>
  136. /// <param name="GroupCostRepository"></param>
  137. /// <param name="CostTypeHotelNumberRepository"></param>
  138. /// <param name="GroupCostParameterRepository"></param>
  139. /// <param name="hotelPriceRep"></param>
  140. /// <param name="customersRep"></param>
  141. /// <param name="setDataRep"></param>
  142. /// <param name="tourClientListRep"></param>
  143. /// <param name="teamRateRep"></param>
  144. /// <param name="usersRep"></param>
  145. /// <param name="juHeApi"></param>
  146. /// <param name="invertedListRep"></param>
  147. /// <param name="visaFeeInfoRep"></param>
  148. /// <param name="ticketBlackCodeRep"></param>
  149. /// <param name="hotelInquiryRep"></param>
  150. /// <param name="threeCodeRepository"></param>
  151. /// <param name="feeAuditRep"></param>
  152. /// <param name="visaCommissionRep"></param>
  153. /// <param name="ffrRep"></param>
  154. /// <param name="opinionaireRep"></param>
  155. /// <param name="tableorRep"></param>
  156. /// <param name="enterExitCostDraftRep"></param>
  157. /// <param name="restaurantRep"></param>
  158. /// <param name="enterExitCostQuoteRep"></param>
  159. /// <param name="grpOrderPreInfoRep"></param>
  160. public GroupsController(
  161. ILogger<GroupsController> logger,
  162. ITextFileLogger eec_textLogger,
  163. IGroupTextFileLogger groupTextLogger,
  164. IMapper mapper,
  165. IHubContext<ChatHub, IChatClient> hubContext,
  166. SqlSugarClient sqlSugar,
  167. GrpScheduleRepository grpScheduleRep,
  168. DelegationInfoRepository groupRepository,
  169. TaskAssignmentRepository taskAssignmentRep,
  170. AirTicketResRepository airTicketResRep,
  171. DecreasePaymentsRepository decreasePaymentsRep,
  172. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  173. DelegationEnDataRepository delegationEnDataRep,
  174. EnterExitCostRepository enterExitCostRep,
  175. DelegationVisaRepository delegationVisaRep,
  176. MessageRepository message,
  177. VisaPriceRepository visaPriceRep,
  178. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  179. CheckBoxsRepository checkBoxs,
  180. GroupCostRepository GroupCostRepository,
  181. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  182. GroupCostParameterRepository GroupCostParameterRepository,
  183. HotelPriceRepository hotelPriceRep,
  184. CustomersRepository customersRep,
  185. SetDataRepository setDataRep,
  186. TourClientListRepository tourClientListRep,
  187. TeamRateRepository teamRateRep,
  188. UsersRepository usersRep,
  189. IJuHeApiService juHeApi,
  190. InvertedListRepository invertedListRep,
  191. VisaFeeInfoRepository visaFeeInfoRep,
  192. TicketBlackCodeRepository ticketBlackCodeRep,
  193. HotelInquiryRepository hotelInquiryRep,
  194. ThreeCodeRepository threeCodeRepository,
  195. FeeAuditRepository feeAuditRep,
  196. VisaCommissionRepository visaCommissionRep,
  197. ForeignReceivablesRepository ffrRep,
  198. OpinionaireRepository opinionaireRep,
  199. TableOperationRecordRepository tableorRep,
  200. EnterExitCostDraftRepository enterExitCostDraftRep,
  201. RestaurantRepository restaurantRep,
  202. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  203. GroupOrderPreInfoRepository grpOrderPreInfoRep,
  204. IDeepSeekService deepSeekService
  205. )
  206. {
  207. _logger = logger;
  208. _eec_textLogger = eec_textLogger;
  209. _groupTextLogger = groupTextLogger;
  210. _mapper = mapper;
  211. _grpScheduleRep = grpScheduleRep;
  212. _groupRepository = groupRepository;
  213. _taskAssignmentRep = taskAssignmentRep;
  214. _airTicketResRep = airTicketResRep;
  215. _sqlSugar = sqlSugar;
  216. url = AppSettingsHelper.Get("ExcelBaseUrl");
  217. path = AppSettingsHelper.Get("ExcelBasePath");
  218. if (!System.IO.Directory.Exists(path))
  219. {
  220. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  221. }
  222. _decreasePaymentsRep = decreasePaymentsRep;
  223. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  224. _delegationEnDataRep = delegationEnDataRep;
  225. _enterExitCostRep = enterExitCostRep;
  226. _delegationVisaRep = delegationVisaRep;
  227. _message = message;
  228. _visaPriceRep = visaPriceRep;
  229. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  230. _checkBoxs = checkBoxs;
  231. _GroupCostRepository = GroupCostRepository;
  232. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  233. _GroupCostParameterRepository = GroupCostParameterRepository;
  234. _hotelPriceRep = hotelPriceRep;
  235. _customersRep = customersRep;
  236. _setDataRep = setDataRep;
  237. _tourClientListRep = tourClientListRep;
  238. _teamRateRep = teamRateRep;
  239. _hubContext = hubContext;
  240. _usersRep = usersRep;
  241. _juHeApi = juHeApi;
  242. _invertedListRep = invertedListRep;
  243. _visaFeeInfoRep = visaFeeInfoRep;
  244. _ticketBlackCodeRep = ticketBlackCodeRep;
  245. _hotelInquiryRep = hotelInquiryRep;
  246. _threeCodeRepository = threeCodeRepository;
  247. _feeAuditRep = feeAuditRep;
  248. _visaCommissionRep = visaCommissionRep;
  249. _ffrRep = ffrRep;
  250. _opinionaireRep = opinionaireRep;
  251. _currencyInit = new List<CurrencyInfo>()
  252. {
  253. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  254. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  255. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  256. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  257. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  258. };
  259. _portTypeData = new List<int>() { 2, 3 };
  260. _tableorRep = tableorRep;
  261. _enterExitCostDraftRep = enterExitCostDraftRep;
  262. _restaurantRep = restaurantRep;
  263. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  264. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  265. _deepSeekService = deepSeekService;
  266. }
  267. #region 流程管控
  268. /// <summary>
  269. /// 获取团组流程管控信息
  270. /// </summary>
  271. /// <param name="_jsonDto">查询参数</param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  275. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  276. {
  277. if (string.IsNullOrEmpty(_jsonDto.Paras))
  278. {
  279. return Ok(JsonView(false, "参数为空"));
  280. }
  281. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  282. if (_ScheduleDto != null)
  283. {
  284. if (_ScheduleDto.SearchType == 2)//获取列表
  285. {
  286. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  287. return Ok(JsonView(_grpScheduleViewList));
  288. }
  289. else//获取对象
  290. {
  291. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  292. if (_grpScheduleView != null)
  293. {
  294. return Ok(JsonView(_grpScheduleView));
  295. }
  296. }
  297. }
  298. else
  299. {
  300. return Ok(JsonView(false, "参数反序列化失败"));
  301. }
  302. return Ok(JsonView(false, "暂无数据!"));
  303. }
  304. /// <summary>
  305. /// 修改团组流程管控详细表数据
  306. /// </summary>
  307. /// <param name="dto"></param>
  308. /// <returns></returns>
  309. [HttpPost]
  310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  311. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  312. {
  313. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  314. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  315. .SetColumns(it => it.Duty == _detail.Duty)
  316. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  317. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  318. .SetColumns(it => it.JobContent == _detail.JobContent)
  319. .SetColumns(it => it.Remark == _detail.Remark)
  320. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  321. .Where(s => s.Id == dto.Id)
  322. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  323. .ExecuteCommandAsync();
  324. if (result > 0)
  325. {
  326. return Ok(JsonView(true, "保存成功!"));
  327. }
  328. return Ok(JsonView(false, "保存失败!"));
  329. }
  330. /// <summary>
  331. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  332. /// </summary>
  333. /// <param name="dto"></param>
  334. /// <returns></returns>
  335. [HttpPost]
  336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  337. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  338. {
  339. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  340. _detail.IsDel = 1;
  341. _detail.DeleteUserId = dto.Duty;
  342. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  343. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  344. .SetColumns(it => it.IsDel == _detail.IsDel)
  345. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  346. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  347. .Where(it => it.Id == dto.Id)
  348. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  349. //.WhereColumns(s => s.Id == dto.Id)
  350. .ExecuteCommandAsync();
  351. if (result > 0)
  352. {
  353. return Ok(JsonView(true, "删除成功!"));
  354. }
  355. return Ok(JsonView(false, "删除失败!"));
  356. }
  357. /// <summary>
  358. /// 增加团组流程管控详细表数据
  359. /// </summary>
  360. /// <param name="dto"></param>
  361. /// <returns></returns>
  362. [HttpPost]
  363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  364. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  365. {
  366. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  367. if (DateTime.Now < _detail.ExpectBeginDt)
  368. {
  369. _detail.StepStatus = 0;
  370. }
  371. else
  372. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  373. _detail.StepStatus = 1;
  374. }
  375. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  376. if (result > 0)
  377. {
  378. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  379. return Ok(JsonView(true, "添加成功!", _result));
  380. }
  381. return Ok(JsonView(false, "添加失败!"));
  382. }
  383. #endregion
  384. #region 团组前期信息
  385. /// <summary>
  386. /// 团组前期信息H5-URL(员工对应地址)
  387. /// </summary>
  388. /// <param name="name">用户名称</param>
  389. /// <returns></returns>
  390. [HttpGet]
  391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  392. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  393. {
  394. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  395. .Where(x => x.IsDel == 0)
  396. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  397. .OrderBy(x => x.Id)
  398. .Select(x => new
  399. {
  400. name = x.CnName,
  401. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  402. })
  403. .ToListAsync();
  404. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  405. }
  406. /// <summary>
  407. /// 团组前期信息 List
  408. /// </summary>
  409. /// <returns></returns>
  410. [HttpPost]
  411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  412. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  413. {
  414. var search = dto.Search;
  415. int[] nameTempIds = new int[] { 1, 12, 28 },
  416. countryTempIds = new int[] { 2, 13, 29 },
  417. daysTempIds = new int[] { 4, 15, 31 },
  418. ppNumTempIds = new int[] { 6 };
  419. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  420. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  421. .Where((opi, u) => opi.IsDel == 0)
  422. .OrderByDescending((opi, u) => opi.CreateTime)
  423. .Select((opi, u) => new GroupOrderPreInfoListView()
  424. {
  425. Id = opi.Id,
  426. Name = opi.Name,
  427. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  428. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  429. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  430. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  431. Operator = u.CnName,
  432. OperationTime = opi.CreateTime
  433. })
  434. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  435. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  436. .ToListAsync();
  437. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  438. int total = list.Count;
  439. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  440. var listPageData1 = listPageData
  441. .Skip((dto.PageIndex - 1) * dto.PageSize)
  442. .Take(dto.PageSize)
  443. .ToList();
  444. var infoIds = listPageData1.Select(x => x.Id).ToList();
  445. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  446. .Where(x => x.IsDel == 0 && x.STid == 109)
  447. .ToArrayAsync();
  448. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  449. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  450. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  451. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  452. .ToListAsync();
  453. foreach (var item in listPageData1)
  454. {
  455. var typeDatas1 = typeDatas.Select(x => new
  456. {
  457. x.Id,
  458. x.Name,
  459. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  460. }).ToArray();
  461. item.VersionDetails = typeDatas1;
  462. }
  463. return Ok(JsonView(listPageData1, listPageData1.Count));
  464. }
  465. /// <summary>
  466. /// 团组前期信息 Init
  467. /// </summary>
  468. /// <returns></returns>
  469. [HttpGet("{userId}")]
  470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  471. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  472. {
  473. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  474. }
  475. /// <summary>
  476. /// 国家数据源
  477. /// </summary>
  478. /// <param name="pageIndex">当前页码</param>
  479. /// <param name="pageSize">每页条数</param>
  480. /// <param name="search">查询条件</param>
  481. /// <returns></returns>
  482. [HttpGet]
  483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  484. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  485. {
  486. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  487. if (pageIndex == 0 && pageSize == 0)
  488. {
  489. //所有数据
  490. return Ok(JsonView(countrys, countrys.Count));
  491. }
  492. //分页
  493. int skip = (pageIndex - 1) * pageSize;
  494. int take = pageSize;
  495. if (!string.IsNullOrEmpty(search))
  496. {
  497. IEnumerable<char> charSequence = search.Select(c => c);
  498. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  499. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  500. return Ok(JsonView(pageData, pageResult1.Count));
  501. }
  502. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  503. return Ok(JsonView(pageResult2, countrys.Count));
  504. }
  505. /// <summary>
  506. /// 城市数据源
  507. /// </summary>
  508. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  509. /// <param name="pageIndex">当前页码</param>
  510. /// <param name="pageSize">每页条数</param>
  511. /// <param name="search">查询条件</param>
  512. /// <returns></returns>
  513. [HttpGet("{countryLabel}")]
  514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  515. public async Task<IActionResult> CityByCountry(
  516. string countryLabel,
  517. [FromQuery] int pageIndex,
  518. [FromQuery] int pageSize,
  519. [FromQuery] string search)
  520. {
  521. countryLabel = HttpUtility.UrlDecode(countryLabel);
  522. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  523. var citys = Array.Empty<string?>();
  524. if (countryList.Any())
  525. {
  526. var cityDatas = await _sqlSugar
  527. .Queryable<Grp_NationalTravelFee>()
  528. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  529. .ToArrayAsync();
  530. foreach (var item in cityDatas)
  531. {
  532. if (item.City.Contains("城市"))
  533. {
  534. item.City = item.Country + "-所有城市";
  535. }
  536. }
  537. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  538. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  539. }
  540. if (pageIndex == 0 && pageSize == 0)
  541. {
  542. //所有数据
  543. return Ok(JsonView(citys, citys?.Length ?? 0));
  544. }
  545. //分页
  546. int skip = (pageIndex - 1) * pageSize;
  547. int take = pageSize;
  548. if (!string.IsNullOrEmpty(search))
  549. {
  550. IEnumerable<char> charSequence = search.Select(c => c);
  551. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  552. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  553. return Ok(JsonView(pageData, pageResult1.Count));
  554. }
  555. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  556. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  557. }
  558. /// <summary>
  559. /// 团组前期信息 Info
  560. /// </summary>
  561. /// <param name="dto">Id</param>
  562. /// <returns></returns>
  563. [HttpGet("{Id}/{TempId}")]
  564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  565. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  566. {
  567. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  568. }
  569. /// <summary>
  570. /// 团组前期信息 移动端 Info
  571. /// </summary>
  572. /// <param name="dto">Id</param>
  573. /// <returns></returns>
  574. [HttpGet("{Id}/{TempId}")]
  575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  576. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  577. {
  578. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  579. }
  580. /// <summary>
  581. /// 团组前期信息 Save
  582. /// </summary>
  583. /// <param name="dto">Id</param>
  584. /// <returns></returns>
  585. [HttpPost]
  586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  587. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  588. {
  589. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  590. }
  591. /// <summary>
  592. /// 团组前期信息 Del
  593. /// </summary>
  594. /// <param name="dto">Id</param>
  595. /// <returns></returns>
  596. [HttpPost]
  597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  598. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  599. {
  600. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  601. }
  602. /// <summary>
  603. /// 团组前期信息 文件下载
  604. /// </summary>
  605. /// <param name="dto">Id</param>
  606. /// <returns></returns>
  607. [HttpGet("{Id}/{TempId}")]
  608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  609. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  610. {
  611. int id = dto.Id, tempId = dto.TempId;
  612. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  613. var data = view.Data as GrpOrderPreInfoView;
  614. #region Excel
  615. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  616. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  617. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  618. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  619. var fileNamePrefix = string.Empty;
  620. if (tempId == 1405)
  621. {
  622. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  623. fileNamePrefix = $"{data.Name}_无商邀版";
  624. }
  625. else if (tempId == 1406)
  626. {
  627. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  628. fileNamePrefix = $"{data.Name}_有商邀版";
  629. }
  630. else
  631. {
  632. //tempId == 1404 默认下载
  633. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  634. fileNamePrefix = $"{data.Name}_单接送机";
  635. }
  636. foreach (var item in data.Items)
  637. {
  638. var obj = item.NewValue;
  639. if (obj == null) item.OriginVal = "";
  640. else if (obj.Equals("有") || obj.Equals("无"))
  641. {
  642. item.OriginVal = obj.ToString();
  643. }
  644. else if (obj is object[] objArray)
  645. {
  646. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  647. item.OriginVal = string.Join("、", stringArray);
  648. }
  649. else if (obj is string[] stringArray)
  650. {
  651. item.OriginVal = string.Join("、", stringArray);
  652. }
  653. else if (obj.Equals("-"))
  654. {
  655. item.OriginVal = "";
  656. }
  657. }
  658. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  659. fileName = CommonFun.ValidFileName(fileName);
  660. //载入模板
  661. var designer = new WorkbookDesigner
  662. {
  663. Workbook = new Workbook(tempPath)
  664. };
  665. if (tempId == 1406)
  666. {
  667. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  668. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  669. for (int i = 1; i <= view2.Length; i++)
  670. {
  671. view2[i - 1].Index = i;
  672. }
  673. designer.SetDataSource("View1", view1);
  674. designer.SetDataSource("View2", view2);
  675. }
  676. else
  677. {
  678. designer.SetDataSource("View", data.Items);
  679. }
  680. designer.Process();
  681. if (!Directory.Exists(savePath))
  682. {
  683. Directory.CreateDirectory(savePath);
  684. }
  685. string serverPath = $"{savePath}{fileName}";
  686. designer.Workbook.Save(serverPath);
  687. string rst = $"{servicePath}{ftpPath}{fileName}";
  688. #endregion
  689. return Ok(JsonView(new { url = rst }));
  690. }
  691. #endregion
  692. #region 团组基本信息
  693. /// <summary>
  694. /// 接团信息列表
  695. /// </summary>
  696. /// <param name="dto">团组列表请求dto</param>
  697. /// <returns></returns>
  698. [HttpPost]
  699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  700. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  701. {
  702. var groupData = await _groupRepository.GetGroupList(dto);
  703. if (groupData.Code != 0)
  704. {
  705. return Ok(JsonView(false, groupData.Msg));
  706. }
  707. return Ok(JsonView(groupData.Data));
  708. }
  709. /// <summary>
  710. /// 分页查询团组列表
  711. /// </summary>
  712. /// <param name="dto"></param>
  713. /// <returns></returns>
  714. [HttpPost]
  715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  716. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  717. {
  718. var watch = new Stopwatch();
  719. watch.Start();
  720. RefAsync<int> total = 0;
  721. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  722. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  723. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  724. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  725. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  726. .Distinct()
  727. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  728. watch.Stop();
  729. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  730. }
  731. /// <summary>
  732. /// 接团信息列表 Page Init
  733. /// </summary>
  734. /// <returns></returns>
  735. [HttpPost]
  736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  737. public async Task<IActionResult> PostGroupPageListInit()
  738. {
  739. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  740. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  741. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  742. var _view = new
  743. {
  744. depData = depDatas,
  745. rankData = rankDatas
  746. };
  747. return Ok(JsonView(true, "查询成功!", _view));
  748. }
  749. /// <summary>
  750. /// 接团信息列表 Page
  751. /// </summary>
  752. /// <param name="dto">团组列表请求dto</param>
  753. /// <returns></returns>
  754. [HttpPost]
  755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  756. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  757. {
  758. #region 参数验证
  759. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  760. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  761. #region 页面操作权限验证
  762. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  763. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  764. #endregion
  765. #endregion
  766. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  767. {
  768. string sqlWhere = string.Empty;
  769. if (dto.IsSure == 0) //未完成
  770. {
  771. sqlWhere += string.Format(@" And IsSure = 0");
  772. }
  773. else if (dto.IsSure == 1) //已完成
  774. {
  775. sqlWhere += string.Format(@" And IsSure = 1");
  776. }
  777. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  778. {
  779. string tj = dto.SearchCriteria;
  780. 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}%')",
  781. tj, tj, tj, tj, tj);
  782. }
  783. if (int.TryParse(dto.Rank, out int rankId))
  784. {
  785. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  786. }
  787. string sqlWhere1 = string.Empty;
  788. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  789. {
  790. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  791. }
  792. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  793. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  794. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  795. JietuanOperator,IsSure,CreateTime,IsBid,Step
  796. From (
  797. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  798. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  799. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  800. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,gdi.Step,
  801. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  802. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  803. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  804. From Grp_DelegationInfo gdi
  805. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  806. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  807. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  808. Where gdi.IsDel = 0 {0}
  809. ) temp {1}", sqlWhere, sqlWhere1);
  810. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  811. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  812. //处理 团组模块实际操作人
  813. _DelegationList.ForEach(async x =>
  814. {
  815. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  816. var operatorNames = new StringBuilder();
  817. //operatorNames.AppendLine("各模块实际操作人:");
  818. if (operators.Any())
  819. {
  820. operators.ForEach(y =>
  821. {
  822. string label = string.Empty;
  823. if (y.OperationUsers.Any())
  824. {
  825. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  826. label = string.Join('、', users);
  827. }
  828. else label = "暂未指定";
  829. operatorNames.AppendLine($"{y.CTableName}:{label}");
  830. operatorNames.AppendLine();
  831. });
  832. }
  833. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  834. });
  835. var _view = new
  836. {
  837. PageFuncAuth = pageFunAuthView,
  838. Data = _DelegationList
  839. };
  840. return Ok(JsonView(true, "查询成功!", _view, total));
  841. }
  842. else
  843. {
  844. return Ok(JsonView(false, "查询失败"));
  845. }
  846. }
  847. /// <summary>
  848. /// 团组列表
  849. /// </summary>
  850. /// <returns></returns>
  851. [HttpPost]
  852. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  853. {
  854. #region 参数验证
  855. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  856. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  857. #region 页面操作权限验证
  858. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  859. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  860. #endregion
  861. #endregion
  862. if (dto.PortType != 1 && dto.PortType != 2)
  863. {
  864. return Ok(JsonView(false, "查询失败!"));
  865. }
  866. string orderbyStr = "order by gdi.CreateTime Desc";
  867. string sqlWhere = string.Empty;
  868. if (dto.IsSure == 0) //未完成
  869. {
  870. sqlWhere += string.Format(@" And IsSure = 0");
  871. }
  872. else if (dto.IsSure == 1) //已完成
  873. {
  874. sqlWhere += string.Format(@" And IsSure = 1");
  875. }
  876. //团组类型
  877. if (dto.TeamDid > 0)
  878. {
  879. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  880. }
  881. //团组名称
  882. if (!string.IsNullOrEmpty(dto.TeamName))
  883. {
  884. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  885. }
  886. //客户名称
  887. if (!string.IsNullOrEmpty(dto.ClientName))
  888. {
  889. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  890. }
  891. //客户单位
  892. if (!string.IsNullOrEmpty(dto.ClientUnit))
  893. {
  894. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  895. }
  896. //出访时间
  897. if (!string.IsNullOrEmpty(dto.visitDataTime))
  898. {
  899. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  900. orderbyStr = "order by gdi.VisitDate";
  901. }
  902. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  903. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  904. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  905. JietuanOperator,IsSure,CreateTime
  906. From (
  907. Select row_number() over({0}) as Row_Number,
  908. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  909. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  910. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  911. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  912. From Grp_DelegationInfo gdi
  913. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  914. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  915. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  916. Where gdi.IsDel = 0 {1}
  917. ) temp ", orderbyStr, sqlWhere);
  918. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  919. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  920. #region 处理所属部门
  921. /*
  922. * 1.sq 和 gyy 等显示 市场部
  923. * 2.王鸽和主管及张总还有管理员号统一国交部
  924. * 2-1. 4 管理员 ,21 张海麟
  925. */
  926. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  927. var userIds1 = new List<int>() { 4, 21 };
  928. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  929. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  930. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  931. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  932. .ToList();
  933. foreach (var item in _DelegationList)
  934. {
  935. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  936. }
  937. #endregion
  938. var _view = new
  939. {
  940. PageFuncAuth = pageFunAuthView,
  941. Data = _DelegationList
  942. };
  943. return Ok(JsonView(true, "查询成功!", _view, total));
  944. }
  945. /// <summary>
  946. /// 接团信息详情
  947. /// </summary>
  948. /// <param name="dto">团组info请求dto</param>
  949. /// <returns></returns>
  950. [HttpPost]
  951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  952. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  953. {
  954. var groupData = await _groupRepository.GetGroupInfo(dto);
  955. if (groupData.Code != 0)
  956. {
  957. return Ok(JsonView(false, groupData.Msg));
  958. }
  959. return Ok(JsonView(groupData.Data));
  960. }
  961. /// <summary>
  962. /// 接团信息 编辑添加
  963. /// 基础信息数据源
  964. /// </summary>
  965. /// <param name="dto"></param>
  966. /// <returns></returns>
  967. [HttpPost]
  968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  969. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  970. {
  971. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  972. if (groupData.Code != 0)
  973. {
  974. return Ok(JsonView(false, groupData.Msg));
  975. }
  976. return Ok(JsonView(groupData.Data));
  977. }
  978. /// <summary>
  979. /// 成本修改团组信息
  980. /// </summary>
  981. /// <param name="dto"></param>
  982. /// <returns></returns>
  983. [HttpPost]
  984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  985. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  986. {
  987. var jw = JsonView(false, "操作失败");
  988. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  989. if (di == null)
  990. {
  991. jw.Msg = "参数有误!";
  992. return Ok(jw);
  993. }
  994. #region 添加出访起止时间
  995. var startTime = new DateTime();
  996. var endTime = new DateTime();
  997. if (DateTime.TryParse(dto.VisitDate, out startTime))
  998. {
  999. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1000. }
  1001. else
  1002. {
  1003. jw.Msg = "参数有误!";
  1004. return Ok(jw);
  1005. }
  1006. #endregion
  1007. di.VisitDate = startTime;
  1008. di.VisitPNumber = dto.VisitPNumber;
  1009. di.VisitDays = dto.VisitDays;
  1010. di.VisitStartDate = startTime;
  1011. di.VisitEndDate = endTime;
  1012. var count = _sqlSugar.Updateable(di)
  1013. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1014. .ExecuteCommand();
  1015. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1016. }
  1017. /// <summary>
  1018. /// 接团信息 编辑添加
  1019. /// 省份-城市 基础信息数据源
  1020. /// </summary>
  1021. /// <param name="dto"></param>
  1022. /// <returns></returns>
  1023. [HttpPost]
  1024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1025. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1026. {
  1027. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1028. string search = dto.Search;
  1029. var data = await _groupRepository.CityBasicSource();
  1030. int total = data.Length;
  1031. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1032. .Skip((pageIndex - 1) * pageSize)
  1033. .Take(pageSize)
  1034. .ToArray();
  1035. return Ok(JsonView(data, total));
  1036. }
  1037. /// <summary>
  1038. /// 接团信息 操作(增改)
  1039. /// </summary>
  1040. /// <param name="dto"></param>
  1041. /// <returns></returns>
  1042. [HttpPost]
  1043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1044. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1045. {
  1046. // 创建 Stopwatch 实例
  1047. Stopwatch stopwatch = Stopwatch.StartNew();
  1048. decimal ffrPrice = 0.00M;
  1049. DateTime? visitDt = null;
  1050. if (dto.Status == 2)
  1051. {
  1052. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1053. if (groupInfo != null)
  1054. {
  1055. ffrPrice = groupInfo.PaymentMoney;
  1056. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1057. }
  1058. }
  1059. var groupData = await _groupRepository.GroupOperation(dto);
  1060. if (groupData.Code != 0)
  1061. {
  1062. return Ok(JsonView(false, groupData.Msg));
  1063. }
  1064. int diId = 0;
  1065. try
  1066. {
  1067. //添加时 默认加入团组汇率
  1068. if (dto.Status == 1) //添加
  1069. {
  1070. diId = groupData.Data;
  1071. //添加默认币种
  1072. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1073. //默认分配权限
  1074. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1075. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1076. var _managerIds = new List<int>() { 22, 32, 21 };
  1077. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1078. if (userIds.Count > 0)
  1079. {
  1080. userIds.Add(208);
  1081. //创建团组管控
  1082. GroupStepForDelegation.CreateWorkStep(diId);
  1083. //发送消息
  1084. string groupName = dto.TeamName;
  1085. string createGroupUser = string.Empty;
  1086. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1087. if (userInfo != null) createGroupUser = userInfo.CnName;
  1088. string title = $"系统通知";
  1089. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1090. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1091. }
  1092. //默认创建倒推表
  1093. await _invertedListRep._Create(dto.UserId, diId);
  1094. }
  1095. else if (dto.Status == 2)
  1096. {
  1097. diId = dto.Id;
  1098. }
  1099. #region 签证人员团组时间通知
  1100. #region 计算出访起止时间
  1101. var startTime = new DateTime();
  1102. var endTime = new DateTime();
  1103. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1104. {
  1105. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1106. }
  1107. #endregion
  1108. #endregion
  1109. #region 团组操作默认添加/修改收款账单
  1110. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1111. {
  1112. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1113. .Where(x => x.IsDel == 0 &&
  1114. x.Diid == diId &&
  1115. x.Remark.Equals("预付款")
  1116. )
  1117. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1118. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1119. .FirstAsync();
  1120. ffrInfo = new Fin_ForeignReceivables()
  1121. {
  1122. Diid = diId,
  1123. PriceName = dto.ClientUnit,
  1124. Price = dto.PaymentMoney,
  1125. Count = 1,
  1126. Unit = $"元",
  1127. ItemSumPrice = dto.PaymentMoney,
  1128. Rate = 1.0000M,
  1129. Currency = 836,
  1130. AddingWay = 0,
  1131. CreateUserId = dto.UserId,
  1132. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1133. Remark = $"预付款"
  1134. };
  1135. if (ffrInfo == null) //Add
  1136. {
  1137. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1138. }
  1139. else //修改
  1140. {
  1141. await _sqlSugar.Updateable(ffrInfo)
  1142. .UpdateColumns(x => new
  1143. {
  1144. x.PriceName,
  1145. x.Price,
  1146. x.ItemSumPrice,
  1147. x.CreateTime,
  1148. x.CreateUserId
  1149. })
  1150. .WhereColumns(x => x.Id)
  1151. .ExecuteCommandAsync();
  1152. }
  1153. }
  1154. #endregion
  1155. if (diId > 0)
  1156. {
  1157. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1158. }
  1159. // 停止计时
  1160. stopwatch.Stop();
  1161. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1162. }
  1163. catch (Exception ex)
  1164. {
  1165. // 停止计时
  1166. stopwatch.Stop();
  1167. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1168. Logs(ex.Message);
  1169. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1170. }
  1171. // 停止计时
  1172. stopwatch.Stop();
  1173. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1174. }
  1175. /// <summary>
  1176. /// 接团流程操作(增改)
  1177. /// 安卓端使用 建团时添加客户名单
  1178. /// </summary>
  1179. /// <param name="dto"></param>
  1180. /// <returns></returns>
  1181. [HttpPost]
  1182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1183. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1184. {
  1185. #region 参数验证
  1186. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1187. #region 页面操作权限验证
  1188. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1189. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1190. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1191. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1192. #endregion
  1193. #endregion
  1194. try
  1195. {
  1196. //_sqlSugar.BeginTran();
  1197. decimal ffrPrice = 0.00M;
  1198. DateTime? visitDt = null;
  1199. if (dto.Status == 2)
  1200. {
  1201. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1202. if (groupInfo != null)
  1203. {
  1204. ffrPrice = groupInfo.PaymentMoney;
  1205. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1206. }
  1207. }
  1208. var _dto = new GroupOperationDto();
  1209. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1210. var groupData = await _groupRepository.GroupOperation(_dto);
  1211. if (groupData.Code != 0)
  1212. {
  1213. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1214. }
  1215. int diId = 0;
  1216. //添加时 默认加入团组汇率
  1217. if (dto.Status == 1) //添加
  1218. {
  1219. diId = groupData.Data;
  1220. //添加默认币种
  1221. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1222. //默认分配权限
  1223. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1224. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1225. var _managerIds = new List<int>() { 21, 22, 32 };
  1226. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1227. if (userIds.Count > 0)
  1228. {
  1229. userIds.Add(208);
  1230. //创建团组管控
  1231. GroupStepForDelegation.CreateWorkStep(diId);
  1232. //发送消息
  1233. string groupName = dto.TeamName;
  1234. string createGroupUser = string.Empty;
  1235. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1236. if (userInfo != null) createGroupUser = userInfo.CnName;
  1237. string title = $"系统通知";
  1238. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1239. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1240. }
  1241. #region 应用推送
  1242. try
  1243. {
  1244. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1245. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1246. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1247. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1248. {
  1249. var userList = new List<string>() { users.QiyeChatUserId };
  1250. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1251. }
  1252. }
  1253. catch (Exception ex)
  1254. {
  1255. }
  1256. #endregion
  1257. //默认创建倒推表
  1258. await _invertedListRep._Create(dto.UserId, diId);
  1259. }
  1260. if (dto.Status == 2)
  1261. {
  1262. diId = dto.Id;
  1263. if (diId == 0)
  1264. {
  1265. //_sqlSugar.RollbackTran();
  1266. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1267. }
  1268. }
  1269. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1270. if (viewData.Code != 0)
  1271. {
  1272. //_sqlSugar.RollbackTran();
  1273. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1274. }
  1275. #region 团组操作默认添加/修改收款账单
  1276. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1277. {
  1278. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1279. .Where(x => x.IsDel == 0 &&
  1280. x.Diid == diId &&
  1281. x.Remark.Equals("预付款")
  1282. )
  1283. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1284. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1285. .FirstAsync();
  1286. ffrInfo = new Fin_ForeignReceivables()
  1287. {
  1288. Diid = diId,
  1289. PriceName = dto.ClientUnit,
  1290. Price = dto.PaymentMoney,
  1291. Count = 1,
  1292. Unit = $"元",
  1293. ItemSumPrice = dto.PaymentMoney,
  1294. Rate = 1.0000M,
  1295. Currency = 836,
  1296. AddingWay = 0,
  1297. CreateUserId = dto.UserId,
  1298. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1299. Remark = $"预付款"
  1300. };
  1301. if (ffrInfo == null) //Add
  1302. {
  1303. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1304. }
  1305. else //修改
  1306. {
  1307. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1308. .UpdateColumns(x => new
  1309. {
  1310. x.PriceName,
  1311. x.Price,
  1312. x.ItemSumPrice,
  1313. x.CreateTime,
  1314. x.CreateUserId
  1315. })
  1316. .WhereColumns(x => x.Id)
  1317. .ExecuteCommandAsync();
  1318. }
  1319. }
  1320. #endregion
  1321. #region 签证人员团组时间通知
  1322. #region 计算出访起止时间
  1323. var startTime = new DateTime();
  1324. var endTime = new DateTime();
  1325. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1326. {
  1327. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1328. }
  1329. #endregion
  1330. if (diId > 0)
  1331. {
  1332. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1333. }
  1334. #endregion
  1335. //_sqlSugar.CommitTran();
  1336. return Ok(JsonView(true, "添加成功"));
  1337. }
  1338. catch (Exception ex)
  1339. {
  1340. _sqlSugar.RollbackTran();
  1341. return Ok(JsonView(false, ex.Message));
  1342. }
  1343. }
  1344. /// <summary>
  1345. /// 接团流程操作(增改)
  1346. /// 安卓端使用 建团时添加客户名单
  1347. /// </summary>
  1348. /// <param name="dto"></param>
  1349. /// <returns></returns>
  1350. [HttpPost]
  1351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1352. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1353. {
  1354. #region 参数验证
  1355. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1356. #region 页面操作权限验证
  1357. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1358. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1359. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1360. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1361. #endregion
  1362. #endregion
  1363. _sqlSugar.BeginTran();
  1364. decimal ffrPrice = 0.00M;
  1365. DateTime? visitDt = null;
  1366. if (dto.Status == 2)
  1367. {
  1368. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1369. if (groupInfo != null)
  1370. {
  1371. ffrPrice = groupInfo.PaymentMoney;
  1372. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1373. }
  1374. }
  1375. var _dto = new GroupOperationDto();
  1376. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1377. var groupData = await _groupRepository.GroupOperation(_dto);
  1378. if (groupData.Code != 0)
  1379. {
  1380. _sqlSugar.RollbackTran();
  1381. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1382. }
  1383. try
  1384. {
  1385. int diId = 0;
  1386. //添加时 默认加入团组汇率
  1387. if (dto.Status == 1) //添加
  1388. {
  1389. diId = groupData.Data;
  1390. //添加默认币种
  1391. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1392. //默认分配权限
  1393. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1394. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1395. var _managerIds = new List<int>() { 21, 22, 32 };
  1396. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1397. if (userIds.Count > 0)
  1398. {
  1399. userIds.Add(208);
  1400. //创建团组管控
  1401. GroupStepForDelegation.CreateWorkStep(diId);
  1402. //发送消息
  1403. string groupName = dto.TeamName;
  1404. string createGroupUser = string.Empty;
  1405. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1406. if (userInfo != null) createGroupUser = userInfo.CnName;
  1407. string title = $"系统通知";
  1408. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1409. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1410. }
  1411. #region 应用推送
  1412. try
  1413. {
  1414. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1415. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1416. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1417. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1418. {
  1419. var userList = new List<string>() { users.QiyeChatUserId };
  1420. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1421. }
  1422. }
  1423. catch (Exception ex)
  1424. {
  1425. _sqlSugar.CommitTran();
  1426. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1427. }
  1428. #endregion
  1429. //默认创建倒推表
  1430. await _invertedListRep._Create(dto.UserId, diId);
  1431. }
  1432. else if (dto.Status == 2)
  1433. {
  1434. diId = dto.Id;
  1435. if (diId == 0)
  1436. {
  1437. _sqlSugar.RollbackTran();
  1438. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1439. }
  1440. }
  1441. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1442. if (viewData.Code != 0)
  1443. {
  1444. _sqlSugar.RollbackTran();
  1445. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1446. }
  1447. #region 团组操作默认添加/修改收款账单
  1448. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1449. {
  1450. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1451. .Where(x => x.IsDel == 0 &&
  1452. x.Diid == diId &&
  1453. x.Remark.Equals("预付款")
  1454. )
  1455. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1456. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1457. .FirstAsync();
  1458. ffrInfo = new Fin_ForeignReceivables()
  1459. {
  1460. Diid = diId,
  1461. PriceName = dto.ClientUnit,
  1462. Price = dto.PaymentMoney,
  1463. Count = 1,
  1464. Unit = $"元",
  1465. ItemSumPrice = dto.PaymentMoney,
  1466. Rate = 1.0000M,
  1467. Currency = 836,
  1468. AddingWay = 0,
  1469. CreateUserId = dto.UserId,
  1470. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1471. Remark = $"预付款"
  1472. };
  1473. if (ffrInfo == null) //Add
  1474. {
  1475. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1476. }
  1477. else //修改
  1478. {
  1479. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1480. .UpdateColumns(x => new
  1481. {
  1482. x.PriceName,
  1483. x.Price,
  1484. x.ItemSumPrice,
  1485. x.CreateTime,
  1486. x.CreateUserId
  1487. })
  1488. .WhereColumns(x => x.Id)
  1489. .ExecuteCommandAsync();
  1490. }
  1491. }
  1492. #endregion
  1493. #region 签证人员团组时间通知
  1494. #region 计算出访起止时间
  1495. var startTime = new DateTime();
  1496. var endTime = new DateTime();
  1497. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1498. {
  1499. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1500. }
  1501. #endregion
  1502. if (diId > 0)
  1503. {
  1504. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1505. }
  1506. #endregion
  1507. _sqlSugar.CommitTran();
  1508. return Ok(JsonView(true));
  1509. }
  1510. catch (Exception ex)
  1511. {
  1512. _sqlSugar.RollbackTran();
  1513. return Ok(JsonView(false, ex.Message));
  1514. }
  1515. }
  1516. /// <summary>
  1517. /// 接团信息 操作(删除)
  1518. /// </summary>
  1519. /// <param name="dto"></param>
  1520. /// <returns></returns>
  1521. [HttpPost]
  1522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1523. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1524. {
  1525. var diId = dto.Id;
  1526. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1527. #region 删除 验证
  1528. /*
  1529. * 1、收款账单数据:0 条
  1530. * 2、收款退还数据:0 条
  1531. * 3、机票费用数据:0 条
  1532. * 4、签证费用数据:0 条
  1533. * 5、保险费用数据:0 条
  1534. * 6、酒店费用数据:0 条
  1535. * 7、公务出访数据:1 条
  1536. * 8、邀请公务活动费用数据:1 条
  1537. * 9、OP费用数据:5 条
  1538. * 10、其他费用数据:0 条
  1539. * 11、团组日付报销费用数据:0 条
  1540. *
  1541. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1542. */
  1543. //收款账单
  1544. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1545. //收款退还
  1546. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1547. //机票费用
  1548. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1549. //签证费用
  1550. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1551. //保险费用
  1552. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1553. //酒店费用
  1554. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1555. //公务出访
  1556. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1557. //邀请公务活动费用
  1558. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1559. //OP费用
  1560. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1561. //其他费用
  1562. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1563. //团组日付报销费用
  1564. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1565. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1566. if (feeCount > 0)
  1567. {
  1568. var delMsgTips = new StringBuilder();
  1569. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1570. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1571. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1572. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1573. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1574. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1575. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1576. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1577. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1578. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1579. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1580. delMsgTips.AppendLine($"");
  1581. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1582. return Ok(JsonView(false, delMsgTips.ToString()));
  1583. }
  1584. #endregion
  1585. var groupData = await _groupRepository.GroupDel(dto);
  1586. if (groupData.Code != 0)
  1587. {
  1588. return Ok(JsonView(false, groupData.Msg));
  1589. }
  1590. return Ok(JsonView(true));
  1591. }
  1592. /// <summary>
  1593. /// 获取团组销售报价号
  1594. /// 团组添加时 使用
  1595. /// </summary>
  1596. /// <returns></returns>
  1597. [HttpPost]
  1598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1599. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1600. {
  1601. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1602. if (groupData.Code != 0)
  1603. {
  1604. return Ok(JsonView(false, groupData.Msg));
  1605. }
  1606. object salesQuoteNo = new
  1607. {
  1608. SalesQuoteNo = groupData.Data
  1609. };
  1610. return Ok(JsonView(salesQuoteNo));
  1611. }
  1612. /// <summary>
  1613. /// 设置确认出团
  1614. /// </summary>
  1615. /// <param name="dto"></param>
  1616. /// <returns></returns>
  1617. [HttpPost]
  1618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1619. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1620. {
  1621. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1622. if (groupData.Code != 0)
  1623. {
  1624. return Ok(JsonView(false, groupData.Msg));
  1625. }
  1626. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1627. #region OA消息推送
  1628. try
  1629. {
  1630. string groupName = groupInfo.TeamName;
  1631. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1632. string title = $"系统通知";
  1633. string content = $"团组[{groupName}]已确认出团!";
  1634. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1635. }
  1636. catch (Exception ex)
  1637. {
  1638. }
  1639. #endregion
  1640. #region 应用推送
  1641. try
  1642. {
  1643. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1644. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1645. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1646. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1647. {
  1648. var userList = new List<string>() { users.QiyeChatUserId };
  1649. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1650. }
  1651. }
  1652. catch (Exception ex)
  1653. {
  1654. }
  1655. #endregion
  1656. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1657. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1658. }
  1659. /// <summary>
  1660. /// 获取团组名称data And 签证国别Data
  1661. /// </summary>
  1662. /// <param name="dto"></param>
  1663. /// <returns></returns>
  1664. [HttpPost]
  1665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1666. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1667. {
  1668. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1669. if (groupData.Code != 0)
  1670. {
  1671. return Ok(JsonView(false, groupData.Msg));
  1672. }
  1673. return Ok(JsonView(groupData.Data));
  1674. }
  1675. /// <summary>
  1676. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1677. /// </summary>
  1678. /// <returns></returns>
  1679. [HttpPost]
  1680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1681. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1682. {
  1683. try
  1684. {
  1685. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1686. if (groupData.Code != 0)
  1687. {
  1688. return Ok(JsonView(false, groupData.Msg));
  1689. }
  1690. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1691. }
  1692. catch (Exception ex)
  1693. {
  1694. return Ok(JsonView(false, ex.Message));
  1695. throw;
  1696. }
  1697. }
  1698. /// <summary>
  1699. /// 团组清单 Excel
  1700. /// </summary>
  1701. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1702. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1703. /// <returns></returns>
  1704. [HttpGet]
  1705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1706. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1707. {
  1708. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1709. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1710. if (!beginBool && !endBool)
  1711. {
  1712. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1713. }
  1714. string sql = string.Format(@"
  1715. SELECT
  1716. ROW_NUMBER,
  1717. Id,
  1718. SalesQuoteNo,
  1719. TourCode,
  1720. TeamTypeId,
  1721. TeamType,
  1722. TeamLevId,
  1723. TeamLev,
  1724. TeamName,
  1725. ClientName,
  1726. ClientUnit,
  1727. VisitDate,
  1728. VisitDays,
  1729. VisitPNumber,
  1730. JietuanOperatorId,
  1731. JietuanOperator,
  1732. IsSure,
  1733. CreateUserName,
  1734. IsBid
  1735. FROM
  1736. (
  1737. SELECT
  1738. ROW_NUMBER() OVER(
  1739. ORDER BY
  1740. gdi.VisitDate Desc
  1741. ) AS ROW_NUMBER,
  1742. gdi.Id,
  1743. SalesQuoteNo,
  1744. TourCode,
  1745. ssd.Id TeamTypeId,
  1746. ssd.Name TeamType,
  1747. ssd1.Id TeamLevId,
  1748. ssd1.Name TeamLev,
  1749. TeamName,
  1750. ClientName,
  1751. ClientUnit,
  1752. VisitDate,
  1753. VisitDays,
  1754. VisitPNumber,
  1755. JietuanOperator JietuanOperatorId,
  1756. su.CnName JietuanOperator,
  1757. IsSure,
  1758. gdi.CreateTime,
  1759. su1.CnName As CreateUserName,
  1760. gdi.IsBid
  1761. FROM
  1762. Grp_DelegationInfo gdi
  1763. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1764. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1765. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1766. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1767. WHERE
  1768. gdi.IsDel = 0
  1769. AND gdi.IsBid = 0
  1770. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1771. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1772. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1773. #region 处理所属部门
  1774. /*
  1775. * 1.sq 和 gyy 等显示 市场部
  1776. * 2.王鸽和主管及张总还有管理员号统一国交部
  1777. * 2-1. 4 管理员 ,21 张海麟
  1778. */
  1779. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1780. var userIds1 = new List<int>() { 4, 21 };
  1781. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1782. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1783. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1784. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1785. .ToListAsync();
  1786. var droupIds = groupList.Select(it => it.Id).ToList();
  1787. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1788. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1789. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1790. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1791. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1792. {
  1793. DiId = tcl.DiId,
  1794. LastName = dc.LastName,
  1795. FirstName = dc.FirstName,
  1796. Sex = dc.Sex,
  1797. Birthday = dc.BirthDay,
  1798. Company = cc.CompanyFullName,
  1799. Job = dc.Job,
  1800. CreateTime = tcl.CreateTime,
  1801. })
  1802. .ToList();
  1803. foreach (var item in groupList)
  1804. {
  1805. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1806. string groupFirstName = "";
  1807. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1808. if (currDatas.Any())
  1809. {
  1810. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1811. }
  1812. item.GroupFirst = groupFirstName;
  1813. }
  1814. #endregion
  1815. #region Excel
  1816. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1817. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1818. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1819. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1820. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1821. //载入模板
  1822. var designer = new WorkbookDesigner
  1823. {
  1824. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1825. };
  1826. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1827. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1828. dt.TableName = "GroupList";
  1829. designer.SetDataSource(dt);
  1830. designer.Process();
  1831. if (!Directory.Exists(savePath))
  1832. {
  1833. Directory.CreateDirectory(savePath);
  1834. }
  1835. string serverPath = $"{savePath}{fileName}";
  1836. designer.Workbook.Save(serverPath);
  1837. string rst = $"{servicePath}{ftpPath}{fileName}";
  1838. #endregion
  1839. return Ok(JsonView(true, "操作成功!", rst));
  1840. }
  1841. /// <summary>
  1842. /// 团组合同下载(1.付款80% 2.付全款)
  1843. /// </summary>
  1844. /// <param name="dto"></param>
  1845. /// <returns></returns>
  1846. /// <exception cref="Exception"></exception>
  1847. [HttpPost]
  1848. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1849. {
  1850. var jw = JsonView(false);
  1851. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1852. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1853. if (di == null)
  1854. {
  1855. jw.Msg = "团组Id有误!";
  1856. return Ok(jw);
  1857. }
  1858. #region 权限校验
  1859. var allDownFile = new List<int>() { 21 };
  1860. try
  1861. {
  1862. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1863. .First(x => x.Id == 1418 && x.IsDel == 0);
  1864. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1865. }
  1866. catch (Exception)
  1867. { }
  1868. var guojiaoDownFile = new List<int>() { 330, 383 };
  1869. var shichangDownFile = new List<int>() { 95 };
  1870. if (allDownFile.Contains(dto.UserId))
  1871. {
  1872. }
  1873. else if (guojiaoDownFile.Contains(dto.UserId))
  1874. {
  1875. var guojiaobuDi = new List<int>() { 4, 21 };
  1876. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1877. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1878. .Where((d, u) => u.Id == di.JietuanOperator)
  1879. .Select((d, u) => d.DepName)
  1880. .First();
  1881. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1882. {
  1883. jw.Msg = "暂无下载权限!";
  1884. return Ok(jw);
  1885. }
  1886. }
  1887. else if (shichangDownFile.Contains(dto.UserId))
  1888. {
  1889. var dic = new Dictionary<int, int[]>()
  1890. {
  1891. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1892. };
  1893. try
  1894. {
  1895. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1896. if (sqSetting != null)
  1897. {
  1898. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1899. foreach (var item in result.Keys)
  1900. {
  1901. if (dic.ContainsKey(item))
  1902. {
  1903. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1904. Array.Copy(dic[item], dilatation, dic[item].Length);
  1905. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1906. dic[item] = dilatation;
  1907. }
  1908. else
  1909. {
  1910. dic.Add(item, result[item]);
  1911. }
  1912. }
  1913. }
  1914. if (!dic[95].Contains(di.CreateUserId))
  1915. {
  1916. jw.Msg = "暂无下载权限!";
  1917. return Ok(jw);
  1918. }
  1919. }
  1920. catch (Exception)
  1921. { }
  1922. }
  1923. else if (dto.UserId == di.CreateUserId)
  1924. {
  1925. }
  1926. else
  1927. {
  1928. jw.Msg = "暂无下载权限!";
  1929. return Ok(jw);
  1930. }
  1931. #endregion
  1932. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1933. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1934. .ToListAsync();
  1935. if (!blackCodeList.Any())
  1936. {
  1937. jw.Msg = "该团无机票行程代码!";
  1938. return Ok(jw);
  1939. }
  1940. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1941. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1942. if (groupEnterExitCost == null)
  1943. {
  1944. jw.Msg = "暂无三公费用信息!";
  1945. return Ok(jw);
  1946. }
  1947. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1948. rateList ??= new List<CurrencyInfo>();
  1949. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1950. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1951. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1952. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1953. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1954. .Select((x, a, b) => new
  1955. {
  1956. x.Index,
  1957. itemName = a.Name,
  1958. CurrencyStr = b.Name,
  1959. x.Cost,
  1960. x.SubTotal,
  1961. x.Remark
  1962. })
  1963. .OrderBy((x) => x.Index)
  1964. .ToList();
  1965. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1966. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1967. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1968. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1969. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1970. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1971. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1972. decimal subJJC = 0.00M,
  1973. subGWC = 0.00M,
  1974. subTDC = 0.00M;
  1975. //经济舱
  1976. if (groupEnterExitCost.SumJJC == 1)
  1977. {
  1978. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1979. }
  1980. //公务舱
  1981. if (groupEnterExitCost.SumGWC == 1)
  1982. {
  1983. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1984. }
  1985. //头等舱
  1986. if (groupEnterExitCost.SumTDC == 1)
  1987. {
  1988. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1989. }
  1990. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1991. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1992. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1993. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1994. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1995. .Select((x, s, dc, cc) => new GroupClints
  1996. {
  1997. Id = x.Id,
  1998. Name = s.Name,
  1999. IsAccompany = x.IsAccompany,
  2000. CompanyFullName = cc.CompanyFullName
  2001. })
  2002. .ToListAsync();
  2003. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  2004. //获取舱位人数
  2005. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2006. .GroupBy(x => x.Name)
  2007. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2008. .ToList();
  2009. string cityPath = string.Empty;
  2010. string startCity = string.Empty;
  2011. string endCity = string.Empty;
  2012. foreach (var item in blackCodeList)
  2013. {
  2014. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2015. cityPath += city + "\r\n";
  2016. if (item.Equals(blackCodeList.First()))
  2017. {
  2018. var sp = city.Split('-');
  2019. startCity = sp[0];
  2020. endCity = sp[^1];
  2021. }
  2022. }
  2023. var bookMarkDic = new Dictionary<string, string>
  2024. {
  2025. { "ClientUnit", di.ClientUnit },
  2026. { "VisitCountry", di.VisitCountry },
  2027. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2028. { "VisitPNumber", di.VisitPNumber.ToString() },
  2029. { "CityPath", cityPath },
  2030. { "StartCity", startCity },
  2031. { "EndCity", endCity },
  2032. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2033. };
  2034. Document doc = null;
  2035. var percentage = 0.8M;
  2036. var fileNameadd = "预付";
  2037. if (dto.FileType == 1)
  2038. {
  2039. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2040. }
  2041. else if (dto.FileType == 2)
  2042. {
  2043. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2044. percentage = 1;
  2045. fileNameadd = "全款";
  2046. }
  2047. else
  2048. {
  2049. throw new Exception("FileType有误!");
  2050. }
  2051. var builder = new DocumentBuilder(doc);
  2052. decimal totalPrice = 0.00M;
  2053. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2054. if (firstTable != null)
  2055. {
  2056. // 遍历表格的行和单元格
  2057. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2058. {
  2059. for (int i = 0; i < row.Cells.Count; i++)
  2060. {
  2061. var cell = row.Cells[i];
  2062. // 读取单元格内容
  2063. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2064. if (cellTextFirst.Contains("舱位"))
  2065. {
  2066. break;
  2067. }
  2068. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2069. {
  2070. if (i == 2)
  2071. {
  2072. if (cellTextFirst == "经济舱")
  2073. {
  2074. // 设置单元格内容
  2075. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2076. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2077. }
  2078. else
  2079. {
  2080. // 设置单元格内容
  2081. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2082. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2083. }
  2084. }
  2085. if (i == 3)
  2086. {
  2087. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2088. if (count != null)
  2089. {
  2090. // 设置单元格内容
  2091. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2092. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2093. }
  2094. }
  2095. if (i == 4)
  2096. {
  2097. var rowPrice = 0.00M;
  2098. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2099. count ??= 0;
  2100. if (cellTextFirst == "经济舱")
  2101. {
  2102. rowPrice = subJJC * (int)count;
  2103. }
  2104. else
  2105. {
  2106. rowPrice = subGWC * (int)count;
  2107. }
  2108. totalPrice += rowPrice;
  2109. // 设置单元格内容
  2110. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2111. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2112. }
  2113. }
  2114. }
  2115. }
  2116. }
  2117. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2118. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2119. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2120. //--合同表格部分
  2121. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2122. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2123. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2124. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2125. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2126. bookMarkDic.Add("CityPath1", cityPath);
  2127. bookMarkDic.Add("CityPath2", cityPath);
  2128. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2129. if (contractTable != null)
  2130. {
  2131. //数据源
  2132. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2133. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2134. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2135. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2136. .Select((it, y, s) => new
  2137. {
  2138. it.Cost,
  2139. it.SubTotal,
  2140. it.Type,
  2141. y.Id,
  2142. y.City,
  2143. s.Name,
  2144. CurrencyCodeCn = s.Remark
  2145. })
  2146. .ToList()
  2147. .Select(x => new
  2148. {
  2149. CurrencyCode = x.Name,
  2150. CityId = x.Id,
  2151. x.City,
  2152. di.VisitPNumber,
  2153. x.Type,
  2154. x.Cost,
  2155. x.SubTotal,
  2156. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2157. x.CurrencyCodeCn,
  2158. });
  2159. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2160. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2161. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2162. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2163. var tableSettings = new List<tableSetting>()
  2164. {
  2165. new(){ Index = 1 , Property = "City"},
  2166. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2167. new(){ Index = 3 , Property = "Cost"},
  2168. new(){ Index = 4 , Property = "VisitPNumber"},
  2169. //new tableSetting{ Index = 5 , Property = ""},
  2170. //new tableSetting{ Index = 6 , Property = ""},
  2171. new(){ Index = 7 , Property = "Rate"},
  2172. //new tableSetting{ Index = 8 , Property = ""},
  2173. };
  2174. //1.住宿费
  2175. int cloneRow = 8;
  2176. int startDayPrice = 8; //写入index
  2177. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2178. foreach (var dac in dac1)
  2179. {
  2180. var first = dac.First();
  2181. var dayCount = dac.Count();
  2182. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2183. for (int i = 1; i < row.Cells.Count; i++)
  2184. {
  2185. var cell = row.Cells[i];
  2186. var findProperty = tableSettings.Find(x => x.Index == i);
  2187. if (findProperty != null)
  2188. {
  2189. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2190. // 设置单元格内容
  2191. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2192. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2193. }
  2194. else
  2195. {
  2196. switch (i)
  2197. {
  2198. case 5:
  2199. cell.FirstParagraph.Runs.Clear();
  2200. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2201. break;
  2202. case 6:
  2203. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2204. cell.FirstParagraph.Runs.Clear();
  2205. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2206. break;
  2207. case 8:
  2208. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2209. cell.FirstParagraph.Runs.Clear();
  2210. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2211. ZSPriceSum += xiaojiRMB;
  2212. break;
  2213. default:
  2214. break;
  2215. }
  2216. }
  2217. }
  2218. startDayPrice++;
  2219. if (!dac1.Last().Equals(dac))
  2220. {
  2221. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2222. // 将克隆的行追加到原行后面
  2223. contractTable.Rows.Insert(startDayPrice, newRow);
  2224. }
  2225. else
  2226. {
  2227. cloneRow += dac1.Count + 1;
  2228. startDayPrice = cloneRow;
  2229. }
  2230. }
  2231. //2.伙食费
  2232. foreach (var dac in dac2)
  2233. {
  2234. var first = dac.First();
  2235. var dayCount = dac.Count();
  2236. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2237. for (int i = 1; i < row.Cells.Count; i++)
  2238. {
  2239. var cell = row.Cells[i];
  2240. var findProperty = tableSettings.Find(x => x.Index == i);
  2241. if (findProperty != null)
  2242. {
  2243. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2244. // 设置单元格内容
  2245. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2246. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2247. }
  2248. else
  2249. {
  2250. switch (i)
  2251. {
  2252. case 5:
  2253. cell.FirstParagraph.Runs.Clear();
  2254. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2255. break;
  2256. case 6:
  2257. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2258. cell.FirstParagraph.Runs.Clear();
  2259. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2260. break;
  2261. case 8:
  2262. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2263. cell.FirstParagraph.Runs.Clear();
  2264. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2265. HSPriceSum += xiaojiRMB;
  2266. break;
  2267. default:
  2268. break;
  2269. }
  2270. }
  2271. }
  2272. startDayPrice++;
  2273. if (!dac2.Last().Equals(dac))
  2274. {
  2275. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2276. // 将克隆的行追加到原行后面
  2277. contractTable.Rows.Insert(startDayPrice, newRow);
  2278. }
  2279. else
  2280. {
  2281. cloneRow += dac2.Count + 1;
  2282. startDayPrice = cloneRow;
  2283. }
  2284. }
  2285. //3.公杂费
  2286. foreach (var dac in dac3)
  2287. {
  2288. var first = dac.First();
  2289. var dayCount = dac.Count();
  2290. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2291. for (int i = 1; i < row.Cells.Count; i++)
  2292. {
  2293. var cell = row.Cells[i];
  2294. var findProperty = tableSettings.Find(x => x.Index == i);
  2295. if (findProperty != null)
  2296. {
  2297. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2298. // 设置单元格内容
  2299. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2300. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2301. }
  2302. else
  2303. {
  2304. switch (i)
  2305. {
  2306. case 5:
  2307. cell.FirstParagraph.Runs.Clear();
  2308. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2309. break;
  2310. case 6:
  2311. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2312. cell.FirstParagraph.Runs.Clear();
  2313. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2314. break;
  2315. case 8:
  2316. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2317. cell.FirstParagraph.Runs.Clear();
  2318. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2319. GZPriceSum += xiaojiRMB;
  2320. break;
  2321. default:
  2322. break;
  2323. }
  2324. }
  2325. }
  2326. startDayPrice++;
  2327. if (!dac3.Last().Equals(dac))
  2328. {
  2329. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2330. // 将克隆的行追加到原行后面
  2331. contractTable.Rows.Insert(startDayPrice, newRow);
  2332. }
  2333. else
  2334. {
  2335. cloneRow += dac3.Count + 1;
  2336. startDayPrice = cloneRow;
  2337. }
  2338. }
  2339. //合并单元格
  2340. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2341. {
  2342. var currentRow = contractTable.Rows[i];
  2343. var nextRow = contractTable.Rows[i + 1];
  2344. // 获取当前行和下一行的第一个单元格
  2345. Cell currentCell = currentRow.Cells[0];
  2346. Cell nextCell = nextRow.Cells[0];
  2347. // 检查单元格内容是否一致(去除尾部的换行符)
  2348. string currentText = currentCell.GetText().Trim();
  2349. string nextText = nextCell.GetText().Trim();
  2350. if (currentText == nextText)
  2351. {
  2352. // 如果当前单元格已经被合并,找到合并的起始单元格
  2353. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2354. {
  2355. // 找到合并的起始单元格
  2356. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2357. // 将下一行的单元格设置为合并的后续单元格
  2358. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2359. }
  2360. else
  2361. {
  2362. // 如果当前单元格是合并的起始单元格
  2363. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2364. // 将下一行的单元格设置为合并的后续单元格
  2365. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2366. }
  2367. }
  2368. else
  2369. {
  2370. // 如果内容不一致,重置当前单元格的合并属性
  2371. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2372. {
  2373. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2374. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2375. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2376. }
  2377. else
  2378. {
  2379. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2380. }
  2381. }
  2382. }
  2383. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2384. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2385. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2386. }
  2387. foreach (var bookmarkName in bookMarkDic.Keys)
  2388. {
  2389. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2390. if (bookmark != null)
  2391. {
  2392. if (bookmarkName == "ClientUnit")
  2393. {
  2394. // 移动到书签位置
  2395. builder.MoveTo(bookmark.BookmarkStart);
  2396. // 设置字体样式为下划线
  2397. builder.Font.Underline = Aspose.Words.Underline.Single;
  2398. // 插入书签值
  2399. builder.Write(bookMarkDic[bookmarkName]);
  2400. // 清除字体格式,避免影响后续文本
  2401. builder.Font.ClearFormatting();
  2402. }
  2403. else
  2404. {
  2405. builder.MoveToBookmark(bookmarkName);
  2406. builder.Write(bookMarkDic[bookmarkName]);
  2407. }
  2408. }
  2409. }
  2410. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2411. doc.Save(savePaht);
  2412. jw.Msg = "生成成功!";
  2413. jw.Code = 200;
  2414. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2415. return Ok(jw);
  2416. }
  2417. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2418. {
  2419. int index = rowIndex;
  2420. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2421. {
  2422. index--;
  2423. }
  2424. return index;
  2425. }
  2426. /// <summary>
  2427. /// 报批完成企微通知
  2428. /// </summary>
  2429. /// <param name="dto"></param>
  2430. /// <returns></returns>
  2431. [HttpPost]
  2432. public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
  2433. {
  2434. int currUserId = dto.currUserId;
  2435. int diid = dto.diid;
  2436. var jw = JsonView(true);
  2437. var users = new List<string>();
  2438. var ssd = _sqlSugar.Queryable<Sys_SetData>()
  2439. .First(x => x.Id == 1460);
  2440. try
  2441. {
  2442. users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
  2443. var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
  2444. //消息通知成功 更改团组step、记录日志
  2445. if (res)
  2446. {
  2447. var groupStep = 0; //0-新建 1-企微消息通知
  2448. //更改团组step
  2449. var updStatus = await _sqlSugar.Updateable<Grp_DelegationInfo>()
  2450. .SetColumns(x => new Grp_DelegationInfo()
  2451. {
  2452. Step = 2
  2453. })
  2454. .Where(x => x.Id == diid && x.IsDel == 0)
  2455. .ExecuteCommandAsync();
  2456. if (updStatus > 0) groupStep = 2;
  2457. string groupStepLabel = groupStep switch
  2458. {
  2459. 1 => "新建",
  2460. 2 => "企微消息通知(报批)",
  2461. _ => "未设置"
  2462. };
  2463. //记录日志
  2464. var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2465. .Where(x => x.Id == diid && x.IsDel == 0)
  2466. .Select(x => x.TeamName)
  2467. .First() ?? "-";
  2468. var operationName = _sqlSugar.Queryable<Sys_Users>()
  2469. .Where(x => x.Id == currUserId && x.IsDel == 0)
  2470. .Select(x => x.CnName)
  2471. .First() ?? "-";
  2472. _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
  2473. }
  2474. }
  2475. catch (Exception ex)
  2476. {
  2477. return Ok(JsonView(false, ex.Message));
  2478. }
  2479. return Ok(jw);
  2480. }
  2481. #endregion
  2482. #region 团组&签证
  2483. #region 团组&签证 New
  2484. /// <summary>
  2485. /// 团组&签证 New
  2486. /// DeepSeek API:测试API连通性
  2487. /// </summary>
  2488. /// <param name="file">请求dto</param>
  2489. /// <returns></returns>
  2490. [HttpPost]
  2491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2492. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2493. {
  2494. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2495. }
  2496. /// <summary>
  2497. /// 团组&签证 New
  2498. /// DeepSeek API:检查可用端点
  2499. /// </summary>
  2500. /// <param name="file">请求dto</param>
  2501. /// <returns></returns>
  2502. [HttpPost]
  2503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2504. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2505. {
  2506. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2507. }
  2508. /// <summary>
  2509. /// 团组&签证 New
  2510. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2511. /// </summary>
  2512. /// <param name="file">请求dto</param>
  2513. /// <returns></returns>
  2514. [HttpPost]
  2515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2516. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  2517. {
  2518. //文件验证
  2519. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2520. //var visaFiles = new VisaUploadFileTypeView();
  2521. var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2522. if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2523. //服务器存储文件
  2524. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2525. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2526. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  2527. using (var stream = new FileStream(filePath, FileMode.Create))
  2528. {
  2529. await visaFile.CopyToAsync(stream);
  2530. }
  2531. //日志记录-上传文件
  2532. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  2533. IFormFile localFile = null;
  2534. //获取项目中的cs文件
  2535. try
  2536. {
  2537. _logger.LogInformation("读取并上传项目文件请求");
  2538. // 1. 读取项目文件
  2539. var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  2540. if (readResponse.SuccessCount == 0)
  2541. {
  2542. return Ok(JsonView(false, "读取项目文件失败"));
  2543. }
  2544. localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  2545. }
  2546. catch (Exception ex)
  2547. {
  2548. _logger.LogError(ex, "读取项目文件失败");
  2549. return Ok(JsonView(false, "读取项目文件失败"));
  2550. }
  2551. if (localFile == null)
  2552. {
  2553. return Ok(JsonView(false, "读取项目文件失败"));
  2554. }
  2555. var fileReq = new DeepSeekFileUploadRequest()
  2556. {
  2557. Files = new List<IFormFile> { localFile, visaFile },
  2558. };
  2559. var filesResult = new List<FileUploadResult>();
  2560. #region 上传文件到DeepSeekAPI
  2561. try
  2562. {
  2563. _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  2564. filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  2565. // 需要等待处理完成
  2566. if (fileReq.WaitForProcessing)
  2567. {
  2568. foreach (var result in filesResult)
  2569. {
  2570. if (result.Success)
  2571. {
  2572. try
  2573. {
  2574. var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  2575. result.Status = processedFile.Status;
  2576. }
  2577. catch (Exception ex)
  2578. {
  2579. _logger.LogError(ex, "DeepSeek API文件上传失败");
  2580. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2581. }
  2582. }
  2583. }
  2584. }
  2585. }
  2586. catch (Exception ex)
  2587. {
  2588. _logger.LogError(ex, "DeepSeek API文件上传失败");
  2589. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2590. }
  2591. #endregion
  2592. if (filesResult == null || filesResult.Count < 1)
  2593. {
  2594. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  2595. }
  2596. //
  2597. try
  2598. {
  2599. var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  2600. _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  2601. string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  2602. var response = await _deepSeekService.ChatWithFilesAsync(fileIds, question);
  2603. return Ok(response);
  2604. }
  2605. catch (Exception ex)
  2606. {
  2607. _logger.LogError(ex, "使用文件聊天失败");
  2608. return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  2609. }
  2610. //加载文件OpCarTouristGuideGroundContent
  2611. ////kimi AI 识别文档返回json结果
  2612. //int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2613. //var KiMiApi = new KiMiApiClient();
  2614. //var files = new List<IFormFile>() { file };
  2615. //var seedConter = await KiMiApi.UploadFilesAsync(files);
  2616. //if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2617. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2618. //var messages = new List<SeedMessages>
  2619. //{
  2620. // new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2621. // new() { Role = KimiRole.user, Content = seedMessage }
  2622. //};
  2623. //messages.InsertRange(1, seedConter);
  2624. string jsonString = string.Empty;
  2625. //bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2626. //while (!isJson)
  2627. //{
  2628. // kimiAI_API_Index++;
  2629. // var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2630. // var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2631. // jsonString += kimiApiResult_JObject["content"].ToString();
  2632. // string startStr = "```json", endStr = "```";
  2633. // // 判断并清除开头部分
  2634. // if (jsonString.StartsWith(startStr))
  2635. // {
  2636. // jsonString = jsonString.Replace(startStr, "");
  2637. // }
  2638. // // 判断并清除结尾部分
  2639. // if (jsonString.EndsWith(endStr))
  2640. // {
  2641. // jsonString = jsonString.Replace(endStr, "");
  2642. // }
  2643. // //验证json格式是否正确
  2644. // try
  2645. // {
  2646. // JsonDocument.Parse(jsonString);
  2647. // isJson = true; // 如果解析成功,则是json格式
  2648. // }
  2649. // catch (Exception)
  2650. // {
  2651. // //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2652. // messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2653. // }
  2654. //}
  2655. //var clientInfo = new Crm_DeleClient(); //客户资料表
  2656. //var clientFamily = new Crm_VisaCustomerFamily(); //客户家庭表
  2657. //var clientCompany = new Crm_CustomerCompany(); //客户公司表
  2658. //var clientCert = new Crm_CustomerCert(); //客户证件表
  2659. //var clientSchool = new Crm_VisaCustomerSchool(); //客户学历表
  2660. ////按照表格类型分别进行参数处理
  2661. //switch (fileTypeId)
  2662. //{
  2663. // //澳新签证个人申请表
  2664. // case 1:
  2665. // _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2666. // VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2667. // break;
  2668. // default:
  2669. // break;
  2670. //}
  2671. return Ok(JsonView(true, jsonString));
  2672. }
  2673. private int GetSuccessCount(List<FileUploadResult> results)
  2674. {
  2675. var count = 0;
  2676. foreach (var result in results)
  2677. {
  2678. if (result.Success) count++;
  2679. }
  2680. return count;
  2681. }
  2682. #endregion
  2683. /// <summary>
  2684. /// 根据团组Id获取签证客户信息List
  2685. /// </summary>
  2686. /// <param name="dto">请求dto</param>
  2687. /// <returns></returns>
  2688. [HttpPost]
  2689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2690. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2691. {
  2692. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2693. if (groupData.Code != 0)
  2694. {
  2695. return Ok(JsonView(false, groupData.Msg));
  2696. }
  2697. return Ok(JsonView(groupData.Data));
  2698. }
  2699. /// <summary>
  2700. /// IOS获取团组签证拍照上传进度01(团组列表)
  2701. /// </summary>
  2702. /// <param name="dto">请求dto</param>
  2703. /// <returns></returns>
  2704. [HttpPost]
  2705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2706. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2707. {
  2708. if (dto == null)
  2709. {
  2710. return Ok(JsonView(false, "参数为空"));
  2711. }
  2712. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2713. return Ok(JsonView(visaList));
  2714. }
  2715. /// <summary>
  2716. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2717. /// </summary>
  2718. /// <returns></returns>
  2719. [HttpPost]
  2720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2721. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2722. {
  2723. if (dto == null)
  2724. {
  2725. return Ok(JsonView(false, "请求错误:"));
  2726. }
  2727. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2728. return Ok(JsonView(list));
  2729. }
  2730. /// <summary>
  2731. /// IOS获取团组签证拍照上传进度03(相册)
  2732. /// </summary>
  2733. /// <returns></returns>
  2734. [HttpPost]
  2735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2736. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2737. {
  2738. if (dto == null)
  2739. {
  2740. return Ok(JsonView(false, "请求错误:"));
  2741. }
  2742. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2743. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2744. list.ForEach(s => s.url = url);
  2745. return Ok(JsonView(list));
  2746. }
  2747. /// <summary>
  2748. /// IOS获取团组签证拍照上传进度04(图片上传)
  2749. /// </summary>
  2750. /// <param name="dto"></param>
  2751. /// <returns></returns>
  2752. [HttpPost]
  2753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2754. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2755. {
  2756. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2757. //if (!string.IsNullOrEmpty(result))
  2758. //{
  2759. //}
  2760. //else {
  2761. // return Ok(JsonView(false, "上传失败"));
  2762. //}
  2763. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2764. int sucNum = 0;
  2765. try
  2766. {
  2767. foreach (var item in dto.base64DataList)
  2768. {
  2769. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2770. string result = DecodeBase64ToImage(item, imageName);
  2771. if (!string.IsNullOrEmpty(result))
  2772. {
  2773. var pic = new Grp_VisaProgressCustomerPicture
  2774. {
  2775. CreateUserId = dto.CreateUserId,
  2776. PicName = imageName,
  2777. PicPath = result,
  2778. VisaProgressCustomerId = dto.visaProgressCustomerId
  2779. };
  2780. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2781. if (insertResult > 0)
  2782. {
  2783. sucNum++;
  2784. }
  2785. }
  2786. }
  2787. }
  2788. catch (Exception ex)
  2789. {
  2790. return Ok(JsonView(false, ex.Message));
  2791. }
  2792. string msg = string.Format(@"成功上传{0}张", sucNum);
  2793. return Ok(JsonView(true, msg));
  2794. }
  2795. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2796. {
  2797. string filename = "";//声明一个string类型的相对路径
  2798. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2799. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2800. try//会有异常抛出,try,catch一下
  2801. {
  2802. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2803. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2804. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2805. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2806. //文件名称
  2807. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2808. //上传的文件的路径
  2809. string filePath = "";
  2810. if (!Directory.Exists(fileDir))
  2811. {
  2812. Directory.CreateDirectory(fileDir);
  2813. }
  2814. //上传的文件的路径
  2815. filePath = fileDir + filename;
  2816. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2817. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2818. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2819. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2820. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2821. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2822. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2823. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2824. bitmap.Dispose();
  2825. }
  2826. catch (Exception e)
  2827. {
  2828. string massage = e.Message;
  2829. Logs("IOS图片上传Error:" + massage);
  2830. //filename = e.Message;
  2831. }
  2832. return filename;//返回相对路径
  2833. }
  2834. /// <summary>
  2835. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2836. /// </summary>
  2837. /// <param name="dto"></param>
  2838. /// <returns></returns>
  2839. [HttpPost]
  2840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2841. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2842. {
  2843. if (dto == null)
  2844. {
  2845. return Ok(JsonView(false, "请求错误:"));
  2846. }
  2847. string msg = "参数错误";
  2848. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2849. {
  2850. try
  2851. {
  2852. //_delegationVisaRep.BeginTran();
  2853. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2854. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2855. .Where(s => s.Id == dto.visaProgressCustomerId)
  2856. .ExecuteCommandAsync();
  2857. if (updCount > 0 && dto.publishCode == 1)
  2858. {
  2859. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2860. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2861. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2862. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2863. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2864. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2865. if (groupData == null)
  2866. {
  2867. _delegationVisaRep.RollbackTran();
  2868. }
  2869. string title = string.Format(@"[签证进度更新]");
  2870. string content = string.Format(@"测试文本");
  2871. bool rst = await _message.AddMsg(new MessageDto()
  2872. {
  2873. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2874. IssuerId = dto.publisher,
  2875. Title = title,
  2876. Content = content,
  2877. ReleaseTime = DateTime.Now,
  2878. UIdList = new List<int> {
  2879. 234
  2880. }
  2881. });
  2882. if (rst)
  2883. {
  2884. return Ok(JsonView(true, "发送通知成功"));
  2885. }
  2886. }
  2887. //_delegationVisaRep.CommitTran();
  2888. }
  2889. catch (Exception)
  2890. {
  2891. //_delegationVisaRep.RollbackTran();
  2892. }
  2893. }
  2894. return Ok(JsonView(true, msg));
  2895. }
  2896. #endregion
  2897. #region 团组任务分配
  2898. /// <summary>
  2899. /// 团组任务分配初始化
  2900. /// </summary>
  2901. /// <returns></returns>
  2902. [HttpPost]
  2903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2904. public async Task<IActionResult> GetTaskAssignmen()
  2905. {
  2906. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2907. if (groupData.Code != 0)
  2908. {
  2909. return Ok(JsonView(false, groupData.Msg));
  2910. }
  2911. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2912. }
  2913. /// <summary>
  2914. /// 团组任务分配查询
  2915. /// </summary>
  2916. /// <param name="dto"></param>
  2917. /// <returns></returns>
  2918. [HttpPost]
  2919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2920. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2921. {
  2922. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2923. if (groupData.Code != 0)
  2924. {
  2925. return Ok(JsonView(false, groupData.Msg));
  2926. }
  2927. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2928. }
  2929. /// <summary>
  2930. /// 团组任务分配操作
  2931. /// </summary>
  2932. /// <param name="dto"></param>
  2933. /// <returns></returns>
  2934. [HttpPost]
  2935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2936. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2937. {
  2938. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2939. if (groupData.Code != 0)
  2940. {
  2941. return Ok(JsonView(false, groupData.Msg));
  2942. }
  2943. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2944. }
  2945. /// <summary>
  2946. /// 团组任务分配
  2947. /// 批量分配
  2948. /// 查询团组
  2949. /// </summary>
  2950. /// <param name="dto"></param>
  2951. /// <returns></returns>
  2952. [HttpPost]
  2953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2954. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2955. {
  2956. //参数验证
  2957. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2958. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2959. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2960. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2961. }
  2962. /// <summary>
  2963. /// 团组任务分配
  2964. /// 批量分配
  2965. /// </summary>
  2966. /// <param name="dto"></param>
  2967. /// <returns></returns>
  2968. [HttpPost]
  2969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2970. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2971. {
  2972. //参数验证
  2973. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2974. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2975. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2976. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2977. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2978. }
  2979. #endregion
  2980. #region 团组费用审核
  2981. /// <summary>
  2982. /// 费用审核
  2983. /// 团组列表 Page
  2984. /// </summary>
  2985. /// <param name="_dto">团组列表请求dto</param>
  2986. /// <returns></returns>
  2987. [HttpPost]
  2988. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2989. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2990. {
  2991. #region 参数验证
  2992. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2993. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2994. #region 页面操作权限验证
  2995. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2996. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2997. #endregion
  2998. #endregion
  2999. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  3000. {
  3001. string sqlWhere = string.Empty;
  3002. if (_dto.IsSure == 0) //未完成
  3003. {
  3004. sqlWhere += string.Format(@" And IsSure = 0");
  3005. }
  3006. else if (_dto.IsSure == 1) //已完成
  3007. {
  3008. sqlWhere += string.Format(@" And IsSure = 1");
  3009. }
  3010. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  3011. {
  3012. string tj = _dto.SearchCriteria;
  3013. 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}%')",
  3014. tj, tj, tj, tj, tj);
  3015. }
  3016. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3017. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  3018. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3019. From (
  3020. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  3021. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  3022. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  3023. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3024. From Grp_DelegationInfo gdi
  3025. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3026. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3027. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3028. Where gdi.IsDel = 0 {0}
  3029. ) temp ", sqlWhere);
  3030. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3031. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  3032. var _view = new
  3033. {
  3034. PageFuncAuth = pageFunAuthView,
  3035. Data = _DelegationList
  3036. };
  3037. return Ok(JsonView(true, "查询成功!", _view, total));
  3038. }
  3039. else
  3040. {
  3041. return Ok(JsonView(false, "查询失败"));
  3042. }
  3043. }
  3044. /// <summary>
  3045. /// 获取团组费用审核
  3046. /// </summary>
  3047. /// <param name="_dto"></param>
  3048. /// <returns></returns>
  3049. [HttpPost]
  3050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3051. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  3052. {
  3053. try
  3054. {
  3055. #region 参数验证
  3056. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3057. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3058. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  3059. #region 页面操作权限验证
  3060. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3061. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3062. #endregion
  3063. #endregion
  3064. var _view = new Grp_CreditCardPaymentView();
  3065. var clientNameList = GetSimplClientList(_dto.DiId);
  3066. #region 费用清单
  3067. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  3068. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  3069. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  3070. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  3071. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  3072. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  3073. /*
  3074. * 76://酒店预订
  3075. */
  3076. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3077. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3078. /*
  3079. * 79://车/导游地接
  3080. */
  3081. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3082. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3083. /*
  3084. * 80: //签证
  3085. */
  3086. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3087. /*
  3088. *81: //邀请/公务活动
  3089. */
  3090. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3091. /*
  3092. * 82: //团组客户保险
  3093. */
  3094. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3095. /*
  3096. * Lable = 85 机票预订
  3097. */
  3098. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3099. /*
  3100. * 85 机票预定
  3101. */
  3102. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3103. /*
  3104. * 98 其他款项
  3105. */
  3106. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3107. /*
  3108. * 285:收款退还
  3109. */
  3110. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3111. /*
  3112. * 1015: //超支费用
  3113. */
  3114. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3115. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  3116. /*
  3117. * 币种信息
  3118. */
  3119. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  3120. /*
  3121. * 车/导游地接 费用类型
  3122. */
  3123. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  3124. /*
  3125. * 车/导游地接 费用类型
  3126. */
  3127. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  3128. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  3129. /*
  3130. * 用户信息
  3131. */
  3132. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  3133. /*
  3134. * 费用模块
  3135. */
  3136. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  3137. string priceModule = string.Empty;
  3138. if (sdPriceName != null)
  3139. {
  3140. priceModule = sdPriceName.Name;
  3141. }
  3142. /*
  3143. * 成本信息
  3144. */
  3145. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  3146. decimal _groupRate = 0.0000M;
  3147. string _groupCurrencyCode = "-";
  3148. if (groupCost != null)
  3149. {
  3150. _groupRate = groupCost.Rate;
  3151. if (int.TryParse(groupCost.Currency, out int _currency))
  3152. {
  3153. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  3154. }
  3155. else _groupCurrencyCode = groupCost.Currency;
  3156. }
  3157. string costContentSql = $"Select * From Grp_GroupCost";
  3158. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  3159. //处理日期为空的天数
  3160. for (int i = 0; i < groupCostDetails.Count; i++)
  3161. if (i != 0)
  3162. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  3163. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  3164. /*
  3165. * 处理详情数据
  3166. */
  3167. foreach (var entity in entityList)
  3168. {
  3169. var _detail = new Grp_CreditCardPaymentDetailView
  3170. {
  3171. Id = entity.Id,
  3172. PriceName = priceModule,
  3173. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  3174. };
  3175. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3176. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  3177. //处理金额
  3178. if (entity.CTable == 1015)
  3179. {
  3180. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  3181. if (czInfo != null)
  3182. {
  3183. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3184. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3185. }
  3186. }
  3187. /*
  3188. * 应付款金额
  3189. */
  3190. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3191. string PaymentCurrency_WaitPay = "Unknown";
  3192. string hotelCurrncyCode = "Unknown";
  3193. string hotelCurrncyName = "Unknown";
  3194. if (sdPaymentCurrency_WaitPay != null)
  3195. {
  3196. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3197. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3198. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3199. if (hotelCurrncyCode.Equals("CNY"))
  3200. {
  3201. entity.DayRate = 1.0000M;
  3202. }
  3203. }
  3204. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3205. /*
  3206. * 此次付款金额
  3207. */
  3208. decimal CurrPayStr = 0.00M,
  3209. OriginalCurrPay = 0.00M;
  3210. if (entity.PayPercentage == 0)
  3211. {
  3212. if (entity.PayThenMoney != 0)
  3213. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3214. }
  3215. else
  3216. {
  3217. if (entity.PayMoney != 0)
  3218. {
  3219. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3220. }
  3221. }
  3222. //if (_dto.Label == 79)
  3223. //{
  3224. // string original = string.Empty;
  3225. // if (hotelCurrncyCode.Equals("CNY"))
  3226. // {
  3227. // OriginalCurrPay = CurrPayStr;
  3228. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3229. // }
  3230. // else
  3231. // {
  3232. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3233. // //760 EUR(7600.00 CNY)
  3234. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3235. // }
  3236. //}
  3237. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3238. string original = string.Empty;
  3239. if (hotelCurrncyCode.Equals("CNY"))
  3240. {
  3241. OriginalCurrPay = CurrPayStr;
  3242. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3243. }
  3244. else
  3245. {
  3246. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3247. //760 EUR(7600.00 CNY)
  3248. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3249. }
  3250. /*
  3251. * 剩余尾款
  3252. */
  3253. decimal BalanceStr = 0;
  3254. if (CurrPayStr != 0)
  3255. {
  3256. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3257. BalanceStr = 0;
  3258. else
  3259. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3260. }
  3261. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3262. /*
  3263. * Bus名称
  3264. */
  3265. _detail.BusName = "待增加";
  3266. /*
  3267. *费用所属
  3268. */
  3269. switch (entity.CTable)
  3270. {
  3271. case 76://酒店预订
  3272. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3273. if (hotelReservations != null)
  3274. {
  3275. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3276. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3277. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3278. string roomFeeStr = "", roomFeestr1 = "";
  3279. //是否比较房型价格
  3280. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3281. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3282. roomFeeStr += $"<br/>";
  3283. var roomTotal = 0.00M;
  3284. if (hotelReservations.SingleRoomPrice > 0)
  3285. {
  3286. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3287. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3288. //__isSingle = true;
  3289. roomTotal += fee;
  3290. }
  3291. if (hotelReservations.DoubleRoomPrice > 0)
  3292. {
  3293. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3294. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3295. // __isDouble = true;
  3296. roomTotal += fee;
  3297. }
  3298. if (hotelReservations.SuiteRoomPrice > 0)
  3299. {
  3300. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3301. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3302. //__isSuite = true;
  3303. roomTotal += fee;
  3304. }
  3305. if (hotelReservations.OtherRoomPrice > 0)
  3306. {
  3307. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3308. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3309. //__isOther = true;
  3310. roomTotal += fee;
  3311. }
  3312. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3313. else roomFeeStr += " 0.00 * 0";
  3314. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3315. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3316. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3317. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3318. /*
  3319. * 费用类型
  3320. * 1:房费
  3321. * 2:早餐
  3322. * 3:地税
  3323. * 4:城市税
  3324. * </summary>
  3325. */
  3326. //地税
  3327. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3328. if (governmentRentData != null)
  3329. {
  3330. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3331. governmentRentFee = governmentRentData.Price;
  3332. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3333. if (governmentRentCurrData != null)
  3334. {
  3335. governmentRentCode = governmentRentCurrData.Name;
  3336. governmentRentName = $"({governmentRentCurrData.Remark})";
  3337. }
  3338. }
  3339. //城市税
  3340. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3341. if (cityTaxData != null)
  3342. {
  3343. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3344. cityTaxFee = cityTaxData.Price;
  3345. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3346. if (cityTaxCurrData != null)
  3347. {
  3348. cityTaxCode = cityTaxCurrData.Name;
  3349. cityTaxName = $"({cityTaxCurrData.Remark})";
  3350. }
  3351. }
  3352. //酒店早餐
  3353. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3354. if (breakfastData != null)
  3355. {
  3356. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3357. breakfastFee = breakfastData.Price;
  3358. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3359. if (breakfastCurrData != null)
  3360. {
  3361. breakfastCode = breakfastCurrData.Name;
  3362. breakfastName = $"({breakfastCurrData.Remark})";
  3363. }
  3364. }
  3365. //房间费用
  3366. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3367. if (roomData != null)
  3368. {
  3369. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3370. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3371. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3372. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3373. roomFee = roomData.Price;
  3374. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3375. if (roomCurrData != null)
  3376. {
  3377. roomCode = roomCurrData.Name;
  3378. roomName = $"({roomCurrData.Remark})";
  3379. }
  3380. }
  3381. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3382. string hotelCostStr = "";
  3383. decimal hotelCsotTotal = 0.00M;
  3384. if (groupCost != null)
  3385. {
  3386. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3387. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3388. }
  3389. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3390. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3391. string hotelCost_day = "";
  3392. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3393. foreach (var item in hotelCostDetails1)
  3394. {
  3395. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3396. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3397. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3398. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3399. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3400. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3401. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3402. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3403. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3404. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3405. hotelCost_day += @$"<br/>";
  3406. }
  3407. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3408. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3409. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3410. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3411. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3412. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3413. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3414. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3415. $"房间说明: {hotelReservations.Remark} <br/>" +
  3416. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3417. $"{hotelBreakfastStr}" +
  3418. $"{hotelGovernmentRentStr}" +
  3419. $"{hotelCityTaxStr}";
  3420. _detail.PriceNameContent = hotelReservations.HotelName;
  3421. }
  3422. break;
  3423. case 79://车/导游地接
  3424. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3425. if (touristGuideGroundReservations != null)
  3426. {
  3427. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3428. {
  3429. _detail.BusName = touristGuideGroundReservations.BusName;
  3430. }
  3431. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3432. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3433. //if (isInt)
  3434. //{
  3435. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3436. // if (cityInfo != null)
  3437. // {
  3438. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3439. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3440. // if (carFeeItem != null)
  3441. // {
  3442. // nameContent += $@"({carFeeItem.Name})";
  3443. // }
  3444. // _detail.PriceNameContent = nameContent;
  3445. // }
  3446. //}
  3447. //else
  3448. //{
  3449. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3450. //}
  3451. var touristGuideGroundReservationsContents =
  3452. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3453. var opContent_sb = new StringBuilder();
  3454. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3455. opContent_sb.AppendLine(contetTitle);
  3456. foreach (var item in touristGuideGroundReservationsContents)
  3457. {
  3458. string typeName = "Unknown";
  3459. string carCurrencyCode = "Unknown";
  3460. string carCurrencyName = "Unknown";
  3461. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3462. if (carTypeData != null) typeName = carTypeData.Name;
  3463. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3464. if (currencyData != null)
  3465. {
  3466. carCurrencyCode = currencyData.Name;
  3467. carCurrencyName = currencyData.Remark;
  3468. }
  3469. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3470. bool IsCurrencyAgreement = false;
  3471. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3472. string opCostStr = string.Empty;
  3473. decimal opCostTypePrice = 0.00M;
  3474. #region 处理成本各项费用
  3475. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3476. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3477. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3478. costOPFeeCNY = 0.00M, //团组成本 op费用
  3479. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3480. if (opCost.Count > 0)
  3481. {
  3482. switch (item.SId)
  3483. {
  3484. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3485. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3486. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3487. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3488. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3489. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3490. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3491. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3492. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3493. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3494. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3495. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3496. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3497. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3498. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3499. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3500. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3501. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3502. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3503. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3504. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3505. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3506. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3507. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3508. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3509. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3510. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3511. }
  3512. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3513. costOPFeeCNY = opCostTypePrice * _groupRate;
  3514. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3515. }
  3516. #endregion
  3517. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3518. aduitOPFeeCNY = item.Price * entity.DayRate;
  3519. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3520. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3521. $"{opTypeStr} {opCostStr}<br/>" +
  3522. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3523. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3524. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3525. {
  3526. if (IsCurrencyAgreement)
  3527. {
  3528. if (item.Price > opCostTypePrice)
  3529. {
  3530. opContent_sb.Append("<span style='color:red;'>");
  3531. opContent_sb.Append(opContent);
  3532. opContent_sb.Append("</span>");
  3533. opContent_sb.AppendLine();
  3534. }
  3535. else
  3536. {
  3537. opContent_sb.Append(opContent);
  3538. opContent_sb.AppendLine();
  3539. }
  3540. }
  3541. else
  3542. {
  3543. //验证是否超成本 按付款比例计算
  3544. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3545. {
  3546. opContent_sb.Append("<span style='color:red;'>");
  3547. opContent_sb.Append(opContent);
  3548. opContent_sb.Append("</span>");
  3549. opContent_sb.AppendLine();
  3550. }
  3551. else
  3552. {
  3553. opContent_sb.Append(opContent);
  3554. opContent_sb.AppendLine();
  3555. }
  3556. }
  3557. }
  3558. else
  3559. {
  3560. opContent_sb.Append(opContent);
  3561. opContent_sb.AppendLine();
  3562. }
  3563. }
  3564. _detail.PriceMsgContent = opContent_sb.ToString();
  3565. }
  3566. break;
  3567. case 80: //签证
  3568. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3569. if (visaInfo != null)
  3570. {
  3571. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  3572. _detail.PriceNameContent = visaInfo.VisaDescription;
  3573. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3574. }
  3575. break;
  3576. case 81: //邀请/公务活动
  3577. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3578. if (_ioa != null)
  3579. {
  3580. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3581. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3582. sendCurrName = "Unknown", //快递费用币种 Name
  3583. sendCurrCode = "Unknown", //快递费用币种 Code
  3584. eventsCurrName = "Unknown", //公务活动费币种 Name
  3585. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3586. translateCurrName = "Unknown", //公务翻译费 Name
  3587. translateCurrCode = "Unknown"; //公务翻译费 Code
  3588. #region 处理费用币种
  3589. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3590. if (inviteCurrData != null)
  3591. {
  3592. inviteCurrName = inviteCurrData.Remark;
  3593. inviteCurrCode = inviteCurrData.Name;
  3594. }
  3595. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3596. if (sendCurrData != null)
  3597. {
  3598. sendCurrName = sendCurrData.Remark;
  3599. sendCurrCode = sendCurrData.Name;
  3600. }
  3601. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3602. if (eventsCurrData != null)
  3603. {
  3604. eventsCurrName = eventsCurrData.Remark;
  3605. eventsCurrCode = eventsCurrData.Name;
  3606. }
  3607. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3608. if (translateCurrData != null)
  3609. {
  3610. translateCurrName = translateCurrData.Remark;
  3611. translateCurrCode = translateCurrData.Name;
  3612. }
  3613. #endregion
  3614. _detail.PriceNameContent = _ioa.InviterArea;
  3615. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  3616. List<string> priceExpNames = new List<string>();
  3617. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  3618. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  3619. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  3620. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  3621. if (priceExpNames != null && priceExpNames.Count > 0)
  3622. {
  3623. _detail.PriceNameContent += $"({string.Join("+", priceExpNames)})";
  3624. }
  3625. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3626. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3627. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3628. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3629. $@"备注:" + _ioa.Remark + "<br/>";
  3630. }
  3631. break;
  3632. case 82: //团组客户保险
  3633. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3634. if (customers != null)
  3635. {
  3636. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3637. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3638. }
  3639. break;
  3640. case 85: //机票预订
  3641. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3642. if (jpRes != null)
  3643. {
  3644. string FlightsDescription = jpRes.FlightsDescription;
  3645. string PriceDescription = jpRes.PriceDescription;
  3646. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3647. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3648. }
  3649. break;
  3650. case 98://其他款项
  3651. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3652. if (gdpRes != null)
  3653. {
  3654. //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/";
  3655. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  3656. //{
  3657. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  3658. //}
  3659. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3660. _detail.PriceNameContent = gdpRes.PriceName;
  3661. }
  3662. break;
  3663. case 285://收款退还
  3664. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3665. if (refundAndOtherMoney != null)
  3666. {
  3667. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3668. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3669. }
  3670. break;
  3671. case 751://酒店早餐
  3672. break;
  3673. case 1015://超支费用
  3674. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3675. if (groupExtraCost != null)
  3676. {
  3677. _detail.PriceNameContent = groupExtraCost.PriceName;
  3678. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3679. }
  3680. break;
  3681. default:
  3682. break;
  3683. }
  3684. /*
  3685. * 申请人
  3686. */
  3687. string operatorName = " - ";
  3688. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3689. if (_opUser != null)
  3690. {
  3691. operatorName = _opUser.CnName;
  3692. }
  3693. _detail.OperatorName = operatorName;
  3694. /*
  3695. * 审核人
  3696. */
  3697. string auditOperatorName = " - ";
  3698. if (entity.IsAuditGM != 0)
  3699. {
  3700. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3701. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3702. else
  3703. {
  3704. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3705. if (_adUser != null)
  3706. {
  3707. auditOperatorName = _adUser.CnName;
  3708. }
  3709. }
  3710. }
  3711. _detail.AuditOperatorName = auditOperatorName;
  3712. /*
  3713. * 超预算比例
  3714. */
  3715. string overBudgetStr = "";
  3716. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3717. else if (entity.ExceedBudget == 0)
  3718. {
  3719. if (entity.CTable == 76 || entity.CTable == 79)
  3720. {
  3721. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3722. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3723. }
  3724. else
  3725. {
  3726. overBudgetStr = "未超预算";
  3727. }
  3728. }
  3729. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3730. _detail.OverBudget = overBudgetStr;
  3731. decimal auditFee = 0.00M; //已审核金额 人名币
  3732. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3733. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3734. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3735. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3736. {
  3737. auditedFeeOriginal = entity.PayMoney;
  3738. auditFee = CurrPayStr;
  3739. }
  3740. else if (entity.IsAuditGM == 0)
  3741. {
  3742. unAuditFeeCNY = CurrPayStr;
  3743. unAuditFeeOriginal = OriginalCurrPay;
  3744. OriginalCurrPay = 0.00M;
  3745. }
  3746. /*
  3747. * 费用总计
  3748. */
  3749. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3750. {
  3751. CurrencyId = entity.PaymentCurrency,
  3752. CurrencyName = PaymentCurrency_WaitPay,
  3753. AmountPayable = entity.PayMoney,
  3754. ThisPayment = OriginalCurrPay,
  3755. BalancePayment = BalanceStr,
  3756. AuditedFunds = auditFee,
  3757. AuditedFundsOriginal = auditedFeeOriginal,
  3758. UnAuditFundsCNY = unAuditFeeCNY,
  3759. UnAuditFundsOriginal = unAuditFeeOriginal
  3760. });
  3761. _detail.IsAuditGM = entity.IsAuditGM;
  3762. detailList.Add(_detail);
  3763. }
  3764. #endregion
  3765. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3766. /*
  3767. * 下方描述处理
  3768. */
  3769. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3770. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3771. if (ccpCurrencyPrice != null)
  3772. {
  3773. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3774. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3775. }
  3776. else
  3777. {
  3778. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3779. }
  3780. string amountPayableStr = string.Format(@"应付款总金额: ");
  3781. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3782. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3783. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3784. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3785. foreach (var item in nonDuplicat)
  3786. {
  3787. var currencyName = item.CurrencyName;
  3788. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3789. if (strs.Count > 0)
  3790. {
  3791. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3792. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3793. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3794. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3795. //单独处理此次付款金额
  3796. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3797. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3798. //单独处理已审核费用
  3799. //if (item.CurrencyId == 836) //人民币
  3800. //{
  3801. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3802. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3803. //}
  3804. //else
  3805. //{
  3806. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3807. //}
  3808. if (currencyName.Equals("CNY"))
  3809. {
  3810. //已审核费用
  3811. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3812. //未审核费用
  3813. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3814. }
  3815. else
  3816. {
  3817. //已审核费用
  3818. 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"));
  3819. //未审核费用
  3820. 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"));
  3821. }
  3822. }
  3823. }
  3824. _view.TotalStr1 = amountPayableStr[..^1];
  3825. _view.TotalStr2 = thisPaymentStr[..^1];
  3826. _view.TotalStr3 = balancePaymentStr[..^1];
  3827. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3828. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3829. var _view1 = new
  3830. {
  3831. PageFuncAuth = pageFunAuthView,
  3832. Data = _view
  3833. };
  3834. return Ok(JsonView(_view1));
  3835. }
  3836. catch (Exception ex)
  3837. {
  3838. return Ok(JsonView(false, ex.Message));
  3839. }
  3840. }
  3841. /// <summary>
  3842. /// 费用审核
  3843. /// 修改团组费用审核状态
  3844. /// </summary>
  3845. /// <param name="_dto">参数Json字符串</param>
  3846. /// <returns></returns>
  3847. [HttpPost]
  3848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3849. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3850. {
  3851. #region 参数验证
  3852. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3853. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3854. #endregion
  3855. #region 页面操作权限验证
  3856. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3857. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3858. #endregion
  3859. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3860. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3861. DateTime dtNow = DateTime.Now;
  3862. _groupRepository.BeginTran();
  3863. int rst = 0;
  3864. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3865. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3866. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3867. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3868. var msgDatas = new List<dynamic>();
  3869. var dic_ccp_user = new Dictionary<int, int>() { };
  3870. foreach (var item in idList)
  3871. {
  3872. int CreditId = int.Parse(item);
  3873. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3874. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3875. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3876. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3877. .Where(s => s.Id == CreditId)
  3878. .ExecuteCommandAsync();
  3879. if (result < 1)
  3880. {
  3881. rst = -1;
  3882. _groupRepository.RollbackTran();
  3883. return Ok(JsonView(false, "操作失败并回滚!"));
  3884. }
  3885. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3886. if (creditData != null)
  3887. {
  3888. #region 应用通知配置
  3889. try
  3890. {
  3891. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3892. }
  3893. catch (Exception ex)
  3894. {
  3895. }
  3896. #endregion
  3897. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3898. string groupNameStr = string.Empty;
  3899. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3900. if (groupData != null) groupNameStr = groupData.TeamName;
  3901. string creditTypeStr = string.Empty;
  3902. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3903. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3904. string creditCurrency = string.Empty;
  3905. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3906. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3907. if (creditCurrency.Equals("CNY"))
  3908. {
  3909. creditData.DayRate = 1.0000M;
  3910. }
  3911. if (creditData.PayPercentage == 0.00M)
  3912. {
  3913. creditData.PayPercentage = 100M;
  3914. }
  3915. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3916. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3917. string msgContent = "";
  3918. if (creditCurrency.Equals("CNY"))
  3919. {
  3920. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3921. }
  3922. else
  3923. {
  3924. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3925. }
  3926. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3927. }
  3928. }
  3929. if (rst == 0)
  3930. {
  3931. _groupRepository.CommitTran();
  3932. foreach (var item in msgDatas)
  3933. {
  3934. //发送消息
  3935. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3936. }
  3937. #region 应用推送
  3938. try
  3939. {
  3940. foreach (var ccpId in dic_ccp_user.Keys)
  3941. {
  3942. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3943. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3944. }
  3945. }
  3946. catch (Exception)
  3947. {
  3948. }
  3949. #endregion
  3950. return Ok(JsonView(true, "操作成功!"));
  3951. }
  3952. return Ok(JsonView(false, "操作失败!"));
  3953. }
  3954. /// <summary>
  3955. /// 费用审核
  3956. /// 其他款项 文件下载
  3957. /// </summary>
  3958. /// <param name="id">其他款项 主键编号</param>
  3959. /// <returns></returns>
  3960. [HttpGet("{id}")]
  3961. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3962. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  3963. {
  3964. //网站域名
  3965. const string baseUrl = "http://132.232.92.186:24/Office/GrpFile/%E5%9B%A2%E7%BB%84%E5%A2%9E%E5%87%8F%E6%AC%BE%E9%A1%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6/";
  3966. var otherInfo = await _decreasePaymentsRep._sqlSugar
  3967. .Queryable<Grp_DecreasePayments>()
  3968. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  3969. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  3970. .Select((x, y) => new
  3971. {
  3972. x.Id,
  3973. x.FilePath
  3974. })
  3975. .FirstAsync();
  3976. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  3977. {
  3978. var url = $"{baseUrl}{otherInfo.FilePath}";
  3979. return Ok(JsonView(true, "操作成功!", url));
  3980. }
  3981. return Ok(JsonView(false, "暂无附件"));
  3982. }
  3983. #endregion
  3984. #region 机票费用录入
  3985. /// <summary>
  3986. /// 机票录入当前登录人可操作团组
  3987. /// </summary>
  3988. /// <param name="dto"></param>
  3989. /// <returns></returns>
  3990. [HttpPost]
  3991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3992. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3993. {
  3994. try
  3995. {
  3996. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3997. if (groupData.Code != 0)
  3998. {
  3999. return Ok(JsonView(false, groupData.Msg));
  4000. }
  4001. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4002. }
  4003. catch (Exception ex)
  4004. {
  4005. return Ok(JsonView(false, ex.Message));
  4006. }
  4007. }
  4008. /// <summary>
  4009. /// 机票费用录入列表
  4010. /// </summary>
  4011. /// <param name="dto"></param>
  4012. /// <returns></returns>
  4013. [HttpPost]
  4014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4015. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  4016. {
  4017. try
  4018. {
  4019. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  4020. if (groupData.Code != 0)
  4021. {
  4022. return Ok(JsonView(false, groupData.Msg));
  4023. }
  4024. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4025. }
  4026. catch (Exception ex)
  4027. {
  4028. return Ok(JsonView(false, ex.Message));
  4029. throw;
  4030. }
  4031. }
  4032. /// <summary>
  4033. /// 根据id查询费用录入信息
  4034. /// </summary>
  4035. /// <param name="dto"></param>
  4036. /// <returns></returns>
  4037. [HttpPost]
  4038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4039. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  4040. {
  4041. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  4042. if (groupData.Code != 0)
  4043. {
  4044. return Ok(JsonView(false, groupData.Msg));
  4045. }
  4046. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4047. }
  4048. /// <summary>
  4049. /// 机票费用录入操作(Status:1.新增,2.修改)
  4050. /// </summary>
  4051. /// <param name="dto"></param>
  4052. /// <returns></returns>
  4053. [HttpPost]
  4054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4055. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  4056. {
  4057. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  4058. if (groupData.Code != 0)
  4059. {
  4060. return Ok(JsonView(false, groupData.Msg));
  4061. }
  4062. #region 应用推送
  4063. try
  4064. {
  4065. var diId = dto.AirTicketResOpData.DiId;
  4066. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4067. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4068. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4069. //自动审核
  4070. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  4071. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  4072. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  4073. $"GroupId:{diId};airId:{dataId};",
  4074. status,
  4075. auditMsg);
  4076. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4077. //2024-10-21 新增LZ UID
  4078. var userIds = new List<int>() { 21 };
  4079. string title = $"系统通知";
  4080. string content = "";
  4081. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4082. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4083. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4084. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4085. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4086. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  4087. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4088. }
  4089. catch (Exception ex)
  4090. {
  4091. }
  4092. #endregion
  4093. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4094. }
  4095. /// <summary>
  4096. /// 机票费用自动审核 AI识别方式
  4097. /// </summary>
  4098. /// <returns></returns>
  4099. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  4100. {
  4101. var ecoTypeIds = new List<int>() {
  4102. 459, //超经舱
  4103. 460, //经济舱
  4104. 1430, //公务舱(实际经济舱)
  4105. 1432, //头等舱(实际经济舱)
  4106. };
  4107. var bizTypeIds = new List<int>() {
  4108. 457, //头等舱
  4109. 458, //公务舱
  4110. 1431, //头等舱(实际公务舱)
  4111. };
  4112. var auditFeeTypeIds = new List<int>() { };
  4113. auditFeeTypeIds.AddRange(ecoTypeIds);
  4114. auditFeeTypeIds.AddRange(bizTypeIds);
  4115. int currModule = 85;
  4116. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  4117. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  4118. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  4119. .Select((x, y) => new
  4120. {
  4121. x.Id,
  4122. CcpId = y.Id,
  4123. x.FlightsDate,
  4124. x.PrePrice,
  4125. x.CType,
  4126. x.ClientNum,
  4127. x.DIId
  4128. })
  4129. .FirstAsync();
  4130. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  4131. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  4132. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  4133. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  4134. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  4135. var groupCostContents = await _sqlSugar
  4136. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  4137. .Where(x => x.IsDel == 0 && x.Diid == diId)
  4138. .ToListAsync();
  4139. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  4140. //处理 成本详细信息日期为空 填装费用信息
  4141. var airFeeLabel = new StringBuilder();
  4142. airFeeLabel.AppendLine("费用成本:");
  4143. for (int i = 0; i < groupCostContents.Count; i++)
  4144. {
  4145. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  4146. {
  4147. int index = i - 1;
  4148. if (index >= 0)
  4149. {
  4150. groupCostContents[i].Date = groupCostContents[index].Date;
  4151. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4152. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4153. }
  4154. }
  4155. else
  4156. {
  4157. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4158. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4159. }
  4160. var item = groupCostContents[i];
  4161. airFeeLabel.AppendLine($"{item.Date}");
  4162. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  4163. }
  4164. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  4165. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  4166. //访问Kimi AI 返回价格结果
  4167. var msgs = new List<SeedMessages>()
  4168. {
  4169. new ()
  4170. {
  4171. Role = KimiRole.user,
  4172. Content = airFeeLabel.ToString()
  4173. }
  4174. };
  4175. var client = new KiMiApiClient();
  4176. var kimiApiResult = await client.SeedMessage(msgs);
  4177. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  4178. string clients = kimiApiResult_JObject["content"].ToString();
  4179. decimal ecoPri_kimiAI = 0.00M,
  4180. bizPri_kimiAI = 0.00M;
  4181. //单个价格: 经济舱价格
  4182. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  4183. //价格文本包含/:/前经济舱价格 /后公务舱价格
  4184. if (clients.Contains('/'))
  4185. {
  4186. var priArray = clients.Split('/');
  4187. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  4188. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  4189. }
  4190. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  4191. var isAutoAudit = false;
  4192. //价格验证处理
  4193. //经济舱
  4194. if (ecoTypeIds.Contains(airInfo.CType))
  4195. {
  4196. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  4197. }
  4198. //公务舱
  4199. else if (bizTypeIds.Contains(airInfo.CType))
  4200. {
  4201. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4202. }
  4203. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4204. //是否执行自动审核
  4205. if (isAutoAudit)
  4206. {
  4207. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4208. .SetColumns(x => x.IsAuditGM == 3)
  4209. .SetColumns(x => x.AuditGMOperate == 4)
  4210. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4211. .Where(x => x.Id == airInfo.CcpId)
  4212. .ExecuteCommandAsync();
  4213. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4214. }
  4215. return (false, "当前费用超过成本费用,不可自动审核!");
  4216. }
  4217. /// <summary>
  4218. /// 机票费用录入
  4219. /// 自动审核测试 - AI 识别
  4220. /// </summary>
  4221. /// <param name="groupId"></param>
  4222. /// <param name="Id"></param>
  4223. /// <returns></returns>
  4224. [HttpPost]
  4225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4226. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4227. {
  4228. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4229. return Ok(JsonView(status, msg));
  4230. }
  4231. /// <summary>
  4232. /// 根据舱位类型查询接团客户名单信息
  4233. /// </summary>
  4234. /// <param name="dto"></param>
  4235. /// <returns></returns>
  4236. [HttpPost]
  4237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4238. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4239. {
  4240. try
  4241. {
  4242. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4243. if (crm_Groups.Count != 0)
  4244. {
  4245. var Customer = new List<dynamic>();
  4246. foreach (var item in crm_Groups)
  4247. {
  4248. var data = new
  4249. {
  4250. item.Id,
  4251. item.Pinyin,
  4252. Name = item.LastName + item.FirstName
  4253. };
  4254. Customer.Add(data);
  4255. }
  4256. return Ok(JsonView(true, "查询成功!", Customer));
  4257. }
  4258. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4259. }
  4260. catch (Exception ex)
  4261. {
  4262. return Ok(JsonView(false, "程序错误!"));
  4263. throw;
  4264. }
  4265. }
  4266. /// <summary>
  4267. /// 根据团号获取客户信息
  4268. /// </summary>
  4269. /// <param name="dto"></param>
  4270. /// <returns></returns>
  4271. [HttpPost]
  4272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4273. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4274. {
  4275. var jw = JsonView(false);
  4276. if (dto.DIID < 1)
  4277. {
  4278. jw.Msg += "请输入正确的diid";
  4279. return Ok(jw);
  4280. }
  4281. var arr = GetSimplClientList(dto.DIID);
  4282. jw = JsonView(true, "获取成功!", arr);
  4283. return Ok(jw);
  4284. }
  4285. private List<SimplClientInfo> GetSimplClientList(int diId)
  4286. {
  4287. 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);
  4288. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4289. foreach (var item in arr)
  4290. {
  4291. EncryptionProcessor.DecryptProperties(item);
  4292. }
  4293. return arr;
  4294. }
  4295. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4296. {
  4297. string result = origin;
  4298. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4299. {
  4300. string[] temparr = origin.Split(',');
  4301. string fistrStr = temparr[0];
  4302. int count = temparr.Length;
  4303. bool success = int.TryParse(fistrStr, out int tempId);
  4304. if (success)
  4305. {
  4306. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4307. if (tempInfo != null)
  4308. {
  4309. if (count > 1)
  4310. {
  4311. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4312. }
  4313. else
  4314. {
  4315. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4316. }
  4317. }
  4318. }
  4319. }
  4320. return result;
  4321. }
  4322. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4323. {
  4324. string result = origin;
  4325. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4326. {
  4327. string[] temparr = origin.Split(',');
  4328. result = "";
  4329. foreach (var item in temparr)
  4330. {
  4331. bool success = int.TryParse(item, out int tempId);
  4332. if (success)
  4333. {
  4334. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4335. if (tempInfo != null)
  4336. {
  4337. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4338. }
  4339. }
  4340. }
  4341. }
  4342. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4343. return result;
  4344. }
  4345. /// <summary>
  4346. /// 机票费用录入,删除
  4347. /// </summary>
  4348. /// <param name="dto"></param>
  4349. /// <returns></returns>
  4350. [HttpPost]
  4351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4352. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4353. {
  4354. try
  4355. {
  4356. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4357. if (res)
  4358. {
  4359. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4360. {
  4361. IsDel = 1,
  4362. DeleteUserId = dto.DeleteUserId,
  4363. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4364. }).ExecuteCommandAsync();
  4365. return Ok(JsonView(true, "删除成功!"));
  4366. }
  4367. return Ok(JsonView(false, "删除失败!"));
  4368. }
  4369. catch (Exception ex)
  4370. {
  4371. return Ok(JsonView(false, "程序错误!"));
  4372. throw;
  4373. }
  4374. }
  4375. /// <summary>
  4376. /// 导出机票录入报表
  4377. /// </summary>
  4378. /// <param name="dto"></param>
  4379. /// <returns></returns>
  4380. [HttpPost]
  4381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4382. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4383. {
  4384. try
  4385. {
  4386. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4387. if (groupData.Code != 0)
  4388. {
  4389. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4390. }
  4391. else
  4392. {
  4393. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4394. if (AirTicketReservations.Count != 0)
  4395. {
  4396. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4397. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4398. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4399. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4400. var designer = new WorkbookDesigner
  4401. {
  4402. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4403. };
  4404. decimal countCost = 0;
  4405. foreach (var item in AirTicketReservations)
  4406. {
  4407. #region 处理客人姓名
  4408. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4409. item.ClientName = clientNames;
  4410. #endregion
  4411. if (item.BankType == "其他")
  4412. {
  4413. item.BankNo = "--";
  4414. }
  4415. else
  4416. {
  4417. if (!string.IsNullOrEmpty(item.BankType))
  4418. {
  4419. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  4420. }
  4421. }
  4422. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4423. item.Price = System.Decimal.Round(item.Price, 2);
  4424. countCost += Convert.ToDecimal(item.Price);
  4425. }
  4426. designer.SetDataSource("Export", AirTicketReservations);
  4427. designer.SetDataSource("ExportDiCode", diCode);
  4428. designer.SetDataSource("ExportDiName", diName);
  4429. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4430. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4431. designer.Process();
  4432. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4433. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4434. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4435. return Ok(JsonView(true, "成功", url = rst));
  4436. }
  4437. else
  4438. {
  4439. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4440. }
  4441. }
  4442. }
  4443. catch (Exception ex)
  4444. {
  4445. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4446. throw;
  4447. }
  4448. }
  4449. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  4450. /// <summary>
  4451. /// 行程单导出
  4452. /// </summary>
  4453. /// <param name="dto"></param>
  4454. /// <returns></returns>
  4455. [HttpPost]
  4456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4457. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4458. {
  4459. try
  4460. {
  4461. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4462. if (groupData.Code != 0)
  4463. {
  4464. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4465. }
  4466. else
  4467. {
  4468. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4469. if (dto.Language == "CN")
  4470. {
  4471. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4472. var builder = new DocumentBuilder(doc);
  4473. int tableIndex = 0;//表格索引
  4474. //得到文档中的第一个表格
  4475. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4476. foreach (var item in _AirTicketReservations)
  4477. {
  4478. #region 处理固定数据
  4479. string[] FlightsCode = item.FlightsCode.Split('/');
  4480. if (FlightsCode.Length != 0)
  4481. {
  4482. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4483. if (_AirCompany != null)
  4484. {
  4485. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4486. }
  4487. else
  4488. {
  4489. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4490. }
  4491. }
  4492. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4493. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4494. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4495. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4496. string name = "";
  4497. foreach (string clientName in nameArray)
  4498. {
  4499. if (!name.Contains(clientName))
  4500. {
  4501. name += clientName + ",";
  4502. }
  4503. }
  4504. if (!string.IsNullOrWhiteSpace(name))
  4505. {
  4506. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4507. }
  4508. else
  4509. {
  4510. table.Range.Bookmarks["ClientName"].Text = "--";
  4511. }
  4512. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4513. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4514. table.Range.Bookmarks["JointTicket"].Text = "--";
  4515. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4516. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4517. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4518. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4519. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4520. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4521. #endregion
  4522. #region 循环数据处理
  4523. var airs = new List<AirInfo>();
  4524. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4525. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4526. for (int i = 0; i < FlightsCode.Length; i++)
  4527. {
  4528. var air = new AirInfo();
  4529. string[] tempstr = DayArray[i]
  4530. .Replace("\r\n", string.Empty)
  4531. .Replace("\\r\\n", string.Empty)
  4532. .TrimStart().TrimEnd()
  4533. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4534. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4535. string starCity = "";
  4536. if (star_Three != null)
  4537. {
  4538. starCity = star_Three.AirPort;
  4539. }
  4540. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4541. string EndCity = "";
  4542. if (End_Three != null)
  4543. {
  4544. EndCity = End_Three.AirPort;
  4545. }
  4546. air.Destination = starCity + "/" + EndCity;
  4547. air.Flight = FlightsCode[i];
  4548. air.SeatingClass = item.CTypeName;
  4549. string dateTime = tempstr[2];
  4550. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4551. air.FlightDate = DateTemp;
  4552. air.DepartureTime = tempstr[5];
  4553. air.LandingTime = tempstr[6];
  4554. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4555. air.TicketStatus = "--";
  4556. air.Luggage = "--";
  4557. air.DepartureTerminal = "--";
  4558. air.LandingTerminal = "--";
  4559. airs.Add(air);
  4560. }
  4561. int row = 13;
  4562. for (int i = 0; i < airs.Count; i++)
  4563. {
  4564. if (airs.Count > 2)
  4565. {
  4566. for (int j = 0; j < airs.Count - 2; j++)
  4567. {
  4568. var CopyRow = table.Rows[12].Clone(true);
  4569. table.Rows.Add(CopyRow);
  4570. }
  4571. }
  4572. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4573. int index = 0;
  4574. foreach (PropertyInfo property in properties)
  4575. {
  4576. string value = property.GetValue(airs[i]).ToString();
  4577. Cell ishcel0 = table.Rows[row].Cells[index];
  4578. var p = new Paragraph(doc);
  4579. string s = value;
  4580. p.AppendChild(new Run(doc, s));
  4581. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4582. ishcel0.AppendChild(p);
  4583. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4584. index++;
  4585. }
  4586. row++;
  4587. }
  4588. #endregion
  4589. var lastParagraph = new Paragraph(doc);
  4590. //第一个表格末尾加段落
  4591. table.ParentNode.InsertAfter(lastParagraph, table);
  4592. //复制第一个表格
  4593. Table cloneTable = (Table)table.Clone(true);
  4594. //在文档末尾段落后面加入复制的表格
  4595. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4596. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4597. {
  4598. int rownewsIndex = 13;
  4599. for (int i = 0; i < 2; i++)
  4600. {
  4601. var CopyRow = table.Rows[12].Clone(true);
  4602. table.Rows.RemoveAt(13);
  4603. table.Rows.Add(CopyRow);
  4604. rownewsIndex++;
  4605. }
  4606. }
  4607. else
  4608. {
  4609. table.Rows.RemoveAt(12);
  4610. }
  4611. cloneTable.Rows.RemoveAt(12);
  4612. }
  4613. if (_AirTicketReservations.Count != 0)
  4614. {
  4615. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4616. if (FlightsCode.Length != 0)
  4617. {
  4618. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4619. if (_AirCompany != null)
  4620. {
  4621. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4622. }
  4623. else
  4624. {
  4625. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4626. }
  4627. }
  4628. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4629. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4630. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4631. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4632. string name = "";
  4633. foreach (string clientName in nameArray)
  4634. {
  4635. if (!name.Contains(clientName))
  4636. {
  4637. name += clientName + ",";
  4638. }
  4639. }
  4640. if (!string.IsNullOrWhiteSpace(name))
  4641. {
  4642. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4643. }
  4644. else
  4645. {
  4646. table.Range.Bookmarks["ClientName"].Text = "--";
  4647. }
  4648. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4649. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4650. table.Range.Bookmarks["JointTicket"].Text = "--";
  4651. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4652. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4653. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4654. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4655. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4656. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4657. }
  4658. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4659. //保存合并后的文档
  4660. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4661. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4662. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4663. return Ok(JsonView(true, "成功!", rst));
  4664. }
  4665. else
  4666. {
  4667. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4668. var builder = new DocumentBuilder(doc);
  4669. int tableIndex = 0;//表格索引
  4670. //得到文档中的第一个表格
  4671. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4672. var texts = new List<string>();
  4673. foreach (var item in _AirTicketReservations)
  4674. {
  4675. string[] FlightsCode = item.FlightsCode.Split('/');
  4676. if (FlightsCode.Length != 0)
  4677. {
  4678. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4679. if (_AirCompany != null)
  4680. {
  4681. if (!transDic.ContainsKey(_AirCompany.CnName))
  4682. {
  4683. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4684. }
  4685. }
  4686. else
  4687. {
  4688. if (!transDic.ContainsKey("--"))
  4689. {
  4690. transDic.Add("--", "--");
  4691. }
  4692. }
  4693. }
  4694. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4695. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4696. string name = "";
  4697. foreach (string clientName in nameArray)
  4698. {
  4699. name += clientName + ",";
  4700. }
  4701. if (!texts.Contains(name))
  4702. {
  4703. texts.Add(name);
  4704. }
  4705. var airs = new List<AirInfo>();
  4706. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4707. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4708. for (int i = 0; i < FlightsCode.Length; i++)
  4709. {
  4710. var air = new AirInfo();
  4711. string[] tempstr = DayArray[i]
  4712. .Replace("\r\n", string.Empty)
  4713. .Replace("\\r\\n", string.Empty)
  4714. .TrimStart().TrimEnd()
  4715. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4716. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4717. if (star_Three != null)
  4718. {
  4719. if (!transDic.ContainsKey(star_Three.AirPort))
  4720. {
  4721. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4722. }
  4723. }
  4724. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4725. if (End_Three != null)
  4726. {
  4727. if (!transDic.ContainsKey(End_Three.AirPort))
  4728. {
  4729. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4730. }
  4731. }
  4732. if (!texts.Contains(item.CTypeName))
  4733. {
  4734. texts.Add(item.CTypeName);
  4735. }
  4736. }
  4737. }
  4738. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4739. if (transData.Count > 0)
  4740. {
  4741. foreach (TranslateResult item in transData)
  4742. {
  4743. if (!transDic.ContainsKey(item.Query))
  4744. {
  4745. transDic.Add(item.Query, item.Translation);
  4746. }
  4747. }
  4748. }
  4749. foreach (var item in _AirTicketReservations)
  4750. {
  4751. #region 处理固定数据
  4752. string[] FlightsCode = item.FlightsCode.Split('/');
  4753. if (FlightsCode.Length != 0)
  4754. {
  4755. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4756. if (_AirCompany != null)
  4757. {
  4758. string str = "--";
  4759. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4760. if (!string.IsNullOrEmpty(translateResult))
  4761. {
  4762. str = translateResult;
  4763. str = _airTicketResRep.Processing(str);
  4764. }
  4765. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4766. }
  4767. else
  4768. {
  4769. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4770. }
  4771. }
  4772. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4773. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4774. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4775. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4776. string names = "";
  4777. foreach (string clientName in nameArray)
  4778. {
  4779. names += clientName + ",";
  4780. }
  4781. if (!string.IsNullOrWhiteSpace(names))
  4782. {
  4783. string str = "--";
  4784. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4785. if (!string.IsNullOrEmpty(translateResult))
  4786. {
  4787. str = translateResult;
  4788. str = _airTicketResRep.Processing(str);
  4789. }
  4790. table.Range.Bookmarks["ClientName"].Text = str;
  4791. }
  4792. else
  4793. {
  4794. table.Range.Bookmarks["ClientName"].Text = "--";
  4795. }
  4796. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4797. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4798. table.Range.Bookmarks["JointTicket"].Text = "--";
  4799. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4800. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4801. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4802. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4803. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4804. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4805. #endregion
  4806. #region 循环数据处理
  4807. var airs = new List<AirInfo>();
  4808. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4809. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4810. for (int i = 0; i < FlightsCode.Length; i++)
  4811. {
  4812. var air = new AirInfo();
  4813. string[] tempstr = DayArray[i]
  4814. .Replace("\r\n", string.Empty)
  4815. .Replace("\\r\\n", string.Empty)
  4816. .TrimStart().TrimEnd()
  4817. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4818. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4819. string starCity = "";
  4820. if (star_Three != null)
  4821. {
  4822. string str2 = "--";
  4823. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4824. if (!string.IsNullOrEmpty(translateResult2))
  4825. {
  4826. str2 = translateResult2;
  4827. str2 = _airTicketResRep.Processing(str2);
  4828. }
  4829. starCity = str2;
  4830. }
  4831. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4832. string EndCity = "";
  4833. if (End_Three != null)
  4834. {
  4835. string str1 = "--";
  4836. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4837. if (!string.IsNullOrEmpty(translateResult1))
  4838. {
  4839. str1 = translateResult1;
  4840. str1 = _airTicketResRep.Processing(str1);
  4841. }
  4842. EndCity = str1;
  4843. }
  4844. air.Destination = starCity + "/" + EndCity;
  4845. air.Flight = FlightsCode[i];
  4846. string str = "--";
  4847. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4848. if (!string.IsNullOrEmpty(translateResult))
  4849. {
  4850. str = translateResult;
  4851. str = _airTicketResRep.Processing(str);
  4852. }
  4853. air.SeatingClass = str;
  4854. string dateTime = tempstr[2];
  4855. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4856. air.FlightDate = DateTemp;
  4857. air.DepartureTime = tempstr[5];
  4858. air.LandingTime = tempstr[6];
  4859. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4860. air.TicketStatus = "--";
  4861. air.Luggage = "--";
  4862. air.DepartureTerminal = "--";
  4863. air.LandingTerminal = "--";
  4864. airs.Add(air);
  4865. }
  4866. int row = 13;
  4867. for (int i = 0; i < airs.Count; i++)
  4868. {
  4869. if (airs.Count > 2)
  4870. {
  4871. for (int j = 0; j < airs.Count - 2; j++)
  4872. {
  4873. var CopyRow = table.Rows[12].Clone(true);
  4874. table.Rows.Add(CopyRow);
  4875. }
  4876. }
  4877. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4878. int index = 0;
  4879. foreach (PropertyInfo property in properties)
  4880. {
  4881. string value = property.GetValue(airs[i]).ToString();
  4882. Cell ishcel0 = table.Rows[row].Cells[index];
  4883. var p = new Paragraph(doc);
  4884. string s = value;
  4885. p.AppendChild(new Run(doc, s));
  4886. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4887. ishcel0.AppendChild(p);
  4888. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4889. //ishcel0.CellFormat.VerticalAlignment=
  4890. index++;
  4891. }
  4892. row++;
  4893. }
  4894. #endregion
  4895. var lastParagraph = new Paragraph(doc);
  4896. //第一个表格末尾加段落
  4897. table.ParentNode.InsertAfter(lastParagraph, table);
  4898. //复制第一个表格
  4899. Table cloneTable = (Table)table.Clone(true);
  4900. //在文档末尾段落后面加入复制的表格
  4901. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4902. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4903. {
  4904. int rownewsIndex = 13;
  4905. for (int i = 0; i < 2; i++)
  4906. {
  4907. var CopyRow = table.Rows[12].Clone(true);
  4908. table.Rows.RemoveAt(13);
  4909. table.Rows.Add(CopyRow);
  4910. rownewsIndex++;
  4911. }
  4912. }
  4913. else
  4914. {
  4915. table.Rows.RemoveAt(12);
  4916. }
  4917. cloneTable.Rows.RemoveAt(12);
  4918. }
  4919. if (_AirTicketReservations.Count != 0)
  4920. {
  4921. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4922. if (FlightsCode.Length != 0)
  4923. {
  4924. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4925. if (_AirCompany != null)
  4926. {
  4927. string str = "--";
  4928. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4929. if (!string.IsNullOrEmpty(translateResult))
  4930. {
  4931. str = translateResult;
  4932. str = _airTicketResRep.Processing(str);
  4933. }
  4934. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4935. }
  4936. else
  4937. {
  4938. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4939. }
  4940. }
  4941. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4942. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4943. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4944. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4945. string names = "";
  4946. foreach (string clientName in nameArray)
  4947. {
  4948. names += clientName + ",";
  4949. }
  4950. if (!string.IsNullOrWhiteSpace(names))
  4951. {
  4952. string str = "--";
  4953. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4954. if (!string.IsNullOrEmpty(translateResult))
  4955. {
  4956. str = translateResult;
  4957. str = _airTicketResRep.Processing(str);
  4958. }
  4959. table.Range.Bookmarks["ClientName"].Text = str;
  4960. }
  4961. else
  4962. {
  4963. table.Range.Bookmarks["ClientName"].Text = "--";
  4964. }
  4965. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4966. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4967. table.Range.Bookmarks["JointTicket"].Text = "--";
  4968. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4969. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4970. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4971. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4972. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4973. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4974. }
  4975. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4976. //保存合并后的文档
  4977. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4978. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4979. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4980. return Ok(JsonView(true, "成功!", rst));
  4981. }
  4982. }
  4983. }
  4984. catch (Exception ex)
  4985. {
  4986. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4987. throw;
  4988. }
  4989. }
  4990. #endregion
  4991. #region 团组增减款项 --> 其他款项
  4992. /// <summary>
  4993. /// 团组增减款项下拉框绑定
  4994. /// </summary>
  4995. /// <param name="dto"></param>
  4996. /// <returns></returns>
  4997. [HttpPost]
  4998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4999. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  5000. {
  5001. #region 参数验证
  5002. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5003. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  5004. #endregion
  5005. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  5006. }
  5007. /// <summary>
  5008. /// 根据团组Id查询团组增减款项
  5009. /// </summary>
  5010. /// <param name="dto"></param>
  5011. /// <returns></returns>
  5012. [HttpPost]
  5013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5014. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  5015. {
  5016. #region 参数验证
  5017. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5018. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5019. #endregion
  5020. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  5021. }
  5022. /// <summary>
  5023. /// 团组增减款项操作(Status:1.新增,2.修改)
  5024. /// </summary>
  5025. /// <param name="dto"></param>
  5026. /// <returns></returns>
  5027. [HttpPost]
  5028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5029. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  5030. {
  5031. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  5032. if (groupData.Code != 200)
  5033. {
  5034. return Ok(JsonView(false, groupData.Msg));
  5035. }
  5036. #region 应用推送
  5037. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  5038. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5039. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5040. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  5041. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  5042. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  5043. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  5044. if (recheck)
  5045. {
  5046. //自动审核
  5047. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  5048. }
  5049. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5050. //2024-10-21 新增LZ UID
  5051. var userIds = new List<int>() { 21 };
  5052. string title = $"系统通知";
  5053. string content = "";
  5054. var diId = dto.DiId;
  5055. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5056. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5057. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5058. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5059. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5060. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  5061. #endregion
  5062. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5063. }
  5064. /// <summary>
  5065. /// 团组增减款项操作 删除
  5066. /// </summary>
  5067. /// <param name="dto"></param>
  5068. /// <returns></returns>
  5069. [HttpPost]
  5070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5071. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  5072. {
  5073. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  5074. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  5075. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  5076. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  5077. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  5078. }
  5079. /// <summary>
  5080. /// 根据团组增减款项Id查询
  5081. /// </summary>
  5082. /// <param name="dto"></param>
  5083. /// <returns></returns>
  5084. [HttpPost]
  5085. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5086. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  5087. {
  5088. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  5089. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  5090. }
  5091. /// <summary>
  5092. /// 查询供应商名称
  5093. /// </summary>
  5094. /// <param name="dto"></param>
  5095. /// <returns></returns>
  5096. [HttpPost]
  5097. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  5098. {
  5099. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  5100. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  5101. ?? new List<Grp_DecreasePayments>();
  5102. dbResult = dbResult.Distinct(new
  5103. ProductComparer()).ToList();
  5104. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  5105. {
  5106. x.Id,
  5107. x.SupplierAddress,
  5108. x.SupplierArea,
  5109. x.SupplierContact,
  5110. x.SupplierContactNumber,
  5111. x.SupplierEmail,
  5112. x.SupplierName,
  5113. x.SupplierSocialAccount,
  5114. x.SupplierTypeId,
  5115. }).ToList());
  5116. return Ok(jw);
  5117. }
  5118. /// <summary>
  5119. /// 团组增减款项 OTA匹配
  5120. /// </summary>
  5121. /// <param name="file"></param>
  5122. /// <returns></returns>
  5123. [HttpPost]
  5124. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  5125. {
  5126. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  5127. string fileName = file.FileName;
  5128. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  5129. {
  5130. return Ok(JsonView(false, "请上传Excel文件!"));
  5131. }
  5132. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  5133. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  5134. if (!Directory.Exists(path))
  5135. {
  5136. Directory.CreateDirectory(path);
  5137. }
  5138. var filePath = @$"{path}/{fileName}";
  5139. //保存文件
  5140. using (FileStream fs = System.IO.File.Create(filePath))
  5141. {
  5142. file.CopyTo(fs);
  5143. fs.Flush();
  5144. }
  5145. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  5146. //读取ExcelFile
  5147. DataTable dt = ConvertExcelToDataTable(filePath);
  5148. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  5149. dt.TableName = "TB";
  5150. //修改table列名
  5151. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  5152. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  5153. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  5154. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  5155. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  5156. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  5157. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  5158. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  5159. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  5160. dt.Columns[9].ColumnName = "Quantity"; // 台数
  5161. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  5162. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  5163. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  5164. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  5165. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  5166. var otaOrderNos = new List<string>();
  5167. foreach (DataRow item in dt.Rows)
  5168. {
  5169. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  5170. }
  5171. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  5172. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  5173. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  5174. .Select((dp, di) => new
  5175. {
  5176. dp.PriceName,
  5177. dp.OTAOrderNo,
  5178. dp.FeeTotal,
  5179. di.TeamName,
  5180. })
  5181. .ToListAsync();
  5182. foreach (DataRow item in dt.Rows)
  5183. {
  5184. var otaOrderNo = item["OTAOrderNo"].ToString();
  5185. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  5186. if (oaData == null) continue;
  5187. item["GroupName"] = oaData.TeamName;
  5188. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  5189. }
  5190. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  5191. var pairs = new Dictionary<string, object>();
  5192. var datas = new List<DataTable>
  5193. {
  5194. dt
  5195. };
  5196. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  5197. return Ok(JsonView(true, "操作成功", new { url }));
  5198. }
  5199. #region
  5200. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  5201. {
  5202. // 创建Workbook对象
  5203. var workbook = new Workbook(excelFilePath);
  5204. // 获取第一个工作表
  5205. var worksheet = workbook.Worksheets[0];
  5206. // 将工作表转换为DataTable
  5207. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5208. return dataTable;
  5209. }
  5210. #endregion
  5211. /// <summary>
  5212. /// 世运会数据
  5213. /// </summary>
  5214. /// <returns></returns>
  5215. [HttpGet]
  5216. public IActionResult WorldGamesData()
  5217. {
  5218. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5219. var groupMenu = setData.GroupBy(x => x.T0);
  5220. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5221. foreach (var item in groupMenu)
  5222. {
  5223. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5224. {
  5225. Data = new SetDataView
  5226. {
  5227. Name = item.Key
  5228. },
  5229. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5230. });
  5231. }
  5232. return Ok(JsonView(true, "success", resultArr));
  5233. }
  5234. #endregion
  5235. #region 文件上传、删除
  5236. /// <summary>
  5237. /// region 文件上传 可以带参数
  5238. /// </summary>
  5239. /// <param name="file"></param>
  5240. /// <returns></returns>
  5241. [HttpPost]
  5242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5243. public async Task<IActionResult> UploadProject(IFormFile file)
  5244. {
  5245. //var TypeName = Request.Headers["TypeName"].ToString();
  5246. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5247. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5248. ////文件名称
  5249. //string projectFileName = file.FileName;
  5250. ////上传的文件的路径
  5251. //string filePath = $"{fileDir}/{projectFileName}";
  5252. //if (TypeName == "A")//A代表团组增减款项
  5253. //{
  5254. // filePath = fileDir + $@"\团组增减款项相关文件";
  5255. // if (!Directory.Exists(filePath))
  5256. // {
  5257. // Directory.CreateDirectory(filePath);
  5258. // }
  5259. // //上传的文件的路径
  5260. // filePath += $@"\{projectFileName}";
  5261. //}
  5262. //else if (TypeName == "B")//B代表商邀相关文件
  5263. //{
  5264. // //上传的文件的路径
  5265. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5266. // if (!Directory.Exists(filePath))
  5267. // {
  5268. // Directory.CreateDirectory(filePath);
  5269. // }
  5270. // //上传的文件的路径
  5271. // filePath = $@"\{projectFileName}";
  5272. //}
  5273. //try
  5274. //{
  5275. // using (FileStream fs = System.IO.File.Create(filePath))
  5276. // {
  5277. // file.CopyTo(fs);
  5278. // fs.Flush();
  5279. // }
  5280. //}
  5281. //catch (Exception ex)
  5282. //{
  5283. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5284. //}
  5285. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5286. try
  5287. {
  5288. var TypeName = Request.Headers["TypeName"].ToString();
  5289. if (file != null)
  5290. {
  5291. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5292. //文件名称
  5293. string projectFileName = file.FileName;
  5294. //上传的文件的路径
  5295. string filePath = $"{fileDir}/{projectFileName}";
  5296. if (TypeName == "A")//A代表团组增减款项
  5297. {
  5298. if (!Directory.Exists(fileDir))
  5299. {
  5300. Directory.CreateDirectory(fileDir);
  5301. }
  5302. //上传的文件的路径
  5303. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5304. }
  5305. else if (TypeName == "B")//B代表商邀相关文件
  5306. {
  5307. if (!Directory.Exists(fileDir))
  5308. {
  5309. Directory.CreateDirectory(fileDir);
  5310. }
  5311. //上传的文件的路径
  5312. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5313. }
  5314. using (FileStream fs = System.IO.File.Create(filePath))
  5315. {
  5316. file.CopyTo(fs);
  5317. fs.Flush();
  5318. }
  5319. return Ok(JsonView(true, "上传成功!", projectFileName));
  5320. }
  5321. else
  5322. {
  5323. return Ok(JsonView(false, "上传失败!"));
  5324. }
  5325. }
  5326. catch (Exception ex)
  5327. {
  5328. return Ok(JsonView(false, ex.Message));
  5329. }
  5330. }
  5331. /// <summary>
  5332. /// 删除指定文件
  5333. /// </summary>
  5334. /// <param name="dto"></param>
  5335. /// <returns></returns>
  5336. [HttpPost]
  5337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5338. public async Task<IActionResult> DelFile(DelFileDto dto)
  5339. {
  5340. try
  5341. {
  5342. var TypeName = Request.Headers["TypeName"].ToString();
  5343. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5344. string filePath = "";
  5345. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5346. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5347. int id = 0;
  5348. if (TypeName == "A")
  5349. {
  5350. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5351. // 删除该文件
  5352. System.IO.File.Delete(filePath);
  5353. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5354. .Where(a => a.Id == dto.Id)
  5355. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5356. .ExecuteCommandAsync();
  5357. }
  5358. else if (TypeName == "B")
  5359. {
  5360. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5361. // 删除该文件
  5362. System.IO.File.Delete(filePath);
  5363. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5364. if (info != null)
  5365. {
  5366. string[] files = Array.Empty<string>();
  5367. if (!string.IsNullOrEmpty(info.Attachment))
  5368. {
  5369. try
  5370. {
  5371. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5372. }
  5373. catch (Exception)
  5374. {
  5375. files = new List<string>() { info.Attachment }.ToArray();
  5376. }
  5377. }
  5378. if (files.Length > 0)
  5379. {
  5380. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5381. string filePath2 = string.Empty;
  5382. if (files1.Length > 0)
  5383. {
  5384. filePath2 = JsonConvert.SerializeObject(files1);
  5385. }
  5386. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5387. .Where(a => a.Id == dto.Id)
  5388. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5389. .ExecuteCommandAsync();
  5390. }
  5391. }
  5392. }
  5393. if (id != 0)
  5394. {
  5395. return Ok(JsonView(true, "成功!"));
  5396. }
  5397. else
  5398. {
  5399. return Ok(JsonView(false, "失败!"));
  5400. }
  5401. }
  5402. catch (Exception ex)
  5403. {
  5404. return Ok(JsonView(false, "程序错误!"));
  5405. throw;
  5406. }
  5407. }
  5408. /// <summary>
  5409. /// 文件上传多个文件 可以带参数
  5410. /// </summary>
  5411. /// <param name="files"></param>
  5412. /// <returns></returns>
  5413. [HttpPost]
  5414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5415. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5416. {
  5417. try
  5418. {
  5419. var TypeName = Request.Headers["TypeName"].ToString();
  5420. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5421. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5422. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5423. var filePahts = new List<string>();
  5424. foreach (var file in files)
  5425. {
  5426. //文件名称
  5427. string projectFileName = file.FileName;
  5428. //上传的文件的路径
  5429. string filePath = $"{fileDir}/{projectFileName}";
  5430. if (TypeName == "A")//A代表团组增减款项
  5431. {
  5432. if (!Directory.Exists(fileDir))
  5433. {
  5434. Directory.CreateDirectory(fileDir);
  5435. }
  5436. //上传的文件的路径
  5437. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5438. }
  5439. else if (TypeName == "B")//B代表商邀相关文件
  5440. {
  5441. if (!Directory.Exists(fileDir))
  5442. {
  5443. Directory.CreateDirectory(fileDir);
  5444. }
  5445. //上传的文件的路径
  5446. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5447. }
  5448. using (FileStream fs = System.IO.File.Create(filePath))
  5449. {
  5450. file.CopyTo(fs);
  5451. fs.Flush();
  5452. }
  5453. filePahts.Add(projectFileName);
  5454. }
  5455. return Ok(JsonView(true, "上传成功!", filePahts));
  5456. }
  5457. catch (Exception ex)
  5458. {
  5459. return Ok(JsonView(false, ex.Message));
  5460. }
  5461. }
  5462. #endregion
  5463. #region 商邀费用录入
  5464. /// <summary>
  5465. /// 根据团组Id查询商邀费用列表
  5466. /// </summary>
  5467. /// <param name="dto"></param>
  5468. /// <returns></returns>
  5469. [HttpPost]
  5470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5471. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5472. {
  5473. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5474. if (groupData.Code != 0)
  5475. {
  5476. return Ok(JsonView(false, groupData.Msg));
  5477. }
  5478. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5479. }
  5480. /// <summary>
  5481. /// 商邀费用列表
  5482. /// 下载文件
  5483. /// </summary>
  5484. /// <param name="id"></param>
  5485. /// <returns></returns>
  5486. [HttpGet("{id}")]
  5487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5488. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5489. {
  5490. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5491. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5492. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5493. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5494. var filePaths = new List<string>();
  5495. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5496. try
  5497. {
  5498. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5499. }
  5500. catch (Exception ex)
  5501. {
  5502. filePaths.Add(info.Attachment);
  5503. }
  5504. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5505. for (int i = 0; i < filePaths.Count; i++)
  5506. {
  5507. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5508. }
  5509. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5510. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5511. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5512. {
  5513. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5514. {
  5515. foreach (string filePath in filePaths)
  5516. {
  5517. if (System.IO.File.Exists(filePath))
  5518. {
  5519. // 获取文件名
  5520. string fileName = Path.GetFileName(filePath);
  5521. // 将文件添加到ZIP归档中
  5522. zipArchive.CreateEntryFromFile(filePath, fileName);
  5523. }
  5524. }
  5525. }
  5526. }
  5527. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5528. }
  5529. /// <summary>
  5530. /// 商邀费用 Info Page 基础数据源
  5531. /// </summary>
  5532. /// <returns></returns>
  5533. [HttpPost]
  5534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5535. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5536. {
  5537. try
  5538. {
  5539. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5540. if (groupData.Code != 0)
  5541. {
  5542. return Ok(JsonView(false, groupData.Msg));
  5543. }
  5544. return Ok(JsonView(true, "操作成功", groupData.Data));
  5545. }
  5546. catch (Exception ex)
  5547. {
  5548. return Ok(JsonView(false, ex.Message));
  5549. throw;
  5550. }
  5551. }
  5552. /// <summary>
  5553. /// 根据商邀费用ID查询C表和商邀费用数据
  5554. /// </summary>
  5555. /// <param name="dto"></param>
  5556. /// <returns></returns>
  5557. [HttpPost]
  5558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5559. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5560. {
  5561. try
  5562. {
  5563. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5564. if (groupData.Code != 0)
  5565. {
  5566. return Ok(JsonView(false, groupData.Msg));
  5567. }
  5568. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5569. }
  5570. catch (Exception ex)
  5571. {
  5572. return Ok(JsonView(false, ex.Message));
  5573. throw;
  5574. }
  5575. }
  5576. /// <summary>
  5577. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5578. /// </summary>
  5579. /// <param name="dto"></param>
  5580. /// <returns></returns>
  5581. [HttpPost]
  5582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5583. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5584. {
  5585. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5586. if (groupData.Code != 0)
  5587. {
  5588. return Ok(JsonView(false, groupData.Msg));
  5589. }
  5590. #region 应用推送
  5591. try
  5592. {
  5593. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5594. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5595. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5596. //2024-10-21 新增LZ UID
  5597. var userIds = new List<int>() { 21 };
  5598. string title = $"系统通知";
  5599. string content = "";
  5600. var diId = dto.DiId;
  5601. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5602. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5603. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5604. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5605. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5606. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5607. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5608. }
  5609. catch (Exception ex)
  5610. {
  5611. }
  5612. #endregion
  5613. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5614. }
  5615. /// <summary>
  5616. /// 商邀删除
  5617. /// </summary>
  5618. /// <param name="dto"></param>
  5619. /// <returns></returns>
  5620. [HttpPost]
  5621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5622. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5623. {
  5624. try
  5625. {
  5626. _sqlSugar.BeginTran();
  5627. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5628. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5629. {
  5630. IsDel = 1,
  5631. DeleteUserId = dto.DeleteUserId,
  5632. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5633. })
  5634. .Where(it => it.Id == dto.Id)
  5635. .ExecuteCommand();
  5636. if (res1 > 0)
  5637. {
  5638. int _diId = 0;
  5639. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5640. if (_ioaInfo != null)
  5641. {
  5642. _diId = _ioaInfo.DiId;
  5643. }
  5644. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5645. .SetColumns(a => new Grp_CreditCardPayment()
  5646. {
  5647. IsDel = 1,
  5648. DeleteUserId = dto.DeleteUserId,
  5649. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5650. })
  5651. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5652. .ExecuteCommand();
  5653. if (res2 > 0)
  5654. {
  5655. _sqlSugar.CommitTran();
  5656. return Ok(JsonView(true, "删除成功!"));
  5657. }
  5658. }
  5659. _sqlSugar.RollbackTran();
  5660. return Ok(JsonView(false, "删除失败"));
  5661. }
  5662. catch (Exception ex)
  5663. {
  5664. _sqlSugar.RollbackTran();
  5665. return Ok(JsonView(false, ex.Message));
  5666. }
  5667. }
  5668. #endregion
  5669. #region 票据上传
  5670. /// <summary>
  5671. /// 团组模块文件上传
  5672. /// </summary>
  5673. /// <param name="dto"></param>
  5674. /// <returns></returns>
  5675. [HttpPost]
  5676. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5677. {
  5678. var jw = JsonView(false);
  5679. long M = 1024 * 1024;
  5680. if (dto.Files == null || dto.Files.Count == 0)
  5681. {
  5682. jw.Msg = "无文件信息!";
  5683. return Ok(jw);
  5684. }
  5685. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5686. {
  5687. jw.Msg = "文件大小超过20M!";
  5688. return Ok(jw);
  5689. }
  5690. //var nameSp = dto.File.FileName.Split(".");
  5691. //if (nameSp.Length < 2)
  5692. //{
  5693. // jw.Msg = "拓展名称有误!";
  5694. // return Ok(jw);
  5695. //}
  5696. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5697. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5698. //{
  5699. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5700. // return Ok(jw);
  5701. //}
  5702. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5703. if (Ctable == null)
  5704. {
  5705. jw.Msg = "Ctable指向有误!";
  5706. return Ok(jw);
  5707. }
  5708. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5709. if (groupInfo == null)
  5710. {
  5711. jw.Msg = "团组信息不存在!";
  5712. return Ok(jw);
  5713. }
  5714. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5715. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5716. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5717. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5718. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5719. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5720. try
  5721. {
  5722. if (!Directory.Exists(fileBase))
  5723. {
  5724. Directory.CreateDirectory(fileBase);
  5725. }
  5726. var saveArr = new List<Grp_GroupModelFile>();
  5727. foreach (var fileStream in dto.Files)
  5728. {
  5729. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5730. var file = new Grp_GroupModelFile()
  5731. {
  5732. Cid = dto.Cid,
  5733. CreateTime = DateTime.Now,
  5734. CreateUserId = dto.Userid,
  5735. Ctable = dto.Ctable,
  5736. Diid = dto.Diid,
  5737. IsDel = 0,
  5738. FilePath = saveFilePath,
  5739. FileName = fileStream.FileName
  5740. };
  5741. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5742. {
  5743. fileStream.CopyTo(fs);
  5744. fs.Flush();
  5745. }
  5746. saveArr.Add(file);
  5747. }
  5748. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5749. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5750. jw = JsonView(true, "保存成功!", new
  5751. {
  5752. count = addResult,
  5753. filesName = saveArr.Select(x => x.FileName)
  5754. });
  5755. }
  5756. catch (Exception ex)
  5757. {
  5758. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5759. {
  5760. count = 0,
  5761. filesName = Array.Empty<string>(),
  5762. });
  5763. }
  5764. return Ok(jw);
  5765. }
  5766. /// <summary>
  5767. /// 查询各模块已保存文件
  5768. /// </summary>
  5769. /// <param name="dto"></param>
  5770. /// <returns></returns>
  5771. [HttpPost]
  5772. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5773. {
  5774. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5775. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5776. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5777. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5778. {
  5779. expression = Expressionable.Create<Grp_GroupModelFile>()
  5780. .And(x => visaIds.Contains(x.CreateUserId));
  5781. }
  5782. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5783. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5784. .Where(expression.ToExpression())
  5785. .ToList();
  5786. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5787. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5788. {
  5789. x.FileName,
  5790. x.Id,
  5791. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5792. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5793. })));
  5794. }
  5795. /// <summary>
  5796. /// 下载该团组下的所有文件
  5797. /// </summary>
  5798. /// <param name="dto"></param>
  5799. /// <returns></returns>
  5800. [HttpPost]
  5801. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5802. {
  5803. var jw = JsonView(false);
  5804. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5805. if (groupInfo == null)
  5806. {
  5807. jw.Msg = "团组信息不存在!";
  5808. return Ok(jw);
  5809. }
  5810. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5811. var isModule = Convert.ToBoolean(dto.isModule);
  5812. var Zips = new Dictionary<string, Stream>();
  5813. var io = new IOOperatorHelper();
  5814. if (isModule)
  5815. {
  5816. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5817. foreach (var moduleArr in moduleGroup)
  5818. {
  5819. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5820. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5821. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5822. var chiZips = new Dictionary<string, Stream>();
  5823. foreach (var item in moduleArr)
  5824. {
  5825. if (System.IO.File.Exists(item.FilePath))
  5826. {
  5827. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5828. {
  5829. byte[] bytes = new byte[fileStream.Length];
  5830. fileStream.Read(bytes, 0, bytes.Length);
  5831. fileStream.Close();
  5832. Stream stream = new MemoryStream(bytes);
  5833. chiZips.Add(item.FileName, stream);
  5834. }
  5835. }
  5836. }
  5837. if (chiZips.Count > 0)
  5838. {
  5839. var byts = io.ConvertZipStream(chiZips);
  5840. Stream stream = new MemoryStream(byts);
  5841. Zips.Add(key.Name + "_.zip", stream);
  5842. }
  5843. }
  5844. }
  5845. else
  5846. {
  5847. foreach (var item in dbQuery)
  5848. {
  5849. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5850. {
  5851. byte[] bytes = new byte[fileStream.Length];
  5852. fileStream.Read(bytes, 0, bytes.Length);
  5853. fileStream.Close();
  5854. var stream = new MemoryStream(bytes);
  5855. while (Zips.ContainsKey(item.FileName))
  5856. {
  5857. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5858. }
  5859. Zips.Add(item.FileName, stream);
  5860. }
  5861. }
  5862. }
  5863. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5864. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5865. if (Zips.Count > 0)
  5866. {
  5867. var byts = io.ConvertZipStream(Zips);
  5868. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5869. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5870. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5871. }
  5872. else
  5873. {
  5874. jw.Msg = "暂无生成文件!";
  5875. }
  5876. return Ok(jw);
  5877. }
  5878. /// <summary>
  5879. /// 下载该团组下此模块的所有文件
  5880. /// </summary>
  5881. /// <param name="dto"></param>
  5882. /// <returns></returns>
  5883. [HttpPost]
  5884. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5885. {
  5886. var jw = JsonView(false);
  5887. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5888. if (groupInfo == null)
  5889. {
  5890. jw.Msg = "团组信息不存在!";
  5891. return Ok(jw);
  5892. }
  5893. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5894. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5895. && x.IsDel == 0);
  5896. if (key == null)
  5897. {
  5898. jw.Msg = "Ctable指向错误!";
  5899. return Ok(jw);
  5900. }
  5901. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5902. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5903. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5904. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5905. var io = new IOOperatorHelper();
  5906. var Zips = new Dictionary<string, Stream>();
  5907. foreach (var item in dbQuery)
  5908. {
  5909. if (System.IO.File.Exists(item.FilePath))
  5910. {
  5911. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5912. {
  5913. byte[] bytes = new byte[fileStream.Length];
  5914. fileStream.Read(bytes, 0, bytes.Length);
  5915. fileStream.Close();
  5916. var stream = new MemoryStream(bytes);
  5917. while (Zips.ContainsKey(item.FileName))
  5918. {
  5919. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5920. }
  5921. Zips.Add(item.FileName, stream);
  5922. }
  5923. }
  5924. }
  5925. if (Zips.Count > 0)
  5926. {
  5927. var byts = io.ConvertZipStream(Zips);
  5928. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5929. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5930. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5931. }
  5932. else
  5933. {
  5934. jw.Msg = "暂无生成文件!";
  5935. }
  5936. return Ok(jw);
  5937. }
  5938. /// <summary>
  5939. /// 删除该团组下的指定文件
  5940. /// </summary>
  5941. /// <param name="dto"></param>
  5942. /// <returns></returns>
  5943. [HttpPost]
  5944. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5945. {
  5946. var jw = JsonView(false);
  5947. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5948. if (sing == null)
  5949. {
  5950. jw.Msg = "暂无";
  5951. return Ok(jw);
  5952. }
  5953. if (System.IO.File.Exists(sing.FilePath))
  5954. {
  5955. try
  5956. {
  5957. System.IO.File.Delete(sing.FilePath);
  5958. }
  5959. catch (Exception ex)
  5960. {
  5961. jw.Msg = "删除失败!" + ex.Message;
  5962. return Ok(jw);
  5963. }
  5964. }
  5965. sing.IsDel = 1;
  5966. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5967. sing.DeleteUserId = dto.UserId;
  5968. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5969. jw = JsonView(true, "删除成功!");
  5970. return Ok(jw);
  5971. }
  5972. #endregion
  5973. #region 共享文件上传
  5974. /// <summary>
  5975. /// 共享文件数据初始化
  5976. /// </summary>
  5977. /// <returns></returns>
  5978. [HttpGet]
  5979. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5980. {
  5981. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5982. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5983. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5984. .Select(x => x.Id)
  5985. .ToList()
  5986. .Contains(userid);
  5987. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5988. .Where(x => x.STid == 111 && x.IsDel == 0)
  5989. .Select(x => new
  5990. {
  5991. x.Name,
  5992. x.Id,
  5993. }).ToList();
  5994. if (isMarketingDepartment)
  5995. {
  5996. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5997. }
  5998. if (portType == 1)
  5999. {
  6000. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  6001. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  6002. .Where(x => x.IsDel == 0)
  6003. .OrderByDescending(x => x.VisitDate)
  6004. .Select(x => new
  6005. {
  6006. x.TeamName,
  6007. x.Id,
  6008. x.CityId,
  6009. })
  6010. .ToList()
  6011. .Select(x =>
  6012. {
  6013. var provinceId = x.CityId;
  6014. var isDefualtVal = true;
  6015. if (provinceId > 0)
  6016. {
  6017. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  6018. if (parentId != null)
  6019. {
  6020. isDefualtVal = false;
  6021. provinceId = (int)parentId;
  6022. }
  6023. }
  6024. if (isDefualtVal)
  6025. {
  6026. provinceId = 122; //默认四川
  6027. }
  6028. return new
  6029. {
  6030. x.TeamName,
  6031. x.Id,
  6032. provinceId,
  6033. };
  6034. })
  6035. .ToList();
  6036. return Ok(JsonView(true, "SUCCESS!", new
  6037. {
  6038. dropDownType,
  6039. dropDownGroupList,
  6040. isMarketingDepartment
  6041. }));
  6042. }
  6043. else if (portType == 2 || portType == 3)
  6044. {
  6045. return Ok(JsonView(true, "SUCCESS!", new
  6046. {
  6047. dropDownType,
  6048. isMarketingDepartment
  6049. }));
  6050. }
  6051. else
  6052. {
  6053. return Ok(JsonView(false, "portType有误!"));
  6054. }
  6055. }
  6056. /// <summary>
  6057. /// 共享文件上传
  6058. /// </summary>
  6059. /// <param name="dto"></param>
  6060. /// <returns></returns>
  6061. [HttpPost]
  6062. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  6063. {
  6064. var isGroup = new List<int> { 1412 };
  6065. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  6066. {
  6067. return Ok(JsonView(false, "该文件需要关联团组!"));
  6068. }
  6069. if (dto.Files == null || dto.Files.Count == 0)
  6070. {
  6071. return Ok(JsonView(false, "无文件信息!"));
  6072. }
  6073. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  6074. {
  6075. return Ok(JsonView(false, "文件大小超过20M!"));
  6076. }
  6077. if (dto.Userid < 1)
  6078. {
  6079. return Ok(JsonView(false, "请传入有效的Userid!"));
  6080. }
  6081. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  6082. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  6083. .Select((u, j) => new
  6084. {
  6085. u.CnName,
  6086. UserId = u.Id,
  6087. j.JobName,
  6088. })
  6089. .First();
  6090. if (jobInfo == null)
  6091. {
  6092. return Ok(JsonView(false, "请传入有效的Userid!"));
  6093. }
  6094. var commonFileExtensions = new List<string>
  6095. {
  6096. // 文本文件
  6097. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  6098. // 图片文件
  6099. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  6100. // 视频文件
  6101. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  6102. // 音频文件
  6103. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  6104. // 压缩文件
  6105. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  6106. // 数据文件
  6107. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  6108. };
  6109. try
  6110. {
  6111. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  6112. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  6113. commonFileExtensions.AddRange(settingExtend);
  6114. }
  6115. catch (Exception)
  6116. { }
  6117. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  6118. if (setdata == null)
  6119. {
  6120. return Ok(JsonView(false, "请传入有效的FileType!"));
  6121. }
  6122. var insertList = new List<Grp_GroupShareFile>();
  6123. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  6124. if (!Directory.Exists(winPath))
  6125. {
  6126. Directory.CreateDirectory(winPath);
  6127. }
  6128. foreach (var item in dto.Files)
  6129. {
  6130. var houzui = Path.GetExtension(item.FileName);
  6131. if (!commonFileExtensions.Contains(houzui))
  6132. {
  6133. return Ok(JsonView(false, "未知后缀名称!"));
  6134. }
  6135. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  6136. var saveFilePath = winPath + fileName;
  6137. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6138. {
  6139. item.CopyTo(fs);
  6140. fs.Flush();
  6141. }
  6142. var fileDetail = new Grp_GroupShareFile()
  6143. {
  6144. CreateUserId = dto.Userid,
  6145. CreateTime = DateTime.Now,
  6146. UploadJob = jobInfo.JobName,
  6147. FileName = fileName,
  6148. FileType = dto.FileType,
  6149. Diid = dto.Diid,
  6150. FilePath = winPath + fileName,
  6151. };
  6152. insertList.Add(fileDetail);
  6153. }
  6154. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  6155. return Ok(JsonView(true, "保存成功!"));
  6156. }
  6157. /// <summary>
  6158. /// 查询共享文件列表
  6159. /// </summary>
  6160. /// <param name="dto"></param>
  6161. /// <returns></returns>
  6162. [HttpPost]
  6163. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  6164. {
  6165. var isGroup = new List<int> { 1412 };
  6166. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  6167. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  6168. .And(x => x.Diid == dto.Diid)
  6169. .And(x => x.FileType == dto.FileType)
  6170. .And(x => x.IsDel == 0)
  6171. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  6172. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  6173. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  6174. int totalCount = 0;
  6175. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  6176. .Where(queryExpression.ToExpression())
  6177. .OrderBy(x => x.UploadJob)
  6178. .Select(x => new
  6179. {
  6180. x.Id,
  6181. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  6182. x.FileName,
  6183. x.FileType,
  6184. x.CreateTime,
  6185. })
  6186. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  6187. return Ok(JsonView(true, "SUCCESS!", new
  6188. {
  6189. FileList = dbQuery,
  6190. dto.PageSize,
  6191. dto.PageIndex,
  6192. totalCount
  6193. }));
  6194. }
  6195. /// <summary>
  6196. /// 删除共享文件模块下的指定文件
  6197. /// </summary>
  6198. /// <param name="dto"></param>
  6199. /// <returns></returns>
  6200. [HttpPost]
  6201. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  6202. {
  6203. var jw = JsonView(false);
  6204. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6205. if (sing == null)
  6206. {
  6207. jw.Msg = "暂无文件信息!";
  6208. return Ok(jw);
  6209. }
  6210. if (sing.CreateUserId != dto.UserId)
  6211. {
  6212. jw.Msg = "只能删除自己上传的文件!";
  6213. return Ok(jw);
  6214. }
  6215. if (System.IO.File.Exists(sing.FilePath))
  6216. {
  6217. try
  6218. {
  6219. System.IO.File.Delete(sing.FilePath);
  6220. }
  6221. catch (Exception ex)
  6222. {
  6223. jw.Msg = "删除失败!" + ex.Message;
  6224. return Ok(jw);
  6225. }
  6226. }
  6227. sing.IsDel = 1;
  6228. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6229. sing.DeleteUserId = dto.UserId;
  6230. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6231. jw = JsonView(true, "删除成功!");
  6232. return Ok(jw);
  6233. }
  6234. #endregion
  6235. #region 团组英文资料
  6236. /// <summary>
  6237. /// 查询团组英文所有资料
  6238. /// </summary>
  6239. /// <param name="dto"></param>
  6240. /// <returns></returns>
  6241. [HttpPost]
  6242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6243. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6244. {
  6245. try
  6246. {
  6247. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6248. if (groupData.Code != 0)
  6249. {
  6250. return Ok(JsonView(false, groupData.Msg));
  6251. }
  6252. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6253. }
  6254. catch (Exception ex)
  6255. {
  6256. return Ok(JsonView(false, ex.Message));
  6257. throw;
  6258. }
  6259. }
  6260. /// <summary>
  6261. /// 团组英文资料操作(Status:1.新增,2.修改)
  6262. /// </summary>
  6263. /// <param name="dto"></param>
  6264. /// <returns></returns>
  6265. [HttpPost]
  6266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6267. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6268. {
  6269. try
  6270. {
  6271. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6272. if (groupData.Code != 0)
  6273. {
  6274. return Ok(JsonView(false, groupData.Msg));
  6275. }
  6276. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6277. }
  6278. catch (Exception ex)
  6279. {
  6280. return Ok(JsonView(false, ex.Message));
  6281. throw;
  6282. }
  6283. }
  6284. /// <summary>
  6285. /// 团组英文资料Id查询数据
  6286. /// </summary>
  6287. /// <param name="dto"></param>
  6288. /// <returns></returns>
  6289. [HttpPost]
  6290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6291. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6292. {
  6293. try
  6294. {
  6295. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6296. if (_DelegationEnData != null)
  6297. {
  6298. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6299. }
  6300. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6301. }
  6302. catch (Exception ex)
  6303. {
  6304. return Ok(JsonView(false, "程序错误!"));
  6305. throw;
  6306. }
  6307. }
  6308. /// <summary>
  6309. /// 团组英文资料删除
  6310. /// </summary>
  6311. /// <param name="dto"></param>
  6312. /// <returns></returns>
  6313. [HttpPost]
  6314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6315. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6316. {
  6317. try
  6318. {
  6319. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6320. if (!res)
  6321. {
  6322. return Ok(JsonView(false, "删除失败"));
  6323. }
  6324. return Ok(JsonView(true, "删除成功!"));
  6325. }
  6326. catch (Exception ex)
  6327. {
  6328. return Ok(JsonView(false, ex.Message));
  6329. throw;
  6330. }
  6331. }
  6332. #endregion
  6333. #region 导出邀请函
  6334. /// <summary>
  6335. /// 导出邀请函页面初始化
  6336. /// </summary>
  6337. /// <param name="dto"></param>
  6338. /// <returns></returns>
  6339. [HttpPost]
  6340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6341. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6342. {
  6343. try
  6344. {
  6345. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6346. var crm_Deles = new List<Crm_DeleClient>();
  6347. if (dto.DiId == 0)
  6348. {
  6349. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6350. }
  6351. else
  6352. {
  6353. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6354. }
  6355. return Ok(JsonView(true, "查询成功!", new
  6356. {
  6357. deleClient = crm_Deles,
  6358. delegations = grp_Delegations
  6359. }));
  6360. }
  6361. catch (Exception ex)
  6362. {
  6363. return Ok(JsonView(false, "程序错误!"));
  6364. throw;
  6365. }
  6366. }
  6367. /// <summary>
  6368. /// 导出邀请函
  6369. /// </summary>
  6370. /// <param name="dto"></param>
  6371. /// <returns></returns>
  6372. [HttpPost]
  6373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6374. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6375. {
  6376. #region 参数验证
  6377. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6378. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6379. #endregion
  6380. try
  6381. {
  6382. var transDic = new Dictionary<string, string>();
  6383. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6384. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6385. From Grp_TourClientList tcl
  6386. Left Join
  6387. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6388. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6389. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6390. From Crm_DeleClient dc
  6391. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6392. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6393. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6394. Where dc.IsDel = 0) temp
  6395. On temp.DcId =tcl.ClientId
  6396. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6397. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6398. var texts = new List<string>();
  6399. if (datas.Count != 0)
  6400. {
  6401. foreach (TourClientListDetailsView item in datas)
  6402. {
  6403. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6404. {
  6405. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6406. }
  6407. else
  6408. {
  6409. string name = item.LastName + item.FirstName;
  6410. texts.Add(name);
  6411. }
  6412. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6413. {
  6414. if (!transDic.ContainsKey(item.Job))
  6415. {
  6416. texts.Add(item.Job);
  6417. }
  6418. }
  6419. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6420. {
  6421. texts.Add(item.CompanyFullName);
  6422. }
  6423. }
  6424. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6425. if (transData.Count > 0)
  6426. {
  6427. foreach (TranslateResult item in transData)
  6428. {
  6429. if (!transDic.ContainsKey(item.Query))
  6430. {
  6431. transDic.Add(item.Query, item.Translation);
  6432. }
  6433. }
  6434. }
  6435. var list = new List<GuestList>();
  6436. foreach (var dele in datas)
  6437. {
  6438. var guestList = new GuestList();
  6439. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6440. {
  6441. guestList.Name = dele.Pinyin;
  6442. }
  6443. else
  6444. {
  6445. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6446. guestList.Name = Name;
  6447. }
  6448. if (dele.Sex == 0)
  6449. {
  6450. guestList.Sex = "Male";
  6451. }
  6452. else if (dele.Sex == 1)
  6453. {
  6454. guestList.Sex = "Female";
  6455. }
  6456. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6457. if (!string.IsNullOrEmpty(dele.Job))
  6458. {
  6459. guestList.Job = dele.Job;
  6460. }
  6461. list.Add(guestList);
  6462. }
  6463. //载入模板
  6464. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6465. var builder = new DocumentBuilder(doc);
  6466. //获取word里所有表格
  6467. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6468. //获取所填表格的序数
  6469. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6470. var rowStart = tableOne.Rows[0]; //获取第1行
  6471. //循环赋值
  6472. for (int i = 0; i < list.Count; i++)
  6473. {
  6474. builder.MoveToCell(0, i + 1, 0, 0);
  6475. builder.Write(list[i].Name.ToString());
  6476. builder.MoveToCell(0, i + 1, 1, 0);
  6477. builder.Write(list[i].Sex.ToString());
  6478. builder.MoveToCell(0, i + 1, 2, 0);
  6479. builder.Write(list[i].DOB.ToString());
  6480. builder.MoveToCell(0, i + 1, 3, 0);
  6481. builder.Write(list[i].Job.ToString());
  6482. }
  6483. //删除多余行
  6484. while (tableOne.Rows.Count > list.Count + 1)
  6485. {
  6486. tableOne.Rows.RemoveAt(list.Count + 1);
  6487. }
  6488. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6489. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6490. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6491. doc.Save(filePath);
  6492. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6493. return Ok(JsonView(true, "操作成功!", Url));
  6494. }
  6495. else
  6496. {
  6497. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6498. }
  6499. }
  6500. catch (Exception ex)
  6501. {
  6502. return Ok(JsonView(false, ex.Message));
  6503. throw;
  6504. }
  6505. }
  6506. #endregion
  6507. #region 团组经理模块 出入境费用
  6508. /// <summary>
  6509. /// 团组模块 - 出入境费用 - 省份基础数据源
  6510. /// </summary>
  6511. /// <returns></returns>
  6512. [HttpGet]
  6513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6514. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6515. {
  6516. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6517. }
  6518. /// <summary>
  6519. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6520. /// </summary>
  6521. /// <param name="dto"></param>
  6522. /// <returns></returns>
  6523. [HttpPost]
  6524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6525. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6526. {
  6527. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6528. var groupNamFirst = groupNameData.FirstOrDefault();
  6529. //SetDataInfoView
  6530. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6531. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6532. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6533. //验证城市归属并给默认值
  6534. int provinceId = 122;
  6535. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6536. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6537. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6538. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6539. return Ok(JsonView(true, "查询成功!", new
  6540. {
  6541. GroupNameData = groupNameData,
  6542. CurrencyData = _CurrencyData,
  6543. WordTypeData = wordTypeData,
  6544. ExcelTypeData = excelTypeData,
  6545. CurrencyInit = _currencyInfos,
  6546. ViewPermissionData = viewPermissionData
  6547. }));
  6548. }
  6549. /// <summary>
  6550. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6551. /// </summary>
  6552. /// <returns></returns>
  6553. [HttpGet("{provinceId}")]
  6554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6555. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6556. {
  6557. //验证城市归属并给默认值
  6558. if (provinceId < 1) provinceId = 122;
  6559. /*
  6560. * 122 四川
  6561. * 108 贵州
  6562. * 103 重庆
  6563. * 132 云南
  6564. */
  6565. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6566. return Ok(JsonView(true, "查询成功!", new
  6567. {
  6568. WordTypeData = wordTypeData,
  6569. ExcelTypeData = excelTypeData,
  6570. }));
  6571. }
  6572. /// <summary>
  6573. /// 团组模块 - 出入境费用
  6574. /// 实时汇率 tips
  6575. /// 签证费用 tips
  6576. /// 机票费用 tips
  6577. /// </summary>
  6578. /// <returns></returns>
  6579. [HttpPost]
  6580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6581. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6582. {
  6583. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6584. //默认币种显示
  6585. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6586. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6587. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6588. return Ok(JsonView(true, "查询成功!", new
  6589. {
  6590. //GroupNameData = groupNameData.Data,
  6591. visaData = visaData.Data,
  6592. airData,
  6593. reteInfos
  6594. }));
  6595. }
  6596. /// <summary>
  6597. /// 团组模块 - 出入境费用 - Info
  6598. /// </summary>
  6599. /// <param name="dto"></param>
  6600. /// <returns></returns>
  6601. [HttpPost]
  6602. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6604. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6605. {
  6606. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6607. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6608. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6609. }
  6610. /// <summary>
  6611. /// 团组模块 - 出入境费用 - 设置view权限
  6612. /// </summary>
  6613. /// <returns></returns>
  6614. [HttpPost]
  6615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6616. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6617. {
  6618. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6619. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6620. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6621. var permissions = new List<Grp_EnterExitCostPermission>();
  6622. foreach (var userId in dto.UserIds)
  6623. {
  6624. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6625. }
  6626. if (permissions.Any())
  6627. {
  6628. _sqlSugar.BeginTran();
  6629. try
  6630. {
  6631. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6632. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6633. if (result < 1)
  6634. {
  6635. _sqlSugar.RollbackTran();
  6636. return Ok(JsonView(false));
  6637. }
  6638. }
  6639. catch (Exception ex)
  6640. {
  6641. _sqlSugar.RollbackTran();
  6642. return Ok(JsonView(false, ex.Message));
  6643. }
  6644. _sqlSugar.CommitTran();
  6645. return Ok(JsonView(true));
  6646. }
  6647. return Ok(JsonView(false));
  6648. }
  6649. /// <summary>
  6650. /// 团组模块 - 出入境费用 - Add And Update
  6651. /// </summary>
  6652. /// <returns></returns>
  6653. [HttpPost]
  6654. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6656. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6657. {
  6658. try
  6659. {
  6660. var rateRecords = new List<RateRecordInfo>();
  6661. #region 汇率保存前存储
  6662. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  6663. if (info != null)
  6664. {
  6665. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  6666. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  6667. {
  6668. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  6669. {
  6670. CurrencyCode = x.CurrencyCode,
  6671. CurrencyName = x.CurrencyName,
  6672. UpdatePreRate = x.Rate,
  6673. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  6674. }).ToList();
  6675. }
  6676. else
  6677. {
  6678. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6679. {
  6680. CurrencyCode = x.CurrencyCode,
  6681. CurrencyName = x.CurrencyName,
  6682. UpdatePreRate = 0.00M,
  6683. UpdateBreRate = x.Rate
  6684. }).ToList();
  6685. }
  6686. }
  6687. else
  6688. {
  6689. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6690. {
  6691. CurrencyCode = x.CurrencyCode,
  6692. CurrencyName = x.CurrencyName,
  6693. UpdatePreRate = 0.00M,
  6694. UpdateBreRate = x.Rate
  6695. }).ToList();
  6696. }
  6697. #endregion
  6698. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6699. if (dto.DayOtherPriceData.Any())
  6700. {
  6701. var inserList = dto.DayOtherPriceData
  6702. .Where(x => x.Id == 0)
  6703. .Select(x => new Grp_DayOtherPrice
  6704. {
  6705. Cost = x.Cost,
  6706. Id = x.Id,
  6707. CreateTime = DateTime.Now,
  6708. CreateUserId = dto.UserId,
  6709. Currency = x.Currency,
  6710. Diid = x.DiId,
  6711. Index = x.Index,
  6712. IsDel = 0,
  6713. SetDataId = x.SetDataId,
  6714. SubTotal = x.SubTotal,
  6715. Remark = x.Remark
  6716. })
  6717. .ToList();
  6718. var updateList = dto.DayOtherPriceData
  6719. .Where(x => x.Id != 0)
  6720. .Select(x => new Grp_DayOtherPrice
  6721. {
  6722. Cost = x.Cost,
  6723. Id = x.Id,
  6724. CreateTime = DateTime.Now,
  6725. CreateUserId = dto.UserId,
  6726. Currency = x.Currency,
  6727. Diid = x.DiId,
  6728. Index = x.Index,
  6729. IsDel = 0,
  6730. SetDataId = x.SetDataId,
  6731. SubTotal = x.SubTotal,
  6732. Remark = x.Remark
  6733. })
  6734. .ToList();
  6735. //添加
  6736. _sqlSugar.BeginTran();
  6737. if (inserList.Any())
  6738. {
  6739. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6740. }
  6741. if (updateList.Any())
  6742. {
  6743. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6744. }
  6745. _sqlSugar.CommitTran();
  6746. }
  6747. if (data.Code != 0)
  6748. {
  6749. return Ok(JsonView(false, data.Msg));
  6750. }
  6751. //生成默认文件pdf并且通知人员
  6752. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6753. {
  6754. DiId = dto.DiId,
  6755. ExportType = 1,
  6756. SubTypeId = 1005
  6757. }, "pdf");
  6758. //发送通知
  6759. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6760. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6761. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6762. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6763. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6764. //汇率信息记录
  6765. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6766. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  6767. //汇率验证、反推
  6768. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  6769. if (isSendMsg)
  6770. {
  6771. //消息推送
  6772. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  6773. }
  6774. #region //日志汇率记录
  6775. //按照已使用币种记录
  6776. if (checkCurrencys != null && checkCurrencys.Count > 0)
  6777. {
  6778. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  6779. //汇率记录中加入实时汇率
  6780. if (liveRates != null && liveRates.Count > 0)
  6781. {
  6782. foreach (var item in rateRecords)
  6783. {
  6784. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  6785. }
  6786. }
  6787. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  6788. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  6789. var logContent = new StringBuilder();
  6790. foreach (var item in rateRecords)
  6791. {
  6792. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  6793. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  6794. logContent.AppendLine(msg);
  6795. }
  6796. _eec_textLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】\r\n{logContent}", teamName, dto.DiId, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), logContent.ToString());
  6797. }
  6798. #endregion
  6799. return Ok(JsonView(true, data.Msg, data.Data));
  6800. }
  6801. catch (Exception ex)
  6802. {
  6803. return Ok(JsonView(false, ex.Message));
  6804. }
  6805. }
  6806. /// <summary>
  6807. /// 团组模块 - 出入境费用 - Confirm 费用
  6808. /// </summary>
  6809. /// <returns></returns>
  6810. [HttpPost]
  6811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6812. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6813. {
  6814. //TODO:测试完毕需把对应的用户ID更改
  6815. //1、数据表添加字段
  6816. //2、更改字段接口()
  6817. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6818. //3、确认成功 给财务发送消息
  6819. if (_view.Code == 200)
  6820. {
  6821. if (dto.Type == 1)
  6822. {
  6823. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6824. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6825. }
  6826. }
  6827. return Ok(_view);
  6828. }
  6829. /// <summary>
  6830. /// 团组模块 - 出入境费用 - File download
  6831. /// </summary>
  6832. /// <param name="dto"></param>
  6833. /// <returns></returns>
  6834. [HttpPost]
  6835. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6837. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6838. {
  6839. try
  6840. {
  6841. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6842. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6843. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6844. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6845. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6846. 3 团组成员名单 1 团组成员名单", ""));
  6847. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6848. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6849. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6850. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6851. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6852. //数据源
  6853. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6854. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6855. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6856. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6857. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6858. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6859. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6860. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6861. .Select((x, a, b) => new
  6862. {
  6863. x.Index,
  6864. itemName = a.Name,
  6865. CurrencyStr = b.Name,
  6866. x.Cost,
  6867. x.SubTotal,
  6868. x.Remark
  6869. })
  6870. .OrderBy((x) => x.Index)
  6871. .ToList(); //其他款项费用
  6872. var peiceItemCurrencys = new List<string>();
  6873. if (_DayAndCosts.Any())
  6874. {
  6875. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6876. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6877. }
  6878. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6879. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6880. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6881. {
  6882. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6883. }
  6884. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6885. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6886. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6887. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6888. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6889. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6890. .Select((tcl, dc, cc) => new ClientInfo
  6891. {
  6892. LastName = dc.LastName,
  6893. FirstName = dc.FirstName,
  6894. Sex = dc.Sex,
  6895. Birthday = dc.BirthDay,
  6896. Company = cc.CompanyFullName,
  6897. Job = dc.Job
  6898. })
  6899. .ToList();
  6900. foreach (var item in DeleClientList)
  6901. {
  6902. EncryptionProcessor.DecryptProperties(item);
  6903. }
  6904. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6905. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6906. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6907. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6908. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6909. if (dto.ExportType == 1) //明细表
  6910. {
  6911. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6912. {
  6913. //获取模板
  6914. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6915. //载入模板
  6916. var doc = new Document(tempPath);
  6917. var builder = new DocumentBuilder(doc);
  6918. var dic = new Dictionary<string, string>();
  6919. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6920. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6921. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6922. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6923. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6924. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6925. //境内费用(其他费用)
  6926. if (_EnterExitCosts.ChoiceOne == 1)
  6927. {
  6928. string row1_1 = "";
  6929. if (_EnterExitCosts.Visa > 0)
  6930. {
  6931. //insidePayTotal += _EnterExitCosts.Visa;
  6932. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  6933. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6934. //{
  6935. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6936. //}
  6937. }
  6938. string row1_2 = "";
  6939. if (_EnterExitCosts.YiMiao > 0)
  6940. {
  6941. //insidePayTotal += _EnterExitCosts.YiMiao;
  6942. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  6943. }
  6944. if (_EnterExitCosts.HeSuan > 0)
  6945. {
  6946. //insidePayTotal += _EnterExitCosts.HeSuan;
  6947. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  6948. }
  6949. if (_EnterExitCosts.Service > 0)
  6950. {
  6951. //insidePayTotal += _EnterExitCosts.Service;
  6952. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  6953. }
  6954. string row1_3 = "";
  6955. if (_EnterExitCosts.Safe > 0)
  6956. {
  6957. //insidePayTotal += _EnterExitCosts.Safe;
  6958. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  6959. }
  6960. if (_EnterExitCosts.Ticket > 0)
  6961. {
  6962. //insidePayTotal += _EnterExitCosts.Ticket;
  6963. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  6964. }
  6965. string row1 = "";
  6966. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6967. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6968. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6969. row1 += $"备注:{_EnterExitCosts.Remark}";
  6970. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6971. dic.Add("Row1Str", row1);
  6972. }
  6973. string airTotalStr = string.Empty,
  6974. airPriceStr = string.Empty;
  6975. //经济舱
  6976. if (_EnterExitCosts.SumJJC == 1)
  6977. {
  6978. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  6979. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  6980. }
  6981. //公务舱
  6982. if (_EnterExitCosts.SumGWC == 1)
  6983. {
  6984. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  6985. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  6986. }
  6987. //头等舱
  6988. if (_EnterExitCosts.SumTDC == 1)
  6989. {
  6990. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  6991. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  6992. }
  6993. //汇率描述
  6994. string rateStr = "";
  6995. if (peiceItemCurrencyInfos.Any())
  6996. {
  6997. rateStr = "\r\n汇率描述:";
  6998. foreach (var item in peiceItemCurrencyInfos)
  6999. {
  7000. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  7001. }
  7002. }
  7003. string twoItemRemark = "备注:";
  7004. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7005. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7006. dic.Add("AirTotalStr", airTotalStr);
  7007. dic.Add("AirPriceStr", airPriceStr);
  7008. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7009. dic.Add("TwoItemRemark", twoItemRemark);
  7010. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7011. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7012. int table1Row = 0,
  7013. table2Row = 0,
  7014. table3Row = 0,
  7015. table4Row = 0,
  7016. table5Row = 0;
  7017. //住宿费
  7018. if (_EnterExitCosts.ChoiceThree == 1)
  7019. {
  7020. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7021. table1Row = dac1.Count;
  7022. #region 填充word表格内容
  7023. for (int i = 0; i < dac1.Count; i++)
  7024. {
  7025. Grp_DayAndCost dac = dac1[i];
  7026. if (dac == null) continue;
  7027. builder.MoveToCell(0, i, 0, 0);
  7028. builder.Write("第" + dac.Days.ToString() + "晚:");
  7029. builder.MoveToCell(0, i, 1, 0);
  7030. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7031. //builder.Write(dac.Place == null ? "" : dac.Place);
  7032. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7033. builder.MoveToCell(0, i, 2, 0);
  7034. builder.Write("费用标准:");
  7035. string curr = "";
  7036. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7037. if (currData != null)
  7038. {
  7039. curr = currData.Name;
  7040. }
  7041. builder.MoveToCell(0, i, 3, 0);
  7042. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7043. builder.MoveToCell(0, i, 4, 0);
  7044. builder.Write("费用小计:");
  7045. builder.MoveToCell(0, i, 5, 0);
  7046. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7047. }
  7048. #endregion
  7049. }
  7050. else dic.Add("SubZS", "0.00");
  7051. //删除多余行
  7052. while (table1.Rows.Count > table1Row)
  7053. {
  7054. table1.Rows.RemoveAt(table1Row);
  7055. }
  7056. //伙食费
  7057. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7058. if (_EnterExitCosts.ChoiceFour == 1)
  7059. {
  7060. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7061. table2Row = dac2.Count;
  7062. #region 填充word表格内容
  7063. for (int i = 0; i < dac2.Count; i++)
  7064. {
  7065. Grp_DayAndCost dac = dac2[i];
  7066. if (dac == null) continue;
  7067. builder.MoveToCell(1, i, 0, 0);
  7068. builder.Write("第" + dac.Days.ToString() + "天:");
  7069. builder.MoveToCell(1, i, 1, 0);
  7070. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7071. builder.MoveToCell(1, i, 2, 0);
  7072. builder.Write("费用标准:");
  7073. string curr = "";
  7074. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7075. if (currData != null)
  7076. {
  7077. curr = currData.Name;
  7078. }
  7079. builder.MoveToCell(1, i, 3, 0);
  7080. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7081. builder.MoveToCell(1, i, 4, 0);
  7082. builder.Write("费用小计:");
  7083. builder.MoveToCell(1, i, 5, 0);
  7084. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7085. }
  7086. #endregion
  7087. }
  7088. else dic.Add("SubHS", "0.00");
  7089. //删除多余行
  7090. while (table2.Rows.Count > table2Row)
  7091. {
  7092. table2.Rows.RemoveAt(table2Row);
  7093. }
  7094. //公杂费
  7095. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7096. if (_EnterExitCosts.ChoiceFive == 1)
  7097. {
  7098. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7099. table3Row = dac3.Count;
  7100. #region 填充word表格内容
  7101. for (int i = 0; i < dac3.Count; i++)
  7102. {
  7103. Grp_DayAndCost dac = dac3[i];
  7104. if (dac == null) continue;
  7105. builder.MoveToCell(2, i, 0, 0);
  7106. builder.Write("第" + dac.Days.ToString() + "天:");
  7107. builder.MoveToCell(2, i, 1, 0);
  7108. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7109. builder.MoveToCell(2, i, 2, 0);
  7110. builder.Write("费用标准:");
  7111. string curr = "";
  7112. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7113. if (currData != null)
  7114. {
  7115. curr = currData.Name;
  7116. }
  7117. builder.MoveToCell(2, i, 3, 0);
  7118. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7119. builder.MoveToCell(2, i, 4, 0);
  7120. builder.Write("费用小计:");
  7121. builder.MoveToCell(2, i, 5, 0);
  7122. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7123. }
  7124. //删除多余行
  7125. while (table3.Rows.Count > table3Row)
  7126. {
  7127. table3.Rows.RemoveAt(table3Row);
  7128. }
  7129. #endregion
  7130. }
  7131. else dic.Add("SubGZF", "0.00");
  7132. //删除多余行
  7133. while (table3.Rows.Count > table3Row)
  7134. {
  7135. table3.Rows.RemoveAt(table3Row);
  7136. }
  7137. //培训费
  7138. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7139. if (_EnterExitCosts.ChoiceSix == 1)
  7140. {
  7141. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  7142. dic.Add("SubPX", pxStr);
  7143. table4Row = dac4.Count;
  7144. #region 填充word表格内容
  7145. for (int i = 0; i < dac4.Count; i++)
  7146. {
  7147. Grp_DayAndCost dac = dac4[i];
  7148. if (dac == null) continue;
  7149. builder.MoveToCell(3, i, 0, 0);
  7150. builder.Write("第" + dac.Days.ToString() + "天:");
  7151. builder.MoveToCell(3, i, 1, 0);
  7152. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7153. builder.MoveToCell(3, i, 2, 0);
  7154. builder.Write("费用标准:");
  7155. string curr = "";
  7156. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7157. if (currData != null)
  7158. {
  7159. curr = currData.Name;
  7160. }
  7161. builder.MoveToCell(3, i, 3, 0);
  7162. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7163. builder.MoveToCell(3, i, 4, 0);
  7164. builder.Write("费用小计:");
  7165. builder.MoveToCell(3, i, 5, 0);
  7166. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7167. }
  7168. #endregion
  7169. }
  7170. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  7171. //删除多余行
  7172. while (table4.Rows.Count > table4Row)
  7173. {
  7174. table4.Rows.RemoveAt(table4Row);
  7175. }
  7176. //其他费用
  7177. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7178. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7179. {
  7180. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  7181. dic.Add("titleQi", qtStr);
  7182. table5Row = dac5.Count;
  7183. #region 填充word表格内容
  7184. for (int i = 0; i < dac5.Count; i++)
  7185. {
  7186. var dac = dac5[i];
  7187. if (dac == null) continue;
  7188. builder.MoveToCell(4, i, 0, 0);
  7189. builder.Write("第" + dac.Index.ToString() + "项:");
  7190. builder.MoveToCell(4, i, 1, 0);
  7191. builder.Write(dac.itemName);
  7192. builder.MoveToCell(4, i, 2, 0);
  7193. builder.Write("费用标准:");
  7194. builder.MoveToCell(4, i, 3, 0);
  7195. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7196. builder.MoveToCell(4, i, 4, 0);
  7197. builder.Write("费用小计:");
  7198. builder.MoveToCell(4, i, 5, 0);
  7199. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7200. builder.MoveToCell(4, i, 6, 0);
  7201. builder.Write("备注:");
  7202. builder.MoveToCell(4, i, 7, 0);
  7203. builder.Write(dac.Remark);
  7204. }
  7205. #endregion
  7206. }
  7207. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7208. //删除多余行
  7209. while (table5.Rows.Count > table5Row)
  7210. {
  7211. table5.Rows.RemoveAt(table5Row);
  7212. }
  7213. //加上其他费用
  7214. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7215. decimal subJJC = 0.00M,
  7216. subGWC = 0.00M,
  7217. subTDC = 0.00M;
  7218. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7219. string totalLabel = string.Format("全部费用总计:");
  7220. //经济舱
  7221. if (_EnterExitCosts.SumJJC == 1)
  7222. {
  7223. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7224. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  7225. }
  7226. //公务舱
  7227. if (_EnterExitCosts.SumGWC == 1)
  7228. {
  7229. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7230. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  7231. }
  7232. //头等舱
  7233. if (_EnterExitCosts.SumTDC == 1)
  7234. {
  7235. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7236. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  7237. }
  7238. //TotalLabel
  7239. dic.Add("TotalLabel", totalLabel);
  7240. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7241. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7242. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7243. #region 填充word模板书签内容
  7244. foreach (var key in dic.Keys)
  7245. {
  7246. Bookmark bookmark = doc.Range.Bookmarks[key];
  7247. if (bookmark != null)
  7248. {
  7249. builder.MoveToBookmark(key);
  7250. builder.Write(dic[key]);
  7251. }
  7252. }
  7253. #endregion
  7254. #region 设置页眉
  7255. string userLabel = string.Empty;
  7256. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7257. if (currUserInfo != null)
  7258. {
  7259. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  7260. if (userInfo != null)
  7261. {
  7262. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  7263. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  7264. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  7265. }
  7266. }
  7267. //设置页脚
  7268. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  7269. #endregion
  7270. //文件名
  7271. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  7272. AsposeHelper.removewatermark_v2180();
  7273. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7274. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7275. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7276. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7277. }
  7278. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7279. {
  7280. //获取模板
  7281. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7282. //载入模板
  7283. var doc = new Document(tempPath);
  7284. var builder = new DocumentBuilder(doc);
  7285. var dic = new Dictionary<string, string>();
  7286. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7287. {
  7288. var list = new List<string>();
  7289. try
  7290. {
  7291. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7292. foreach (var item in spilitArr)
  7293. {
  7294. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7295. var depCode = spDotandEmpty[2].Substring(0, 3);
  7296. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7297. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7298. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7299. list.Add(depName);
  7300. list.Add(arrName);
  7301. }
  7302. list = list.Distinct().ToList();
  7303. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7304. }
  7305. catch (Exception)
  7306. {
  7307. dic.Add("ReturnCode", "行程录入不正确!");
  7308. }
  7309. }
  7310. else
  7311. {
  7312. dic.Add("ReturnCode", "未录入行程!");
  7313. }
  7314. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7315. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7316. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7317. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7318. {
  7319. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7320. dic.Add("Day", sp.Days.ToString());
  7321. }
  7322. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7323. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7324. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7325. //dic.Add("Names", Names);
  7326. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7327. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7328. decimal dac1totalPrice = 0.00M;
  7329. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7330. foreach (var dac in dac1)
  7331. {
  7332. if (dac.SubTotal == 0.00M)
  7333. {
  7334. continue;
  7335. }
  7336. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7337. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7338. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7339. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7340. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7341. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7342. builder.Write(currency);//币种
  7343. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7344. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7345. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7346. builder.Write("");//人数
  7347. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7348. builder.Write("");//天数
  7349. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7350. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7351. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7352. decimal rate = 0.00M;
  7353. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7354. builder.Write(rate.ToString("#0.0000"));//汇率
  7355. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7356. decimal rbmPrice = dac.SubTotal;
  7357. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7358. accommodationStartIndex++;
  7359. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7360. }
  7361. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7362. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7363. {
  7364. table1.Rows.RemoveAt(i - 1);
  7365. foodandotherStartIndex--;
  7366. }
  7367. if (dac2.Count == dac3.Count)//国家 币种 金额
  7368. {
  7369. for (int i = 0; i < dac2.Count; i++)
  7370. {
  7371. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7372. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7373. }
  7374. }
  7375. decimal dac2totalPrice = 0.00M;
  7376. foreach (var dac in dac2)
  7377. {
  7378. if (dac.SubTotal == 0)
  7379. {
  7380. continue;
  7381. }
  7382. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7383. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7384. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7385. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7386. builder.Write(currency);//币种
  7387. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7388. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7389. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7390. builder.Write("");//人数
  7391. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7392. builder.Write("");//天数
  7393. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7394. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7395. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7396. decimal rate = 0.00M;
  7397. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7398. builder.Write(rate.ToString("#0.0000"));//汇率
  7399. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7400. decimal rbmPrice = dac.SubTotal;
  7401. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7402. foodandotherStartIndex++;
  7403. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7404. }
  7405. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7406. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7407. {
  7408. table1.Rows.RemoveAt(i - 1);
  7409. }
  7410. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7411. string otherFeeStr = "";
  7412. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7413. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7414. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7415. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7416. foreach (var otherInfo in dac5)
  7417. {
  7418. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7419. }
  7420. #endregion
  7421. if (otherFeeStr.Length > 0)
  7422. {
  7423. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7424. otherFeeStr = $"({otherFeeStr})";
  7425. dic.Add("OtherFeeStr", otherFeeStr);
  7426. }
  7427. //总计
  7428. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7429. //国际旅费
  7430. string outsideAir = string.Empty;
  7431. string allPriceAir = string.Empty;
  7432. if (_EnterExitCosts.SumJJC == 1)
  7433. {
  7434. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7435. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7436. }
  7437. if (_EnterExitCosts.SumGWC == 1)
  7438. {
  7439. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7440. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7441. }
  7442. if (_EnterExitCosts.SumTDC == 1)
  7443. {
  7444. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7445. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7446. }
  7447. dic.Add("InTravelPrice", $"({outsideAir})");
  7448. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7449. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7450. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7451. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7452. foreach (var key in dic.Keys)
  7453. {
  7454. builder.MoveToBookmark(key);
  7455. builder.Write(dic[key]);
  7456. }
  7457. //模板文件名
  7458. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7459. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7460. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7461. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7462. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7463. }
  7464. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7465. {
  7466. //获取模板
  7467. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7468. //载入模板
  7469. var designer = new WorkbookDesigner
  7470. {
  7471. Workbook = new Workbook(tempPath)
  7472. };
  7473. var dic = new Dictionary<string, string>();
  7474. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7475. {
  7476. var list = new List<string>();
  7477. try
  7478. {
  7479. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7480. foreach (var item in spilitArr)
  7481. {
  7482. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7483. var depCode = spDotandEmpty[2].Substring(0, 3);
  7484. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7485. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7486. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7487. list.Add(depName);
  7488. list.Add(arrName);
  7489. }
  7490. list = list.Distinct().ToList();
  7491. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7492. }
  7493. catch (Exception)
  7494. {
  7495. dic.Add("ReturnCode", "行程录入不正确!");
  7496. }
  7497. }
  7498. else
  7499. {
  7500. dic.Add("ReturnCode", "未录入行程!");
  7501. }
  7502. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7503. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7504. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7505. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7506. {
  7507. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7508. dic.Add("Day", sp.Days.ToString());
  7509. }
  7510. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7511. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7512. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7513. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7514. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7515. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7516. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7517. designer.SetDataSource("Name", Names);
  7518. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7519. designer.SetDataSource("Day", dic["Day"] + "天");
  7520. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7521. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7522. int startIndex = 10;
  7523. const int startIndexcopy = 10;
  7524. if (dac2.Count == dac3.Count)//国家 币种 金额
  7525. {
  7526. for (int i = 0; i < dac2.Count; i++)
  7527. {
  7528. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7529. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7530. }
  7531. }
  7532. var dtdac1 = new DataTable();
  7533. var place = new List<string>();
  7534. dtdac1.Columns.AddRange(new DataColumn[] {
  7535. new(){ ColumnName = "city"},
  7536. new(){ ColumnName = "curr"},
  7537. new(){ ColumnName = "criterion"},
  7538. new(){ ColumnName = "number",DataType = typeof(int)},
  7539. new(){ ColumnName = "day",DataType = typeof(int)},
  7540. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7541. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7542. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7543. });
  7544. var dtdac2 = new DataTable();
  7545. dtdac2.Columns.AddRange(new DataColumn[] {
  7546. new(){ ColumnName = "city"},
  7547. new(){ ColumnName = "curr"},
  7548. new(){ ColumnName = "criterion"},
  7549. new(){ ColumnName = "number",DataType = typeof(int)},
  7550. new(){ ColumnName = "day",DataType = typeof(int)},
  7551. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7552. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7553. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7554. });
  7555. dtdac1.TableName = "tb1";
  7556. dtdac2.TableName = "tb2";
  7557. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7558. foreach (var item in dac1)
  7559. {
  7560. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7561. if (place.Contains(item.Place))
  7562. {
  7563. continue;
  7564. }
  7565. DataRow row = dtdac1.NewRow();
  7566. row["city"] = item.Place;
  7567. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7568. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7569. row["curr"] = currency;
  7570. row["rate"] = rate.ToString("#0.0000");
  7571. row["criterion"] = item.Cost.ToString("#0.00");
  7572. row["number"] = 1;
  7573. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7574. //row["costRMB"] = rbmPrice;
  7575. dtdac1.Rows.Add(row);
  7576. place.Add(item.Place);
  7577. }
  7578. place = new List<string>();
  7579. foreach (var item in dac2)
  7580. {
  7581. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7582. if (place.Contains(item.Place))
  7583. {
  7584. continue;
  7585. }
  7586. DataRow row = dtdac2.NewRow();
  7587. row["city"] = item.Place;
  7588. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7589. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7590. row["curr"] = currency;
  7591. row["rate"] = rate.ToString("#0.0000");
  7592. row["criterion"] = item.Cost.ToString("#0.00");
  7593. row["number"] = 1;
  7594. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7595. //row["cost"] = item.SubTotal;
  7596. //row["costRMB"] = rbmPrice;
  7597. dtdac2.Rows.Add(row);
  7598. place.Add(item.Place);
  7599. //dac2totalPrice += rbmPrice;
  7600. }
  7601. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7602. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7603. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7604. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7605. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7606. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7607. string cell4Str1 = string.Empty;
  7608. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7609. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7610. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7611. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7612. string cellStr = $" 5.其他费用(";
  7613. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7614. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7615. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7616. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7617. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7618. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7619. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7620. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7621. foreach (var otherInfo in dac5)
  7622. {
  7623. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7624. }
  7625. #endregion
  7626. if (cellStr.Length > 8)
  7627. {
  7628. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7629. }
  7630. cellStr += ")";
  7631. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7632. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7633. decimal pxFee = dac4.Sum(it => it.Cost);
  7634. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7635. string celllastStr1 = "";
  7636. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7637. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7638. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7639. celllastStr1 += $",国际旅费 元";
  7640. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7641. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7642. designer.SetDataSource("cell4Str", cell4Str);
  7643. designer.SetDataSource("cellStr", cellStr);
  7644. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7645. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7646. designer.SetDataSource("celllastStr", celllastStr);
  7647. Workbook wb = designer.Workbook;
  7648. var sheet = wb.Worksheets[0];
  7649. //绑定datatable数据集
  7650. designer.SetDataSource(dtdac1);
  7651. designer.SetDataSource(dtdac2);
  7652. designer.Process();
  7653. var rowStart = dtdac1.Rows.Count;
  7654. while (rowStart > 0)
  7655. {
  7656. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7657. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7658. startIndex++;
  7659. rowStart--;
  7660. }
  7661. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7662. startIndex += 1; //总计行
  7663. rowStart = dtdac2.Rows.Count;
  7664. while (rowStart > 0)
  7665. {
  7666. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7667. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7668. startIndex++;
  7669. rowStart--;
  7670. }
  7671. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7672. wb.CalculateFormula(true);
  7673. //模板文件名
  7674. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7675. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7676. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7677. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7678. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7679. }
  7680. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7681. {
  7682. //获取模板
  7683. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7684. //载入模板
  7685. var doc = new Document(tempPath);
  7686. var builder = new DocumentBuilder(doc);
  7687. var dic = new Dictionary<string, string>
  7688. {
  7689. { "GroupName", _DelegationInfo.TeamName },
  7690. { "ClientUnit", _DelegationInfo.ClientUnit }
  7691. };
  7692. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7693. string missionLeaderJob = "";//负责人job
  7694. //int groupNumber = 0; //团人数
  7695. if (DeleClientList.Count > 0)
  7696. {
  7697. missionLeader = DeleClientList[0]?.Name ?? "";
  7698. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7699. }
  7700. dic.Add("MissionLeader", missionLeader); //团负责人
  7701. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7702. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7703. #region MyRegion
  7704. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7705. //{
  7706. // List<string> list = new List<string>();
  7707. // try
  7708. // {
  7709. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7710. // foreach (var item in spilitArr)
  7711. // {
  7712. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7713. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7714. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7715. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7716. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7717. // list.Add(depName);
  7718. // list.Add(arrName);
  7719. // }
  7720. // list = list.Distinct().ToList();
  7721. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7722. // }
  7723. // catch (Exception)
  7724. // {
  7725. // dic.Add("ReturnCode", "行程录入不正确!");
  7726. // }
  7727. //}
  7728. //else
  7729. //{
  7730. // dic.Add("ReturnCode", "未录入行程!");
  7731. //}
  7732. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7733. dic.Add("ReturnCode", string.Join("、", countrys));
  7734. #endregion
  7735. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7736. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7737. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7738. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7739. //{
  7740. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7741. // dic.Add("Day", sp.Days.ToString());
  7742. //}
  7743. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7744. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7745. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7746. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7747. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7748. //培训人员名单
  7749. int cultivateRowIndex = 7;
  7750. foreach (var item in DeleClientList)
  7751. {
  7752. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7753. builder.Write(item.Name);
  7754. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7755. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7756. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7757. string birthDay = "";
  7758. if (item.Birthday != null)
  7759. {
  7760. DateTime dt = Convert.ToDateTime(item.Birthday);
  7761. birthDay = $"{dt.Year}.{dt.Month}";
  7762. }
  7763. builder.Write(birthDay);
  7764. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7765. builder.Write(item.Company);
  7766. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7767. builder.Write(item.Job);
  7768. cultivateRowIndex++;
  7769. }
  7770. //删除多余行
  7771. //cultivateRowIndex -= 2;
  7772. int delRows = 10 + 7 - cultivateRowIndex;
  7773. if (delRows > 0)
  7774. {
  7775. for (int i = 0; i < delRows; i++)
  7776. {
  7777. table1.Rows.RemoveAt(cultivateRowIndex);
  7778. //cultivateRowIndex++;
  7779. }
  7780. }
  7781. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7782. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7783. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7784. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7785. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7786. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7787. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7788. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7789. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7790. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7791. //其他费用
  7792. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7793. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7794. //其他费用合计
  7795. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7796. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7797. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7798. //公务舱合计
  7799. //国际旅费
  7800. //string outsideJJ = "";
  7801. //string allPriceJJ = "";
  7802. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7803. {
  7804. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7805. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7806. }
  7807. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7808. {
  7809. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7810. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7811. }
  7812. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7813. {
  7814. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7815. dic.Add("AirFeeTotal", airFeeTotalStr);
  7816. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7817. dic.Add("FeeTotal", feeTotalStr);
  7818. }
  7819. foreach (var key in dic.Keys)
  7820. {
  7821. builder.MoveToBookmark(key);
  7822. builder.Write(dic[key]);
  7823. }
  7824. //模板文件名
  7825. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7826. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7827. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7828. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7829. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7830. }
  7831. }
  7832. else if (dto.ExportType == 2) //表格
  7833. {
  7834. //利用键值对存放数据
  7835. Dictionary<string, string> dic = new Dictionary<string, string>();
  7836. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7837. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7838. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7839. dic.Add("Day", sp.Days.ToString());
  7840. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7841. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7842. {
  7843. //获取模板
  7844. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7845. //载入模板
  7846. var doc = new Document(tempPath);
  7847. var builder = new DocumentBuilder(doc);
  7848. dic.Add("TeamName", _DelegationInfo.TeamName);
  7849. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7850. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7851. string missionLeaderName = "",
  7852. missionLeaderJob = "";
  7853. if (DeleClientList.Count > 0)
  7854. {
  7855. missionLeaderName = DeleClientList[0].Name;
  7856. missionLeaderJob = DeleClientList[0].Job;
  7857. }
  7858. dic.Add("MissionLeaderName", missionLeaderName);
  7859. dic.Add("MissionLeaderJob", missionLeaderJob);
  7860. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7861. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7862. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7863. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7864. int rowCount = 10;//总人数行
  7865. int startRowIndex = 7; //起始行
  7866. for (int i = 0; i < DeleClientList.Count; i++)
  7867. {
  7868. builder.MoveToCell(0, startRowIndex, 0, 0);
  7869. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7870. builder.MoveToCell(0, startRowIndex, 1, 0);
  7871. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7872. builder.Write(sex);//性别
  7873. builder.MoveToCell(0, startRowIndex, 2, 0);
  7874. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7875. builder.MoveToCell(0, startRowIndex, 3, 0);
  7876. builder.Write(DeleClientList[i].Company);//工作单位
  7877. builder.MoveToCell(0, startRowIndex, 4, 0);
  7878. builder.Write(DeleClientList[i].Job);//职务及级别
  7879. builder.MoveToCell(0, startRowIndex, 5, 0);
  7880. builder.Write("");//人员属性
  7881. builder.MoveToCell(0, startRowIndex, 6, 0);
  7882. builder.Write("");//上次出国时间
  7883. startRowIndex++;
  7884. }
  7885. int nullRow = rowCount - DeleClientList.Count;//空行
  7886. for (int i = 0; i < nullRow; i++)
  7887. {
  7888. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7889. }
  7890. foreach (var key in dic.Keys)
  7891. {
  7892. builder.MoveToBookmark(key);
  7893. builder.Write(dic[key]);
  7894. }
  7895. //模板文件名
  7896. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7897. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7898. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7899. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7900. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7901. }
  7902. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7903. {
  7904. //获取模板
  7905. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7906. //载入模板
  7907. var doc = new Document(tempPath);
  7908. var builder = new DocumentBuilder(doc);
  7909. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7910. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7911. dic.Add("Names", Names);
  7912. int accommodationRows = 12;
  7913. //int foodandotherRows = 12;
  7914. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7915. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7916. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7917. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7918. int accommodationStartIndex = 6;
  7919. decimal dac1totalPrice = 0.00M;
  7920. foreach (var dac in dac1)
  7921. {
  7922. if (dac.SubTotal == 0)
  7923. {
  7924. continue;
  7925. }
  7926. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7927. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7928. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7929. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7930. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7931. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7932. builder.Write(currency);//币种
  7933. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7934. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7935. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7936. builder.Write("");//人数
  7937. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7938. builder.Write("");//天数
  7939. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7940. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7941. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7942. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7943. builder.Write(rate.ToString("#0.0000"));//汇率
  7944. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7945. decimal rbmPrice = rate * dac.SubTotal;
  7946. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7947. accommodationStartIndex++;
  7948. dac1totalPrice += rbmPrice;
  7949. }
  7950. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7951. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7952. builder.Write("小计");
  7953. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7954. builder.Write(dac1totalPrice.ToString("#0.00"));
  7955. accommodationStartIndex++;
  7956. int nullRow = accommodationRows - dac1.Count;
  7957. //删除空行
  7958. //if (nullRow > 0)
  7959. //{
  7960. // int rowIndex = accommodationStartIndex;
  7961. // for (int i = 0; i < nullRow; i++)
  7962. // {
  7963. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7964. // row.Remove();
  7965. // rowIndex++;
  7966. // }
  7967. //}
  7968. if (dac2.Count == dac3.Count)//国家 币种 金额
  7969. {
  7970. for (int i = 0; i < dac2.Count; i++)
  7971. {
  7972. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7973. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7974. }
  7975. }
  7976. int foodandotherStartIndex = 19;//
  7977. decimal dac2totalPrice = 0.00M;
  7978. foreach (var dac in dac2)
  7979. {
  7980. if (dac.SubTotal == 0)
  7981. {
  7982. continue;
  7983. }
  7984. //foodandotherStartIndex = 12;
  7985. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7986. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7987. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7988. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7989. builder.Write(currency);//币种
  7990. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7991. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7992. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7993. builder.Write("");//人数
  7994. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7995. builder.Write("");//天数
  7996. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7997. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7998. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7999. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8000. builder.Write(rate.ToString("#0.0000"));//汇率
  8001. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8002. decimal rbmPrice = rate * dac.SubTotal;
  8003. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8004. foodandotherStartIndex++;
  8005. dac2totalPrice += rbmPrice;
  8006. }
  8007. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8008. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8009. //删除空行
  8010. //if (dac2.Count < foodandotherRows)
  8011. //{
  8012. // while (table2.Rows.Count > dac2.Count)
  8013. // {
  8014. // table2.Rows.RemoveAt(dac2.Count);
  8015. // }
  8016. //}
  8017. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8018. string otherFeeStr = "";
  8019. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8020. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8021. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8022. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8023. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8024. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8025. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8026. foreach (var otherInfo in dac5)
  8027. {
  8028. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8029. }
  8030. #endregion
  8031. if (otherFeeStr.Length > 0)
  8032. {
  8033. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8034. otherFeeStr = $"({otherFeeStr})";
  8035. dic.Add("OtherFeeStr", otherFeeStr);
  8036. }
  8037. foreach (var key in dic.Keys)
  8038. {
  8039. builder.MoveToBookmark(key);
  8040. builder.Write(dic[key]);
  8041. }
  8042. //模板文件名
  8043. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8044. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8045. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8046. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8047. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8048. }
  8049. }
  8050. else if (dto.ExportType == 3)
  8051. {
  8052. if (dto.SubTypeId == 1) //团组成员名单
  8053. {
  8054. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  8055. //获取模板
  8056. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  8057. //载入模板
  8058. var doc = new Document(tempPath);
  8059. var builder = new DocumentBuilder(doc);
  8060. //获取word里所有表格
  8061. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8062. //获取所填表格的序数
  8063. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8064. var rowStart = tableOne.Rows[0]; //获取第1行
  8065. //循环赋值
  8066. for (int i = 0; i < DeleClientList.Count; i++)
  8067. {
  8068. builder.MoveToCell(0, i + 1, 0, 0);
  8069. builder.Write(DeleClientList[i].Name);
  8070. builder.MoveToCell(0, i + 1, 1, 0);
  8071. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8072. builder.Write(sex);
  8073. builder.MoveToCell(0, i + 1, 2, 0);
  8074. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  8075. builder.MoveToCell(0, i + 1, 3, 0);
  8076. builder.Write(DeleClientList[i].Company);
  8077. builder.MoveToCell(0, i + 1, 4, 0);
  8078. builder.Write(DeleClientList[i].Job);
  8079. }
  8080. //删除多余行
  8081. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  8082. {
  8083. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  8084. }
  8085. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  8086. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  8087. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  8088. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8089. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8090. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8091. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8092. }
  8093. }
  8094. return Ok(JsonView(400, "操作失败!", ""));
  8095. }
  8096. catch (Exception ex)
  8097. {
  8098. return Ok(JsonView(400, ex.Message, ""));
  8099. }
  8100. }
  8101. /// <summary>
  8102. /// 获取三公费用标准city
  8103. /// </summary>
  8104. /// <param name="placeData"></param>
  8105. /// <param name="nationalTravelFeeId"></param>
  8106. /// <returns></returns>
  8107. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8108. {
  8109. string _city = string.Empty;
  8110. if (placeData.Count < 1) return _city;
  8111. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8112. if (data == null) return _city;
  8113. string country = data.Country;
  8114. string city = data.City;
  8115. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8116. else _city = city;
  8117. return _city;
  8118. }
  8119. ///// <summary>
  8120. ///// 团组模块 - 出入境费用 - 明细表导出
  8121. ///// </summary>
  8122. ///// <returns></returns>
  8123. //[HttpPost]
  8124. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8125. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  8126. //{
  8127. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  8128. // if (data.Code != 0)
  8129. // {
  8130. // return Ok(JsonView(false, data.Msg));
  8131. // }
  8132. // return Ok(JsonView(true, data.Msg, data.Data));
  8133. //}
  8134. /// <summary>
  8135. /// 团组模块 - 出入境费用 - 一键清空
  8136. /// </summary>
  8137. /// <returns></returns>
  8138. [HttpPost]
  8139. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8141. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  8142. {
  8143. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  8144. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8145. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8146. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  8147. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8148. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  8149. .SetColumns(x => new Grp_DayOtherPrice
  8150. {
  8151. IsDel = 1,
  8152. DeleteUserId = dto.UserId,
  8153. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8154. })
  8155. .ExecuteCommandAsync();
  8156. if (_view.Code == 0)
  8157. {
  8158. return Ok(JsonView(true, "操作成功"));
  8159. }
  8160. return Ok(JsonView(false, "操作失败"));
  8161. }
  8162. /// <summary>
  8163. /// 团组模块 - 出入境费用 - 子项删除
  8164. /// </summary>
  8165. /// <returns></returns>
  8166. [HttpPost]
  8167. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8169. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  8170. {
  8171. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8172. if (data.Code != 0)
  8173. {
  8174. return Ok(JsonView(false, data.Msg));
  8175. }
  8176. return Ok(JsonView(true, "操作成功!", data.Data));
  8177. }
  8178. /// <summary>
  8179. /// 删除三公其他费用
  8180. /// </summary>
  8181. /// <param name="dto"></param>
  8182. /// <returns></returns>
  8183. [HttpPost]
  8184. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8185. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  8186. {
  8187. var jw = JsonView(false, "删除失败!");
  8188. var data = new Grp_DayOtherPrice()
  8189. {
  8190. Id = dto.Id,
  8191. IsDel = 1,
  8192. DeleteUserId = dto.DeleteUserId,
  8193. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8194. };
  8195. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8196. if (del > 0)
  8197. {
  8198. jw.Code = 200;
  8199. jw.Msg = "删除成功!";
  8200. }
  8201. return Ok(jw);
  8202. }
  8203. /// <summary>
  8204. /// 团组模块 - 出入境国家费用标准 List
  8205. /// </summary>
  8206. /// <returns></returns>
  8207. [HttpPost]
  8208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8209. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  8210. {
  8211. int provinceId = dto.ProvinceId;
  8212. if (provinceId < 1) provinceId = 122; //默认四川省数据
  8213. var nftData = await _sqlSugar
  8214. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  8215. JoinType.Left, ntf.Currency == sd1.Id,
  8216. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8217. JoinType.Left, ntf.ProvinceId == c.Id
  8218. ))
  8219. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8220. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  8221. {
  8222. Id = ntf.Id,
  8223. ProvinceId = ntf.ProvinceId,
  8224. ProvinceName = c.Name_CN,
  8225. Continent = ntf.Continent,
  8226. Country = ntf.Country,
  8227. City = ntf.City,
  8228. Currency = ntf.Currency,
  8229. CurrencyCode = sd1.Name,
  8230. CurrencyName = sd1.Remark,
  8231. RoomCost = ntf.RoomCost,
  8232. FoodCost = ntf.FoodCost,
  8233. PublicCost = ntf.PublicCost,
  8234. LastUpdateUserId = ntf.LastUpdateUserId,
  8235. LastUpdateUserName = u.CnName,
  8236. LastUpdateTime = ntf.LastUpdateTime
  8237. })
  8238. .ToListAsync();
  8239. return Ok(JsonView(true, "查询成功!", nftData));
  8240. }
  8241. /// <summary>
  8242. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  8243. /// </summary>
  8244. /// <returns></returns>
  8245. [HttpPost]
  8246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8247. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  8248. {
  8249. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  8250. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  8251. List<string> countryData = new List<string>();
  8252. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  8253. countryData = countryData.Distinct().ToList();
  8254. List<dynamic> dataSource = new List<dynamic>();
  8255. foreach (var item in countryData)
  8256. {
  8257. var cityData1 = new List<string>();
  8258. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  8259. var countryData2 = new
  8260. {
  8261. CountryName = item,
  8262. CityData = cityData1
  8263. };
  8264. if (!dataSource.Contains(countryData2))
  8265. {
  8266. dataSource.Add(countryData2);
  8267. }
  8268. }
  8269. return Ok(JsonView(true, "查询成功!", dataSource));
  8270. }
  8271. /// <summary>
  8272. /// 团组模块 - 出入境国家费用标准 Page List
  8273. /// </summary>
  8274. /// <returns></returns>
  8275. [HttpPost]
  8276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8277. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  8278. {
  8279. int portId = dto.PortType,
  8280. pageIndex = dto.PageIndex,
  8281. pageSize = dto.PageSize;
  8282. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8283. if (pageIndex == 0) pageIndex = 1;
  8284. if (pageSize == 0) pageSize = 10;
  8285. RefAsync<int> total = 0;
  8286. var nationalTravelFeeData = await _sqlSugar
  8287. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  8288. JoinType.Left, ntf.Currency == sd1.Id,
  8289. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8290. JoinType.Left, ntf.ProvinceId == sd2.Id
  8291. ))
  8292. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  8293. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  8294. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  8295. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  8296. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  8297. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  8298. {
  8299. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  8300. Id = ntf.Id,
  8301. ProvinceId = ntf.ProvinceId,
  8302. ProvinceName = sd2.Name_CN,
  8303. Continent = ntf.Continent,
  8304. Country = ntf.Country,
  8305. City = ntf.City,
  8306. Currency = ntf.Currency,
  8307. CurrencyCode = sd1.Name,
  8308. CurrencyName = sd1.Remark,
  8309. RoomCost = ntf.RoomCost,
  8310. FoodCost = ntf.FoodCost,
  8311. PublicCost = ntf.PublicCost,
  8312. LastUpdateUserId = ntf.LastUpdateUserId,
  8313. LastUpdateUserName = u.CnName,
  8314. LastUpdateTime = ntf.LastUpdateTime,
  8315. Remark = ntf.Remark
  8316. })
  8317. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8318. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8319. }
  8320. /// <summary>
  8321. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8322. /// </summary>
  8323. /// <returns></returns>
  8324. [HttpPost]
  8325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8326. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8327. {
  8328. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8329. int portId = dto.PortType;
  8330. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8331. string whereSql = string.Empty;
  8332. if (!string.IsNullOrEmpty(dto.Country))
  8333. {
  8334. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8335. }
  8336. if (!string.IsNullOrEmpty(dto.City))
  8337. {
  8338. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8339. }
  8340. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8341. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8342. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8343. From Grp_NationalTravelFee gntf
  8344. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8345. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8346. Where gntf.Isdel = 0 {0} ", whereSql);
  8347. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8348. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8349. }
  8350. /// <summary>
  8351. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8352. /// </summary>
  8353. /// <returns></returns>
  8354. [HttpPost]
  8355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8356. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  8357. {
  8358. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  8359. }
  8360. /// <summary>
  8361. /// 团组模块 - 出入境国家费用标准 - Del
  8362. /// </summary>
  8363. /// <returns></returns>
  8364. [HttpPost]
  8365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8366. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  8367. {
  8368. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  8369. {
  8370. Id = dto.Id,
  8371. DeleteUserId = dto.DeleteUserId,
  8372. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8373. IsDel = 1
  8374. };
  8375. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  8376. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  8377. .WhereColumns(it => new { it.Id })
  8378. .ExecuteCommandAsync();
  8379. if (delStatus <= 0)
  8380. {
  8381. return Ok(JsonView(false, "删除失败!"));
  8382. }
  8383. return Ok(JsonView(true, "操作成功!"));
  8384. }
  8385. /// <summary>
  8386. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  8387. /// 注:Get 请求Headers 加 Token
  8388. /// </summary>
  8389. /// <param name="groupId"></param>
  8390. /// <returns></returns>
  8391. [HttpGet("{groupId}")]
  8392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8393. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  8394. {
  8395. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8396. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8397. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8398. data.ForEach(x =>
  8399. {
  8400. x.CreateUserId = _currUserInfo.UserId;
  8401. });
  8402. if (data.Any())
  8403. {
  8404. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8405. if (add > 0)
  8406. {
  8407. return Ok(JsonView(true, "操作成功!"));
  8408. }
  8409. }
  8410. return Ok(JsonView(false, "未操作!"));
  8411. }
  8412. #endregion
  8413. #region 团组经理模块 出入境费用-草稿
  8414. /// <summary>
  8415. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8416. /// </summary>
  8417. /// <returns></returns>
  8418. [HttpGet]
  8419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8420. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8421. {
  8422. var provData = await _groupRepository.ProvinceBasicSource();
  8423. return Ok(JsonView(true, "查询成功!", provData));
  8424. }
  8425. /// <summary>
  8426. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8427. /// </summary>
  8428. /// <returns></returns>
  8429. [HttpGet("{provinceId}")]
  8430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8431. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8432. {
  8433. //验证城市归属并给默认值
  8434. if (provinceId < 1) provinceId = 122;
  8435. /*
  8436. * 122 四川
  8437. * 108 贵州
  8438. * 103 重庆
  8439. * 132 云南
  8440. */
  8441. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8442. return Ok(JsonView(true, "查询成功!", new
  8443. {
  8444. WordTypeData = wordTypeData,
  8445. ExcelTypeData = excelTypeData,
  8446. }));
  8447. }
  8448. /// <summary>
  8449. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8450. /// </summary>
  8451. /// <returns></returns>
  8452. [HttpPost]
  8453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8454. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8455. {
  8456. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8457. .Where(x => x.IsDel == 0)
  8458. .OrderByDescending(x => x.CreateTime)
  8459. .Select(x => new { x.Id, x.DraftName })
  8460. .ToListAsync();
  8461. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8462. //SetDataInfoView
  8463. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8464. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8465. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8466. int provinceId = dto.ProvinceId;
  8467. if (provinceId < 1) provinceId = 122;
  8468. /*
  8469. * 122 四川
  8470. * 108 贵州
  8471. * 103 重庆
  8472. * 132 云南
  8473. */
  8474. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8475. //默认币种显示
  8476. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8477. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8478. return Ok(JsonView(true, "查询成功!", new
  8479. {
  8480. DraftNameDatas = draftNameDatas,
  8481. CurrencyData = _CurrencyData,
  8482. WordTypeData = wordTypeData,
  8483. ExcelTypeData = excelTypeData,
  8484. CurrencyInit = _currencyInfos,
  8485. ViewPermissionData = viewPermissionData
  8486. }));
  8487. }
  8488. /// <summary>
  8489. /// 团组模块 - 出入境费用-草稿
  8490. /// 实时汇率 tips
  8491. /// 机票费用 tips
  8492. /// </summary>
  8493. /// <returns></returns>
  8494. [HttpPost]
  8495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8496. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8497. {
  8498. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8499. return Ok(JsonView(true, "查询成功!", new
  8500. {
  8501. //GroupNameData = groupNameData.Data,
  8502. //visaData = visaData.Data,
  8503. //airData = airData.Data,
  8504. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8505. }));
  8506. }
  8507. /// <summary>
  8508. /// 团组模块 - 出入境费用-草稿
  8509. /// 签证费用 tips
  8510. /// </summary>
  8511. /// <returns></returns>
  8512. [HttpPost]
  8513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8514. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8515. {
  8516. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8517. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8518. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8519. .Select(x => x.NationalTravelFeeId)
  8520. .Distinct()
  8521. .ToListAsync();
  8522. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8523. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8524. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8525. .Select(x => x.Country)
  8526. .Distinct()
  8527. .ToArrayAsync();
  8528. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8529. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8530. return Ok(JsonView(true, "查询成功!", new
  8531. {
  8532. totalAmt,
  8533. remark
  8534. }));
  8535. }
  8536. /// <summary>
  8537. /// 团组模块 - 出入境费用-草稿 - Info
  8538. /// </summary>
  8539. /// <returns></returns>
  8540. [HttpPost]
  8541. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8543. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8544. {
  8545. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8546. }
  8547. /// <summary>
  8548. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8549. /// </summary>
  8550. /// <returns></returns>
  8551. [HttpPost]
  8552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8553. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8554. {
  8555. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8556. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8557. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8558. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8559. foreach (var userId in dto.UserIds)
  8560. {
  8561. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8562. }
  8563. if (permissions.Any())
  8564. {
  8565. _sqlSugar.BeginTran();
  8566. try
  8567. {
  8568. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8569. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8570. if (result < 1)
  8571. {
  8572. _sqlSugar.RollbackTran();
  8573. return Ok(JsonView(false));
  8574. }
  8575. }
  8576. catch (Exception ex)
  8577. {
  8578. _sqlSugar.RollbackTran();
  8579. return Ok(JsonView(false, ex.Message));
  8580. }
  8581. _sqlSugar.CommitTran();
  8582. return Ok(JsonView(true));
  8583. }
  8584. return Ok(JsonView(false));
  8585. }
  8586. /// <summary>
  8587. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8588. /// </summary>
  8589. /// <returns></returns>
  8590. [HttpPost]
  8591. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8593. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8594. {
  8595. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8596. if (data.Code != 0)
  8597. {
  8598. return Ok(JsonView(false, data.Msg));
  8599. }
  8600. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8601. //汇率信息记录
  8602. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8603. return Ok(JsonView(true, data.Msg, data.Data));
  8604. }
  8605. /// <summary>
  8606. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8607. /// </summary>
  8608. /// <param name="dto"></param>
  8609. /// <returns></returns>
  8610. [HttpPost]
  8611. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8613. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8614. {
  8615. try
  8616. {
  8617. var id = dto.Id;
  8618. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8619. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8620. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8621. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8622. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8623. 3 团组成员名单 1 团组成员名单", ""));
  8624. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8625. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8626. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8627. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8628. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8629. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8630. //数据源
  8631. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8632. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8633. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8634. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8635. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8636. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8637. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8638. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8639. .Select((x, a, b) => new
  8640. {
  8641. x.Index,
  8642. itemName = a.Name,
  8643. CurrencyStr = b.Name,
  8644. x.Cost,
  8645. x.SubTotal,
  8646. x.Remark
  8647. })
  8648. .OrderBy((x) => x.Index)
  8649. .ToList(); //其他款项费用
  8650. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8651. var peiceItemCurrencys = new List<string>();
  8652. if (_DayAndCosts.Any())
  8653. {
  8654. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8655. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8656. }
  8657. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8658. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8659. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8660. {
  8661. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8662. }
  8663. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8664. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8665. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8666. if (dto.ExportType == 1) //明细表
  8667. {
  8668. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8669. {
  8670. //获取模板
  8671. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8672. //载入模板
  8673. Document doc = new Document(tempPath);
  8674. DocumentBuilder builder = new DocumentBuilder(doc);
  8675. //利用键值对存放数据
  8676. Dictionary<string, string> dic = new Dictionary<string, string>();
  8677. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8678. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8679. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8680. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8681. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8682. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8683. //境内费用(其他费用)
  8684. if (_EnterExitCosts.ChoiceOne == 1)
  8685. {
  8686. string row1_1 = "";
  8687. if (_EnterExitCosts.Visa > 0)
  8688. {
  8689. //insidePayTotal += _EnterExitCosts.Visa;
  8690. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8691. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8692. //{
  8693. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8694. //}
  8695. }
  8696. string row1_2 = "";
  8697. if (_EnterExitCosts.YiMiao > 0)
  8698. {
  8699. //insidePayTotal += _EnterExitCosts.YiMiao;
  8700. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8701. }
  8702. if (_EnterExitCosts.HeSuan > 0)
  8703. {
  8704. //insidePayTotal += _EnterExitCosts.HeSuan;
  8705. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8706. }
  8707. if (_EnterExitCosts.Service > 0)
  8708. {
  8709. //insidePayTotal += _EnterExitCosts.Service;
  8710. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8711. }
  8712. string row1_3 = "";
  8713. if (_EnterExitCosts.Safe > 0)
  8714. {
  8715. //insidePayTotal += _EnterExitCosts.Safe;
  8716. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8717. }
  8718. if (_EnterExitCosts.Ticket > 0)
  8719. {
  8720. //insidePayTotal += _EnterExitCosts.Ticket;
  8721. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8722. }
  8723. string row1 = "";
  8724. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8725. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8726. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8727. row1 += $"备注:{_EnterExitCosts.Remark}";
  8728. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8729. dic.Add("Row1Str", row1);
  8730. }
  8731. string airTotalStr = string.Empty,
  8732. airPriceStr = string.Empty;
  8733. //经济舱
  8734. if (_EnterExitCosts.SumJJC == 1)
  8735. {
  8736. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8737. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8738. }
  8739. //公务舱
  8740. if (_EnterExitCosts.SumGWC == 1)
  8741. {
  8742. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8743. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8744. }
  8745. //头等舱
  8746. if (_EnterExitCosts.SumTDC == 1)
  8747. {
  8748. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8749. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8750. }
  8751. //汇率描述
  8752. string rateStr = "";
  8753. if (peiceItemCurrencyInfos.Any())
  8754. {
  8755. rateStr = "\r\n汇率描述:";
  8756. foreach (var item in peiceItemCurrencyInfos)
  8757. {
  8758. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8759. }
  8760. }
  8761. string twoItemRemark = "备注:";
  8762. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8763. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8764. dic.Add("AirTotalStr", airTotalStr);
  8765. dic.Add("AirPriceStr", airPriceStr);
  8766. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8767. dic.Add("TwoItemRemark", twoItemRemark);
  8768. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8769. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8770. int table1Row = 0,
  8771. table2Row = 0,
  8772. table3Row = 0,
  8773. table4Row = 0,
  8774. table5Row = 0;
  8775. //住宿费
  8776. if (_EnterExitCosts.ChoiceThree == 1)
  8777. {
  8778. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8779. table1Row = dac1.Count;
  8780. #region 填充word表格内容
  8781. for (int i = 0; i < dac1.Count; i++)
  8782. {
  8783. var dac = dac1[i];
  8784. if (dac == null) continue;
  8785. builder.MoveToCell(0, i, 0, 0);
  8786. builder.Write("第" + dac.Days.ToString() + "晚:");
  8787. builder.MoveToCell(0, i, 1, 0);
  8788. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8789. //builder.Write(dac.Place == null ? "" : dac.Place);
  8790. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8791. builder.MoveToCell(0, i, 2, 0);
  8792. builder.Write("费用标准:");
  8793. string curr = "";
  8794. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8795. if (currData != null)
  8796. {
  8797. curr = currData.Name;
  8798. }
  8799. builder.MoveToCell(0, i, 3, 0);
  8800. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8801. builder.MoveToCell(0, i, 4, 0);
  8802. builder.Write("费用小计:");
  8803. builder.MoveToCell(0, i, 5, 0);
  8804. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8805. }
  8806. #endregion
  8807. }
  8808. else dic.Add("SubZS", "0.00");
  8809. //删除多余行
  8810. while (table1.Rows.Count > table1Row)
  8811. {
  8812. table1.Rows.RemoveAt(table1Row);
  8813. }
  8814. //伙食费
  8815. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8816. if (_EnterExitCosts.ChoiceFour == 1)
  8817. {
  8818. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8819. table2Row = dac2.Count;
  8820. #region 填充word表格内容
  8821. for (int i = 0; i < dac2.Count; i++)
  8822. {
  8823. var dac = dac2[i];
  8824. if (dac == null) continue;
  8825. builder.MoveToCell(1, i, 0, 0);
  8826. builder.Write("第" + dac.Days.ToString() + "天:");
  8827. builder.MoveToCell(1, i, 1, 0);
  8828. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8829. builder.MoveToCell(1, i, 2, 0);
  8830. builder.Write("费用标准:");
  8831. string curr = "";
  8832. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8833. if (currData != null)
  8834. {
  8835. curr = currData.Name;
  8836. }
  8837. builder.MoveToCell(1, i, 3, 0);
  8838. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8839. builder.MoveToCell(1, i, 4, 0);
  8840. builder.Write("费用小计:");
  8841. builder.MoveToCell(1, i, 5, 0);
  8842. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8843. }
  8844. #endregion
  8845. }
  8846. else dic.Add("SubHS", "0.00");
  8847. //删除多余行
  8848. while (table2.Rows.Count > table2Row)
  8849. {
  8850. table2.Rows.RemoveAt(table2Row);
  8851. }
  8852. //公杂费
  8853. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8854. if (_EnterExitCosts.ChoiceFive == 1)
  8855. {
  8856. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8857. table3Row = dac3.Count;
  8858. #region 填充word表格内容
  8859. for (int i = 0; i < dac3.Count; i++)
  8860. {
  8861. var dac = dac3[i];
  8862. if (dac == null) continue;
  8863. builder.MoveToCell(2, i, 0, 0);
  8864. builder.Write("第" + dac.Days.ToString() + "天:");
  8865. builder.MoveToCell(2, i, 1, 0);
  8866. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8867. builder.MoveToCell(2, i, 2, 0);
  8868. builder.Write("费用标准:");
  8869. string curr = "";
  8870. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8871. if (currData != null)
  8872. {
  8873. curr = currData.Name;
  8874. }
  8875. builder.MoveToCell(2, i, 3, 0);
  8876. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8877. builder.MoveToCell(2, i, 4, 0);
  8878. builder.Write("费用小计:");
  8879. builder.MoveToCell(2, i, 5, 0);
  8880. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8881. }
  8882. //删除多余行
  8883. while (table3.Rows.Count > table3Row)
  8884. {
  8885. table3.Rows.RemoveAt(table3Row);
  8886. }
  8887. #endregion
  8888. }
  8889. else dic.Add("SubGZF", "0.00");
  8890. //删除多余行
  8891. while (table3.Rows.Count > table3Row)
  8892. {
  8893. table3.Rows.RemoveAt(table3Row);
  8894. }
  8895. //培训费
  8896. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8897. if (_EnterExitCosts.ChoiceSix == 1)
  8898. {
  8899. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8900. dic.Add("SubPX", pxStr);
  8901. table4Row = dac4.Count;
  8902. #region 填充word表格内容
  8903. for (int i = 0; i < dac4.Count; i++)
  8904. {
  8905. var dac = dac4[i];
  8906. if (dac == null) continue;
  8907. builder.MoveToCell(3, i, 0, 0);
  8908. builder.Write("第" + dac.Days.ToString() + "天:");
  8909. builder.MoveToCell(3, i, 1, 0);
  8910. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8911. builder.MoveToCell(3, i, 2, 0);
  8912. builder.Write("费用标准:");
  8913. string curr = "";
  8914. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8915. if (currData != null)
  8916. {
  8917. curr = currData.Name;
  8918. }
  8919. builder.MoveToCell(3, i, 3, 0);
  8920. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8921. builder.MoveToCell(3, i, 4, 0);
  8922. builder.Write("费用小计:");
  8923. builder.MoveToCell(3, i, 5, 0);
  8924. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8925. }
  8926. #endregion
  8927. }
  8928. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8929. //删除多余行
  8930. while (table4.Rows.Count > table4Row)
  8931. {
  8932. table4.Rows.RemoveAt(table4Row);
  8933. }
  8934. //其他费用
  8935. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8936. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8937. {
  8938. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8939. dic.Add("titleQi", qtStr);
  8940. table5Row = dac5.Count;
  8941. #region 填充word表格内容
  8942. for (int i = 0; i < dac5.Count; i++)
  8943. {
  8944. var dac = dac5[i];
  8945. if (dac == null) continue;
  8946. builder.MoveToCell(4, i, 0, 0);
  8947. builder.Write("第" + dac.Index.ToString() + "项:");
  8948. builder.MoveToCell(4, i, 1, 0);
  8949. builder.Write(dac.itemName);
  8950. builder.MoveToCell(4, i, 2, 0);
  8951. builder.Write("费用标准:");
  8952. builder.MoveToCell(4, i, 3, 0);
  8953. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8954. builder.MoveToCell(4, i, 4, 0);
  8955. builder.Write("费用小计:");
  8956. builder.MoveToCell(4, i, 5, 0);
  8957. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8958. builder.MoveToCell(4, i, 6, 0);
  8959. builder.Write("备注:");
  8960. builder.MoveToCell(4, i, 7, 0);
  8961. builder.Write(dac.Remark);
  8962. }
  8963. #endregion
  8964. }
  8965. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8966. //删除多余行
  8967. while (table5.Rows.Count > table5Row)
  8968. {
  8969. table5.Rows.RemoveAt(table5Row);
  8970. }
  8971. //加上其他费用
  8972. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8973. decimal subJJC = 0.00M,
  8974. subGWC = 0.00M,
  8975. subTDC = 0.00M;
  8976. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8977. string totalLabel = string.Format("全部费用总计:");
  8978. //经济舱
  8979. if (_EnterExitCosts.SumJJC == 1)
  8980. {
  8981. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8982. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8983. }
  8984. //公务舱
  8985. if (_EnterExitCosts.SumGWC == 1)
  8986. {
  8987. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8988. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8989. }
  8990. //头等舱
  8991. if (_EnterExitCosts.SumTDC == 1)
  8992. {
  8993. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8994. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8995. }
  8996. //TotalLabel
  8997. dic.Add("TotalLabel", totalLabel);
  8998. #region 填充word模板书签内容
  8999. foreach (var key in dic.Keys)
  9000. {
  9001. Bookmark bookmark = doc.Range.Bookmarks[key];
  9002. if (bookmark != null)
  9003. {
  9004. builder.MoveToBookmark(key);
  9005. builder.Write(dic[key]);
  9006. }
  9007. }
  9008. #endregion
  9009. //文件名
  9010. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  9011. strFileName = CommonFun.ValidFileName(strFileName);
  9012. AsposeHelper.removewatermark_v2180();
  9013. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9014. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9015. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9016. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9017. }
  9018. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  9019. {
  9020. //获取模板
  9021. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  9022. //载入模板
  9023. Document doc = new Document(tempPath);
  9024. DocumentBuilder builder = new DocumentBuilder(doc);
  9025. Dictionary<string, string> dic = new Dictionary<string, string>();
  9026. string returnCodeLabel = string.Empty;
  9027. if (nationalTravelFeeData.Any())
  9028. {
  9029. List<string> list = new List<string>();
  9030. foreach (var item in nationalTravelFeeData)
  9031. {
  9032. list.Add($"{item.Country}({item.City})");
  9033. }
  9034. list = list.Distinct().ToList();
  9035. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9036. }
  9037. var countryLabel = string.Empty;
  9038. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9039. if (countryData.Any())
  9040. {
  9041. countryLabel = string.Join("、", countryData);
  9042. }
  9043. dic.Add("ReturnCodeAir", returnCodeLabel);
  9044. dic.Add("VisitStartDate", "-");
  9045. dic.Add("VisitEndDate", "-");
  9046. dic.Add("Day", "-");
  9047. dic.Add("VisitCountry", countryLabel);
  9048. dic.Add("ClientUnit", "-");
  9049. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  9050. //dic.Add("Names", Names);
  9051. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9052. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9053. decimal dac1totalPrice = 0.00M;
  9054. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  9055. foreach (var dac in dac1)
  9056. {
  9057. if (dac.SubTotal == 0.00M)
  9058. {
  9059. continue;
  9060. }
  9061. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  9062. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  9063. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  9064. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9065. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  9066. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9067. builder.Write(currency);//币种
  9068. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  9069. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9070. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  9071. builder.Write("");//人数
  9072. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  9073. builder.Write("");//天数
  9074. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  9075. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9076. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  9077. decimal rate = 0.00M;
  9078. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9079. builder.Write(rate.ToString("#0.0000"));//汇率
  9080. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  9081. decimal rbmPrice = dac.SubTotal;
  9082. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9083. accommodationStartIndex++;
  9084. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9085. }
  9086. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9087. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  9088. {
  9089. table1.Rows.RemoveAt(i - 1);
  9090. foodandotherStartIndex--;
  9091. }
  9092. if (dac2.Count == dac3.Count)//国家 币种 金额
  9093. {
  9094. for (int i = 0; i < dac2.Count; i++)
  9095. {
  9096. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9097. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9098. }
  9099. }
  9100. decimal dac2totalPrice = 0.00M;
  9101. foreach (var dac in dac2)
  9102. {
  9103. if (dac.SubTotal == 0)
  9104. {
  9105. continue;
  9106. }
  9107. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  9108. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9109. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  9110. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9111. builder.Write(currency);//币种
  9112. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  9113. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9114. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  9115. builder.Write("");//人数
  9116. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  9117. builder.Write("");//天数
  9118. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  9119. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9120. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  9121. decimal rate = 0.00M;
  9122. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9123. builder.Write(rate.ToString("#0.0000"));//汇率
  9124. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  9125. decimal rbmPrice = dac.SubTotal;
  9126. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9127. foodandotherStartIndex++;
  9128. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9129. }
  9130. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  9131. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  9132. {
  9133. table1.Rows.RemoveAt(i - 1);
  9134. }
  9135. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9136. string otherFeeStr = "";
  9137. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  9138. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  9139. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  9140. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  9141. foreach (var otherInfo in dac5)
  9142. {
  9143. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  9144. }
  9145. #endregion
  9146. if (otherFeeStr.Length > 0)
  9147. {
  9148. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  9149. otherFeeStr = $"({otherFeeStr})";
  9150. dic.Add("OtherFeeStr", otherFeeStr);
  9151. }
  9152. //总计
  9153. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  9154. //国际旅费
  9155. string outsideAir = string.Empty;
  9156. string allPriceAir = string.Empty;
  9157. if (_EnterExitCosts.SumJJC == 1)
  9158. {
  9159. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9160. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  9161. }
  9162. if (_EnterExitCosts.SumGWC == 1)
  9163. {
  9164. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  9165. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9166. }
  9167. if (_EnterExitCosts.SumTDC == 1)
  9168. {
  9169. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  9170. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  9171. }
  9172. dic.Add("InTravelPrice", $"({outsideAir})");
  9173. dic.Add("FinalSumPrice", $"({allPriceAir})");
  9174. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  9175. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  9176. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  9177. foreach (var key in dic.Keys)
  9178. {
  9179. builder.MoveToBookmark(key);
  9180. builder.Write(dic[key]);
  9181. }
  9182. //模板文件名
  9183. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9184. strFileName = CommonFun.ValidFileName(strFileName);
  9185. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9186. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9187. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9188. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9189. }
  9190. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  9191. {
  9192. //获取模板
  9193. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  9194. //载入模板
  9195. WorkbookDesigner designer = new WorkbookDesigner();
  9196. designer.Workbook = new Workbook(tempPath);
  9197. Dictionary<string, string> dic = new Dictionary<string, string>();
  9198. string returnCodeLabel = string.Empty;
  9199. if (nationalTravelFeeData.Any())
  9200. {
  9201. List<string> list = new List<string>();
  9202. foreach (var item in nationalTravelFeeData)
  9203. {
  9204. list.Add($"{item.Country}({item.City})");
  9205. }
  9206. list = list.Distinct().ToList();
  9207. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9208. }
  9209. var countryLabel = string.Empty;
  9210. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9211. if (countryData.Any())
  9212. {
  9213. countryLabel = string.Join("、", countryData);
  9214. }
  9215. dic.Add("ReturnCodeAir", returnCodeLabel);
  9216. dic.Add("VisitStartDate", "-");
  9217. dic.Add("VisitEndDate", "-");
  9218. dic.Add("Day", "0");
  9219. dic.Add("VisitCountry", countryLabel);
  9220. dic.Add("ClientUnit", "-");
  9221. designer.SetDataSource("ClientUnit", "-");
  9222. designer.SetDataSource("VisitCountry", countryLabel);
  9223. designer.SetDataSource("Group", "-");
  9224. designer.SetDataSource("ClientUnitTitle", "-");
  9225. designer.SetDataSource("Name", "-");
  9226. designer.SetDataSource("VisitStartDate", "-");
  9227. designer.SetDataSource("Day", "0");
  9228. designer.SetDataSource("ReturnCode", returnCodeLabel);
  9229. designer.SetDataSource("ReturnCodeAir", "-");
  9230. int startIndex = 10;
  9231. const int startIndexcopy = 10;
  9232. if (dac2.Count == dac3.Count)//国家 币种 金额
  9233. {
  9234. for (int i = 0; i < dac2.Count; i++)
  9235. {
  9236. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9237. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9238. }
  9239. }
  9240. DataTable dtdac1 = new DataTable();
  9241. List<string> place = new List<string>();
  9242. dtdac1.Columns.AddRange(new DataColumn[] {
  9243. new DataColumn(){ ColumnName = "city"},
  9244. new DataColumn(){ ColumnName = "curr"},
  9245. new DataColumn(){ ColumnName = "criterion"},
  9246. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9247. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9248. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9249. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9250. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  9251. });
  9252. DataTable dtdac2 = new DataTable();
  9253. dtdac2.Columns.AddRange(new DataColumn[] {
  9254. new DataColumn(){ ColumnName = "city"},
  9255. new DataColumn(){ ColumnName = "curr"},
  9256. new DataColumn(){ ColumnName = "criterion"},
  9257. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9258. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9259. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9260. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9261. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  9262. });
  9263. dtdac1.TableName = "tb1";
  9264. dtdac2.TableName = "tb2";
  9265. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  9266. foreach (var item in dac1)
  9267. {
  9268. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9269. if (place.Contains(item.Place))
  9270. {
  9271. continue;
  9272. }
  9273. DataRow row = dtdac1.NewRow();
  9274. row["city"] = item.Place;
  9275. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9276. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9277. row["curr"] = currency;
  9278. row["rate"] = rate.ToString("#0.0000");
  9279. row["criterion"] = item.Cost.ToString("#0.00");
  9280. row["number"] = 1;
  9281. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9282. //row["costRMB"] = rbmPrice;
  9283. dtdac1.Rows.Add(row);
  9284. place.Add(item.Place);
  9285. }
  9286. place = new List<string>();
  9287. foreach (var item in dac2)
  9288. {
  9289. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9290. if (place.Contains(item.Place))
  9291. {
  9292. continue;
  9293. }
  9294. DataRow row = dtdac2.NewRow();
  9295. row["city"] = item.Place;
  9296. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9297. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9298. row["curr"] = currency;
  9299. row["rate"] = rate.ToString("#0.0000");
  9300. row["criterion"] = item.Cost.ToString("#0.00");
  9301. row["number"] = 1;
  9302. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9303. //row["cost"] = item.SubTotal;
  9304. //row["costRMB"] = rbmPrice;
  9305. dtdac2.Rows.Add(row);
  9306. place.Add(item.Place);
  9307. //dac2totalPrice += rbmPrice;
  9308. }
  9309. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9310. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9311. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9312. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9313. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9314. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9315. string cell4Str1 = string.Empty;
  9316. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9317. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9318. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9319. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9320. string cellStr = $" 5.其他费用(";
  9321. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9322. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9323. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9324. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9325. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9326. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9327. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9328. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9329. foreach (var otherInfo in dac5)
  9330. {
  9331. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9332. }
  9333. #endregion
  9334. if (cellStr.Length > 8)
  9335. {
  9336. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9337. }
  9338. cellStr += ")";
  9339. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9340. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9341. decimal pxFee = dac4.Sum(it => it.Cost);
  9342. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9343. string celllastStr1 = "";
  9344. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9345. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9346. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9347. celllastStr1 += $",国际旅费 元";
  9348. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9349. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9350. designer.SetDataSource("cell4Str", cell4Str);
  9351. designer.SetDataSource("cellStr", cellStr);
  9352. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9353. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9354. designer.SetDataSource("celllastStr", celllastStr);
  9355. Workbook wb = designer.Workbook;
  9356. var sheet = wb.Worksheets[0];
  9357. //绑定datatable数据集
  9358. designer.SetDataSource(dtdac1);
  9359. designer.SetDataSource(dtdac2);
  9360. designer.Process();
  9361. var rowStart = dtdac1.Rows.Count;
  9362. while (rowStart > 0)
  9363. {
  9364. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  9365. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9366. startIndex++;
  9367. rowStart--;
  9368. }
  9369. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  9370. startIndex += 1; //总计行
  9371. rowStart = dtdac2.Rows.Count;
  9372. while (rowStart > 0)
  9373. {
  9374. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  9375. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9376. startIndex++;
  9377. rowStart--;
  9378. }
  9379. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  9380. wb.CalculateFormula(true);
  9381. //模板文件名
  9382. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9383. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9384. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9385. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9386. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9387. }
  9388. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  9389. {
  9390. //获取模板
  9391. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  9392. //载入模板
  9393. Document doc = new Document(tempPath);
  9394. DocumentBuilder builder = new DocumentBuilder(doc);
  9395. Dictionary<string, string> dic = new Dictionary<string, string>();
  9396. dic.Add("GroupName", "-");
  9397. dic.Add("ClientUnit", "-");
  9398. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9399. //string missionLeaderJob = "";//负责人job
  9400. //int groupNumber = 0; //团人数
  9401. dic.Add("MissionLeader", "-"); //团负责人
  9402. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9403. dic.Add("GroupNumber", "0"); //团人数
  9404. dic.Add("Day", "0");
  9405. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9406. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9407. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9408. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9409. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9410. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9411. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9412. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9413. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9414. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9415. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9416. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9417. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9418. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9419. //其他费用
  9420. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9421. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9422. //其他费用合计
  9423. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9424. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9425. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9426. //公务舱合计
  9427. //国际旅费
  9428. //string outsideJJ = "";
  9429. //string allPriceJJ = "";
  9430. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9431. {
  9432. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9433. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9434. }
  9435. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9436. {
  9437. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9438. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9439. }
  9440. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9441. {
  9442. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9443. dic.Add("AirFeeTotal", airFeeTotalStr);
  9444. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9445. dic.Add("FeeTotal", feeTotalStr);
  9446. }
  9447. foreach (var key in dic.Keys)
  9448. {
  9449. builder.MoveToBookmark(key);
  9450. builder.Write(dic[key]);
  9451. }
  9452. //模板文件名
  9453. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9454. strFileName = CommonFun.ValidFileName(strFileName);
  9455. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9456. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9457. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9458. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9459. }
  9460. }
  9461. else if (dto.ExportType == 2) //表格
  9462. {
  9463. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9464. }
  9465. else if (dto.ExportType == 3)
  9466. {
  9467. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9468. }
  9469. return Ok(JsonView(400, "只可导出明细表!", ""));
  9470. }
  9471. catch (Exception ex)
  9472. {
  9473. return Ok(JsonView(400, ex.Message, ""));
  9474. }
  9475. }
  9476. /// <summary>
  9477. /// 获取三公费用标准city
  9478. /// </summary>
  9479. /// <param name="placeData"></param>
  9480. /// <param name="nationalTravelFeeId"></param>
  9481. /// <returns></returns>
  9482. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9483. {
  9484. string _city = string.Empty;
  9485. if (!placeData.Any()) return _city;
  9486. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9487. if (data == null) return _city;
  9488. string country = data.Country;
  9489. string city = data.City;
  9490. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9491. else _city = city;
  9492. return _city;
  9493. }
  9494. /// <summary>
  9495. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9496. /// </summary>
  9497. /// <returns></returns>
  9498. [HttpPost]
  9499. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9501. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9502. {
  9503. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9504. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9505. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9506. if (_view.Code == 0)
  9507. {
  9508. return Ok(JsonView(true, "操作成功"));
  9509. }
  9510. return Ok(JsonView(false, "操作失败"));
  9511. }
  9512. /// <summary>
  9513. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9514. /// </summary>
  9515. /// <returns></returns>
  9516. [HttpPost]
  9517. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9519. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9520. {
  9521. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9522. if (data.Code != 0)
  9523. {
  9524. return Ok(JsonView(false, data.Msg));
  9525. }
  9526. return Ok(JsonView(true, "操作成功!", data.Data));
  9527. }
  9528. /// <summary>
  9529. /// 三公其他费用草稿 删除
  9530. /// </summary>
  9531. /// <param name="dto"></param>
  9532. /// <returns></returns>
  9533. [HttpPost]
  9534. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9535. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9536. {
  9537. var jw = JsonView(false, "删除失败!");
  9538. var data = new Grp_DayOtherPriceDraft()
  9539. {
  9540. Id = dto.Id,
  9541. IsDel = 1,
  9542. DeleteUserId = dto.DeleteUserId,
  9543. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9544. };
  9545. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9546. if (del > 0)
  9547. {
  9548. jw.Code = 200;
  9549. jw.Msg = "删除成功!";
  9550. }
  9551. return Ok(jw);
  9552. }
  9553. /// <summary>
  9554. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9555. /// </summary>
  9556. /// <returns></returns>
  9557. [HttpPost]
  9558. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9559. {
  9560. var jw = JsonView(false);
  9561. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9562. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9563. jw.Code = StatusCodes.Status200OK;
  9564. jw.Msg = "操作成功!";
  9565. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9566. return Ok(jw);
  9567. }
  9568. /// <summary>
  9569. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9570. /// </summary>
  9571. /// <param name="dto"></param>
  9572. /// <returns></returns>
  9573. [HttpPost]
  9574. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9575. {
  9576. int userId = dto.UserId,
  9577. portId = dto.PortType,
  9578. groupId = dto.GroupId,
  9579. draftId = dto.DraftId;
  9580. _portTypeData.Add(1);
  9581. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9582. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9583. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9584. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9585. _sqlSugar.BeginTran();
  9586. try
  9587. {
  9588. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9589. if (draftDatas == null)
  9590. {
  9591. _sqlSugar.RollbackTran();
  9592. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9593. }
  9594. //验证可覆盖已有数据 两边创建人需为同一人;
  9595. int draftCreateUserId = draftDatas.CreateUserId,
  9596. formalCreateUserId = 0;
  9597. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9598. if (formalData != null)
  9599. {
  9600. formalCreateUserId = formalData.CreateUserId;
  9601. if (draftCreateUserId != formalCreateUserId)
  9602. {
  9603. _sqlSugar.RollbackTran();
  9604. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9605. }
  9606. }
  9607. //默认添加查看、编辑权限(创建人、自己)
  9608. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9609. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9610. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9611. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9612. newExterData.DiId = groupId;
  9613. newExterData.CreateUserId = userId;
  9614. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9615. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9616. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9617. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9618. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9619. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9620. //数据如果存在执行删除
  9621. if (enterExitCostInfo != null)
  9622. {
  9623. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9624. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9625. .Where(x => x.Id == enterExitCostInfo.Id)
  9626. .ExecuteCommand();
  9627. _sqlSugar.Updateable<Grp_DayAndCost>()
  9628. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9629. .Where(x => x.DiId == groupId)
  9630. .ExecuteCommand();
  9631. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9632. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9633. .Where(x => x.Diid == groupId)
  9634. .ExecuteCommand();
  9635. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9636. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9637. .Where(x => x.GroupId == groupId)
  9638. .ExecuteCommand();
  9639. }
  9640. //执行insert
  9641. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9642. if (insertId < 1)
  9643. {
  9644. _sqlSugar.RollbackTran();
  9645. return Ok(JsonView(false, "草稿数据导入失败!"));
  9646. }
  9647. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9648. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9649. #region 默认添加权限
  9650. #endregion
  9651. _sqlSugar.CommitTran();
  9652. //执行操作之后
  9653. //生成默认文件pdf并且通知人员
  9654. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9655. {
  9656. DiId = groupId,
  9657. ExportType = 1,
  9658. SubTypeId = 1005
  9659. }, "pdf");
  9660. //发送通知
  9661. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9662. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9663. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9664. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9665. //汇率信息记录
  9666. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9667. return Ok(JsonView(true));
  9668. }
  9669. catch (Exception ex)
  9670. {
  9671. _sqlSugar.RollbackTran();
  9672. return Ok(JsonView(false, ex.Message));
  9673. }
  9674. }
  9675. #endregion
  9676. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9677. /// <summary>
  9678. /// 获取币种基础数据(含逻辑处理)
  9679. /// </summary>
  9680. /// <returns></returns>
  9681. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9682. {
  9683. return await GeneralMethod.EnterExitCostInitRate();
  9684. }
  9685. /// <summary>
  9686. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9687. /// </summary>
  9688. /// <returns></returns>
  9689. [HttpPost]
  9690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9691. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9692. {
  9693. //验证城市归属并给默认值
  9694. int provinceId = dto.ProvinceId;
  9695. if (provinceId < 1) provinceId = 122;
  9696. var dataSource = await _sqlSugar
  9697. .Queryable<Sys_SetData>()
  9698. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9699. .ToListAsync();
  9700. var fileTypes = new List<EecSetDataInfoView>();
  9701. //三公费用-Word明细类型
  9702. var wordTypeData = dataSource
  9703. .Where(it => it.STid == 72)
  9704. .Select(x => new EecSetDataInfoView
  9705. {
  9706. ParentId = 1,
  9707. Id = x.Id,
  9708. Name = x.Name
  9709. })
  9710. .ToArray();
  9711. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9712. var excelTypeData = dataSource
  9713. .Where(it => it.STid == 73)
  9714. .Select(x => new EecSetDataInfoView
  9715. {
  9716. ParentId = 2,
  9717. Id = x.Id,
  9718. Name = x.Name
  9719. })
  9720. .ToArray();
  9721. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9722. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9723. fileTypes.Add(groupNameList);
  9724. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9725. //默认币种显示
  9726. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9727. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9728. return Ok(JsonView(true, "查询成功!", new
  9729. {
  9730. FileTypeData = fileTypes,
  9731. CurrencyInit = _currencyInfos,
  9732. viewPermissionData = viewPermissionData
  9733. }));
  9734. }
  9735. /// <summary>
  9736. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9737. /// </summary>
  9738. /// <returns></returns>
  9739. [HttpPost]
  9740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9741. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9742. {
  9743. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9744. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9745. RefAsync<int> total = 0;
  9746. int diId = 0;
  9747. var status = int.TryParse(dto.GroupName, out diId);
  9748. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9749. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9750. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9751. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9752. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9753. .OrderByDescending(x => x.VisitStartDate)
  9754. .Select(x => new EnterExitCostMobileGroupView()
  9755. {
  9756. Id = x.Id,
  9757. GroupName = x.TeamName,
  9758. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9759. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9760. ProvinceId = x.CityId
  9761. })
  9762. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9763. //处理省份Id
  9764. if (data.Any())
  9765. {
  9766. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9767. if (provCityDatas.Any())
  9768. {
  9769. foreach (var item in data)
  9770. {
  9771. var provinceId = item.ProvinceId;
  9772. var isDefualtVal = true;
  9773. if (provinceId > 0)
  9774. {
  9775. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9776. if (parentId != null)
  9777. {
  9778. isDefualtVal = false;
  9779. item.ProvinceId = (int)parentId;
  9780. }
  9781. }
  9782. if (isDefualtVal)
  9783. {
  9784. item.ProvinceId = 122; //默认四川
  9785. }
  9786. }
  9787. }
  9788. }
  9789. //处理是否显示
  9790. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9791. {
  9792. foreach (var item in data)
  9793. {
  9794. item.IsView = true;
  9795. }
  9796. }
  9797. return Ok(JsonView(true, "查询成功!", data, total));
  9798. }
  9799. /// <summary>
  9800. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9801. /// </summary>
  9802. /// <returns></returns>
  9803. [HttpPost]
  9804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9805. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9806. {
  9807. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9808. RefAsync<int> total = 0;
  9809. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9810. .Where(x => x.IsDel == 0 && x.STid == 66)
  9811. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9812. .Select(x => new
  9813. {
  9814. id = x.Id,
  9815. name = x.Name,
  9816. remark = x.Remark,
  9817. })
  9818. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9819. return Ok(JsonView(true, "查询成功!", data, total));
  9820. }
  9821. /// <summary>
  9822. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9823. /// </summary>
  9824. /// <returns></returns>
  9825. [HttpPost]
  9826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9827. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9828. {
  9829. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9830. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9831. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9832. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9833. var groupOtherRateData = groupRateData.TeamRates;
  9834. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9835. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9836. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9837. groupOtherRateData = groupOtherRateData
  9838. .Select(x => new TeamRateDescAddCurrencyIdView
  9839. {
  9840. CurrencyId = x.CurrencyId,
  9841. CurrencyName = x.CurrencyName,
  9842. CurrencyCode = x.CurrencyCode,
  9843. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9844. }).ToList();
  9845. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9846. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9847. }
  9848. /// <summary>
  9849. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9850. /// </summary>
  9851. /// <returns></returns>
  9852. [HttpPost]
  9853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9854. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9855. {
  9856. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9857. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9858. var tipsData = new List<int>() { 1, 2, 3 };
  9859. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9860. if (dto.TipsType == 1)
  9861. {
  9862. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9863. }
  9864. else if (dto.TipsType == 2)
  9865. {
  9866. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9867. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9868. }
  9869. else if (dto.TipsType == 3)
  9870. {
  9871. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9872. return Ok(JsonView(true, "查询成功!", airData));
  9873. }
  9874. return Ok(JsonView(false));
  9875. }
  9876. /// <summary>
  9877. /// 团组模块 - 出入境国家费用标准-移动端 List
  9878. /// </summary>
  9879. /// <returns></returns>
  9880. [HttpPost]
  9881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9882. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9883. {
  9884. Stopwatch sw = new Stopwatch();
  9885. sw.Start();
  9886. int provinceId = dto.ProvinceId;
  9887. if (provinceId < 1) provinceId = 122; // 默认四川
  9888. RefAsync<int> total = 0;
  9889. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9890. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9891. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9892. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9893. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9894. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9895. .Select((ntf, sd, u, sd1) => new
  9896. {
  9897. Id = ntf.Id,
  9898. Area = $"{ntf.Country}-{ntf.City}",
  9899. Currency = ntf.Currency,
  9900. CurrencyCode = sd.Name,
  9901. CurrencyName = sd.Remark,
  9902. RoomCost = ntf.RoomCost,
  9903. FoodCost = ntf.FoodCost,
  9904. PublicCost = ntf.PublicCost,
  9905. TrainCost = ntf.TrainCost,
  9906. LastUpdateUserId = ntf.LastUpdateUserId,
  9907. LastUpdateUserName = u.CnName,
  9908. LastUpdateTime = ntf.LastUpdateTime
  9909. })
  9910. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9911. sw.Stop();
  9912. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9913. }
  9914. /// <summary>
  9915. /// 团组模块 - 出入境费用-移动端 - Info
  9916. /// </summary>
  9917. /// <returns></returns>
  9918. [HttpPost]
  9919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9920. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9921. {
  9922. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9923. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9924. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9925. return Ok(data);
  9926. }
  9927. /// <summary>
  9928. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9929. /// </summary>
  9930. /// <returns></returns>
  9931. [HttpPost]
  9932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9933. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9934. {
  9935. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9936. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9937. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9938. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9939. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9940. mobileInfo.DiId = dto.DiId;
  9941. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9942. if (eecInfo == null) return Ok(mobileInfo);
  9943. //验证查看权限
  9944. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9945. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9946. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9947. mobileInfo.IsAssignPerm = isSet;
  9948. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9949. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9950. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9951. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9952. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9953. {
  9954. SubId = dac.Id,
  9955. DiId = dac.DiId,
  9956. Type = dac.Type,
  9957. Days = dac.Days,
  9958. NationalTravelFeeId = dac.NationalTravelFeeId,
  9959. Arae = $"{ntf.Country}-{ntf.City}",
  9960. Cost = dac.Cost,
  9961. Currency = dac.Currency,
  9962. CurrencyName = sd.Name,
  9963. SubTotal = dac.SubTotal,
  9964. })
  9965. .ToList();
  9966. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9967. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9968. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9969. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9970. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9971. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9972. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9973. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9974. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9975. //其他款项
  9976. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9977. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9978. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9979. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9980. .OrderBy((dop, sd1, sd2) => dop.Index)
  9981. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9982. {
  9983. SubId = dop.Id,
  9984. DiId = dop.Diid,
  9985. Index = dop.Index,
  9986. SetDataId = dop.SetDataId,
  9987. SetDataName = sd1.Name,
  9988. Cost = dop.Cost,
  9989. Currency = dop.Currency,
  9990. CurrencyName = sd2.Remark,
  9991. SubTotal = dop.SubTotal,
  9992. Remark = dop.Remark,
  9993. })
  9994. .ToArray();
  9995. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9996. return Ok(mobileInfo);
  9997. }
  9998. /// <summary>
  9999. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  10000. /// </summary>
  10001. /// <returns></returns>
  10002. [HttpPost]
  10003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10004. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  10005. {
  10006. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10007. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10008. //验证查看权限
  10009. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  10010. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  10011. var userIds = await _sqlSugar
  10012. .Queryable<Grp_EnterExitCostPermission>()
  10013. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  10014. .Select(x => x.UserId)
  10015. .ToArrayAsync();
  10016. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  10017. var perUsersView = new List<dynamic>();
  10018. foreach (var item in perUsers)
  10019. {
  10020. bool isView1 = false;
  10021. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10022. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10023. }
  10024. return Ok(JsonView(perUsersView));
  10025. }
  10026. /// <summary>
  10027. /// 团组模块 - 出入境费用-移动端 - SubInfo
  10028. /// </summary>
  10029. /// <returns></returns>
  10030. [HttpPost]
  10031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10032. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  10033. {
  10034. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10035. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10036. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10037. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10038. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10039. //验证查看权限
  10040. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  10041. //if (!isView) return Ok(JsonView(false, msg));
  10042. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10043. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10044. var subType = dto.SubType;
  10045. if (subType == 1) //1:境内费用
  10046. {
  10047. var oneData = new ChoiceOneMobileSubInfoView()
  10048. {
  10049. Id = eecInfo.Id,
  10050. ChoiceOne = eecInfo.ChoiceOne,
  10051. ChoiceOneTotalCost = eecInfo.InsidePay,
  10052. Visa = eecInfo.Visa,
  10053. VisaRemark = eecInfo.VisaRemark,
  10054. YiMiao = eecInfo.YiMiao,
  10055. HeSuan = eecInfo.HeSuan,
  10056. Service = eecInfo.Service,
  10057. Ticket = eecInfo.Ticket,
  10058. Safe = eecInfo.Safe,
  10059. FirstItemRemark = eecInfo.FirstItemRemark
  10060. };
  10061. return Ok(JsonView(oneData));
  10062. }
  10063. else if (subType == 2) //2:国际旅费
  10064. {
  10065. var twoData = new ChoiceTwoMobileSubInfoView()
  10066. {
  10067. Id = eecInfo.Id,
  10068. ChoiceTwoJJ = eecInfo.SumJJC,
  10069. OutsideJJPay = eecInfo.OutsideJJPay,
  10070. ChoiceTwoGW = eecInfo.SumGWC,
  10071. OutsideGWPay = eecInfo.OutsideGWPay,
  10072. ChoiceTwoTD = eecInfo.SumTDC,
  10073. OutsideTDPay = eecInfo.OutsideTDPay,
  10074. AirJJ = eecInfo.AirJJ,
  10075. AirGW = eecInfo.AirGW,
  10076. AirTD = eecInfo.AirTD,
  10077. CityTranffic = eecInfo.CityTranffic,
  10078. TwoItemRemark = eecInfo.TwoItemRemark
  10079. };
  10080. return Ok(JsonView(twoData));
  10081. }
  10082. else if (subType == 3) //3:住宿费
  10083. {
  10084. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10085. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10086. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10087. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  10088. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10089. {
  10090. SubId = dac.Id,
  10091. DiId = dac.DiId,
  10092. Type = dac.Type,
  10093. Days = dac.Days,
  10094. NationalTravelFeeId = dac.NationalTravelFeeId,
  10095. Arae = $"{ntf.Country}-{ntf.City}",
  10096. Cost = dac.Cost,
  10097. Currency = dac.Currency,
  10098. CurrencyName = sd.Name,
  10099. SubTotal = dac.SubTotal,
  10100. })
  10101. .ToArray();
  10102. var data = new ChoiceMobileSubInfo3To6View()
  10103. {
  10104. ParentId = eecInfo.Id,
  10105. Choice = eecInfo.ChoiceThree,
  10106. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10107. Details = dayAndCostDatas
  10108. };
  10109. return Ok(JsonView(data));
  10110. }
  10111. else if (subType == 4) //4:伙食费
  10112. {
  10113. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10114. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10115. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10116. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  10117. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10118. {
  10119. SubId = dac.Id,
  10120. DiId = dac.DiId,
  10121. Type = dac.Type,
  10122. Days = dac.Days,
  10123. NationalTravelFeeId = dac.NationalTravelFeeId,
  10124. Arae = $"{ntf.Country}-{ntf.City}",
  10125. Cost = dac.Cost,
  10126. Currency = dac.Currency,
  10127. CurrencyName = sd.Name,
  10128. SubTotal = dac.SubTotal,
  10129. })
  10130. .ToArray();
  10131. var data = new ChoiceMobileSubInfo3To6View()
  10132. {
  10133. ParentId = eecInfo.Id,
  10134. Choice = eecInfo.ChoiceFour,
  10135. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10136. Details = dayAndCostDatas
  10137. };
  10138. return Ok(JsonView(data));
  10139. }
  10140. else if (subType == 5) //5:公杂费
  10141. {
  10142. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10143. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10144. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10145. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  10146. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10147. {
  10148. SubId = dac.Id,
  10149. DiId = dac.DiId,
  10150. Type = dac.Type,
  10151. Days = dac.Days,
  10152. NationalTravelFeeId = dac.NationalTravelFeeId,
  10153. Arae = $"{ntf.Country}-{ntf.City}",
  10154. Cost = dac.Cost,
  10155. Currency = dac.Currency,
  10156. CurrencyName = sd.Name,
  10157. SubTotal = dac.SubTotal,
  10158. })
  10159. .ToArray();
  10160. var data = new ChoiceMobileSubInfo3To6View()
  10161. {
  10162. ParentId = eecInfo.Id,
  10163. Choice = eecInfo.ChoiceFive,
  10164. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10165. Details = dayAndCostDatas
  10166. };
  10167. return Ok(JsonView(data));
  10168. }
  10169. else if (subType == 6) //6:培训费
  10170. {
  10171. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10172. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10173. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10174. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  10175. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10176. {
  10177. SubId = dac.Id,
  10178. DiId = dac.DiId,
  10179. Type = dac.Type,
  10180. Days = dac.Days,
  10181. NationalTravelFeeId = dac.NationalTravelFeeId,
  10182. Arae = $"{ntf.Country}-{ntf.City}",
  10183. Cost = dac.Cost,
  10184. Currency = dac.Currency,
  10185. CurrencyName = sd.Name,
  10186. SubTotal = dac.SubTotal,
  10187. })
  10188. .ToArray();
  10189. var data = new ChoiceMobileSubInfo3To6View()
  10190. {
  10191. ParentId = eecInfo.Id,
  10192. Choice = eecInfo.ChoiceSix,
  10193. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10194. Details = dayAndCostDatas
  10195. };
  10196. return Ok(JsonView(data));
  10197. }
  10198. else if (subType == 7) //7:其他
  10199. {
  10200. //其他款项
  10201. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10202. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10203. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10204. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10205. .OrderBy((dop, sd1, sd2) => dop.Index)
  10206. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10207. {
  10208. SubId = dop.Id,
  10209. DiId = dop.Diid,
  10210. Index = dop.Index,
  10211. SetDataId = dop.SetDataId,
  10212. SetDataName = sd1.Name,
  10213. Cost = dop.Cost,
  10214. Currency = dop.Currency,
  10215. CurrencyName = sd2.Name,
  10216. SubTotal = dop.SubTotal,
  10217. Remark = dop.Remark,
  10218. })
  10219. .ToArray();
  10220. var data = new ChoiceSevenMobileSubInfoView()
  10221. {
  10222. ParentId = eecInfo.Id,
  10223. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10224. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10225. Details = otherData
  10226. };
  10227. return Ok(JsonView(data));
  10228. }
  10229. return Ok(JsonView(false));
  10230. }
  10231. #region op
  10232. ///// <summary>
  10233. ///// 移动端更新费用消息通知
  10234. ///// </summary>
  10235. ///// <param name="diid"></param>
  10236. ///// <param name="id"></param>
  10237. ///// <param name="currUserId"></param>
  10238. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  10239. //{
  10240. // try
  10241. // {
  10242. // ////生成默认文件pdf并且通知人员
  10243. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10244. // //{
  10245. // // DiId = diid,
  10246. // // ExportType = 1,
  10247. // // SubTypeId = 1005
  10248. // //}, "pdf");
  10249. // ////发送通知
  10250. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10251. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10252. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10253. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  10254. // ////汇率信息记录
  10255. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10256. // }
  10257. // catch (Exception ex)
  10258. // {
  10259. // //记录日志
  10260. // throw;
  10261. // }
  10262. //}
  10263. /// <summary>
  10264. /// 验证出入境费用数据是否存在
  10265. /// 不存在添加
  10266. /// </summary>
  10267. /// <param name="diId"></param>
  10268. /// <param name="currUserId"></param>
  10269. /// <returns></returns>
  10270. /// <exception cref="CustomException"></exception>
  10271. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  10272. {
  10273. var parentId = 0;
  10274. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10275. if (info != null)
  10276. {
  10277. parentId = info.Id;
  10278. }
  10279. else
  10280. {
  10281. var currencys = await EnterExitCostMobileGetCurrencyInit();
  10282. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10283. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10284. parentId = addId;
  10285. }
  10286. return parentId;
  10287. }
  10288. /// <summary>
  10289. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  10290. /// </summary>
  10291. /// <returns></returns>
  10292. [HttpPost]
  10293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10294. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  10295. {
  10296. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10297. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10298. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10299. //验证编辑权限
  10300. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10301. //if (!isEdit) return Ok(JsonView(false, msg));
  10302. var permissions = new List<Grp_EnterExitCostPermission>();
  10303. foreach (var userId in dto.UserIds)
  10304. {
  10305. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10306. }
  10307. if (permissions.Any())
  10308. {
  10309. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10310. {
  10311. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10312. }
  10313. _sqlSugar.BeginTran();
  10314. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10315. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10316. if (result < 1)
  10317. {
  10318. _sqlSugar.RollbackTran();
  10319. return Ok(JsonView(false));
  10320. }
  10321. _sqlSugar.CommitTran();
  10322. return Ok(JsonView(true));
  10323. }
  10324. return Ok(JsonView(false));
  10325. }
  10326. /// <summary>
  10327. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10328. /// </summary>
  10329. /// <returns></returns>
  10330. [HttpPost]
  10331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10332. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10333. {
  10334. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10335. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10336. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10337. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10338. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10339. int id = dto.Id;
  10340. if (id <= 0) //add
  10341. {
  10342. //int provinceId = dto.ProvinceId;
  10343. int groupId = dto.DiId;
  10344. //if (provinceId < 1) provinceId = 122;
  10345. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10346. info.LastUpdateUserId = dto.CurrUserId;
  10347. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10348. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10349. if (add < 1) return Ok(JsonView(false));
  10350. id = add;
  10351. }
  10352. else //update
  10353. {
  10354. ////验证编辑权限
  10355. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10356. //if (!isEdit) return Ok(JsonView(false, msg));
  10357. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  10358. {
  10359. CurrencyRemark = currencyStr,
  10360. LastUpdateUserId = dto.CurrUserId,
  10361. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10362. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  10363. if (upd < 1) return Ok(JsonView(false));
  10364. }
  10365. #region 汇率变更时更改币种相关费用
  10366. var opDayCosts = new List<Grp_DayAndCost>();
  10367. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  10368. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10369. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  10370. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10371. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10372. .Select((dac, sd) => new
  10373. {
  10374. dac.Id,
  10375. dac.DiId,
  10376. CurrencyCode = sd.Name,
  10377. dac.Cost
  10378. })
  10379. .ToList();
  10380. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10381. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10382. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10383. .Select((dop, sd) => new
  10384. {
  10385. dop.Id,
  10386. dop.Diid,
  10387. CurrencyCode = sd.Name,
  10388. dop.Cost
  10389. })
  10390. .ToList();
  10391. if (dayCosts.Count > 0)
  10392. {
  10393. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10394. foreach (var dc in new_dayCosts)
  10395. {
  10396. var thisCurrency = dc.Key.ToUpper();
  10397. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10398. if (thisRate == 0.00M) continue;
  10399. foreach (var dcSub in dc)
  10400. {
  10401. opDayCosts.Add(new Grp_DayAndCost()
  10402. {
  10403. Id = dcSub.Id,
  10404. DiId = dcSub.DiId,
  10405. Cost = dcSub.Cost,
  10406. SubTotal = dcSub.Cost * thisRate,
  10407. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10408. });
  10409. }
  10410. }
  10411. if (opDayCosts.Count > 0)
  10412. {
  10413. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10414. }
  10415. }
  10416. if (dayOtherCosts.Count > 0)
  10417. {
  10418. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10419. foreach (var dc in new_dayOtherCosts)
  10420. {
  10421. var thisCurrency = dc.Key.ToUpper();
  10422. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10423. if (thisRate == 0.00M) continue;
  10424. foreach (var dcSub in dc)
  10425. {
  10426. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10427. {
  10428. Id = dcSub.Id,
  10429. Diid = dcSub.Diid,
  10430. Cost = dcSub.Cost,
  10431. SubTotal = dcSub.Cost * thisRate,
  10432. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10433. });
  10434. }
  10435. }
  10436. if (opDayOtherCosts.Count > 0)
  10437. {
  10438. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10439. }
  10440. }
  10441. #endregion
  10442. //消息通知
  10443. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10444. //汇率信息记录
  10445. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10446. return Ok(JsonView(new { parentId = id }));
  10447. }
  10448. /// <summary>
  10449. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10450. /// </summary>
  10451. /// <returns></returns>
  10452. [HttpPost]
  10453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10454. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10455. {
  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 (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10460. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10461. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  10462. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10463. int id = dto.Id;
  10464. if (id <= 0) //add
  10465. {
  10466. checkboxInfo.CreateUserId = dto.CurrUserId;
  10467. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10468. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10469. if (add < 1) return Ok(JsonView(false));
  10470. }
  10471. else //update
  10472. {
  10473. ////验证编辑权限
  10474. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10475. //if (!isEdit) return Ok(JsonView(false, msg));
  10476. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10477. .UpdateColumns(x => new
  10478. {
  10479. x.ChoiceOne,
  10480. x.ChoiceTwo,
  10481. x.SumJJC,
  10482. x.SumGWC,
  10483. x.SumTDC,
  10484. x.ChoiceThree,
  10485. x.ChoiceFour,
  10486. x.ChoiceFive,
  10487. x.ChoiceSix,
  10488. x.OtherExpenses_Checked
  10489. })
  10490. .Where(x => x.Id == id)
  10491. .ExecuteCommandAsync();
  10492. if (upd < 1) return Ok(JsonView(false));
  10493. }
  10494. return Ok(JsonView(new { parentId = id }));
  10495. }
  10496. /// <summary>
  10497. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10498. /// </summary>
  10499. /// <returns></returns>
  10500. [HttpPost]
  10501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10502. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10503. {
  10504. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10505. // if (provinceId < 1) provinceId = 122;
  10506. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10507. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10508. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10509. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10510. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10511. var checkboxInfo = new Grp_EnterExitCost()
  10512. {
  10513. Id = id,
  10514. //ProvinceId = provinceId,
  10515. DiId = diId,
  10516. CreateUserId = currUserId,
  10517. LastUpdateUserId = dto.CurrUserId,
  10518. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10519. };
  10520. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10521. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10522. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10523. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10524. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10525. if (id <= 0) //add
  10526. {
  10527. checkboxInfo.CreateUserId = dto.CurrUserId;
  10528. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10529. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10530. if (add < 1) return Ok(JsonView(false));
  10531. }
  10532. else //update
  10533. {
  10534. ////验证编辑权限
  10535. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10536. //if (!isEdit) return Ok(JsonView(false, msg));
  10537. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10538. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  10539. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  10540. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10541. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10542. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10543. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10544. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10545. .Where(x => x.Id == id)
  10546. .ExecuteCommandAsync();
  10547. if (upd < 1) return Ok(JsonView(false));
  10548. }
  10549. return Ok(JsonView(new { parentId = id }));
  10550. }
  10551. /// <summary>
  10552. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10553. /// </summary>
  10554. /// <returns></returns>
  10555. [HttpPost]
  10556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10557. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10558. {
  10559. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10560. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10561. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10562. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10563. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10564. info.FirstItemRemark = dto.FirstItemRemark;
  10565. info.LastUpdateUserId = dto.CurrUserId;
  10566. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10567. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10568. int id = dto.Id;
  10569. if (id <= 0) //add
  10570. {
  10571. info.CreateUserId = dto.CurrUserId;
  10572. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10573. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10574. if (add < 1) return Ok(JsonView(false));
  10575. id = add;
  10576. }
  10577. else //update
  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 upd = await _sqlSugar.Updateable(info)
  10583. .UpdateColumns(x => new
  10584. {
  10585. x.ChoiceOne,
  10586. x.InsidePay,
  10587. x.VisaRemark,
  10588. x.Visa,
  10589. x.Service,
  10590. x.Safe,
  10591. x.Ticket,
  10592. x.HeSuan,
  10593. x.YiMiao,
  10594. x.FirstItemRemark,
  10595. x.LastUpdateUserId,
  10596. x.LastUpdateTime
  10597. })
  10598. .Where(x => x.Id == id)
  10599. .ExecuteCommandAsync();
  10600. if (upd < 1) return Ok(JsonView(false));
  10601. }
  10602. //消息通知
  10603. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10604. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10605. }
  10606. /// <summary>
  10607. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10608. /// </summary>
  10609. /// <returns></returns>
  10610. [HttpPost]
  10611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10612. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10613. {
  10614. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10615. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10616. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10617. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10618. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10619. info.DiId = dto.DiId;
  10620. //info.ProvinceId = dto.ProvinceId;
  10621. info.OutsideJJPay = dto.OutsideJJPay;
  10622. info.OutsideGWPay = dto.OutsideGWPay;
  10623. info.OutsideTDPay = dto.OutsideTDPay;
  10624. info.AirJJ = dto.AirJJ;
  10625. info.AirGW = dto.AirGW;
  10626. info.AirTD = dto.AirTD;
  10627. info.CityTranffic = dto.CityTranffic;
  10628. info.TwoItemRemark = dto.TwoItemRemark;
  10629. info.SumJJC = dto.ChoiceTwoJJ;
  10630. info.SumGWC = dto.ChoiceTwoGW;
  10631. info.SumTDC = dto.ChoiceTwoTD;
  10632. info.LastUpdateUserId = dto.CurrUserId;
  10633. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10634. int id = dto.Id;
  10635. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10636. if (id <= 0) //add i
  10637. {
  10638. info.CreateUserId = dto.CurrUserId;
  10639. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10640. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10641. if (addId <= 0) return Ok(JsonView(false));
  10642. id = addId;
  10643. }
  10644. else //update
  10645. {
  10646. ////验证编辑权限
  10647. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10648. //if (!isEdit) return Ok(JsonView(false, msg));
  10649. var upd = await _sqlSugar.Updateable(info)
  10650. .UpdateColumns(x => new
  10651. {
  10652. x.SumJJC,
  10653. x.OutsideJJPay,
  10654. x.SumGWC,
  10655. x.OutsideGWPay,
  10656. x.SumTDC,
  10657. x.OutsideTDPay,
  10658. x.AirJJ,
  10659. x.AirGW,
  10660. x.AirTD,
  10661. x.CityTranffic,
  10662. x.TwoItemRemark,
  10663. x.LastUpdateTime,
  10664. x.LastUpdateUserId
  10665. })
  10666. .Where(x => x.Id == id)
  10667. .ExecuteCommandAsync();
  10668. if (upd < 1) return Ok(JsonView(false));
  10669. }
  10670. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10671. gwcItemTotal = info.AirGW + info.CityTranffic;
  10672. tdcItemTotal = info.AirTD + info.CityTranffic;
  10673. //消息通知
  10674. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10675. return Ok(JsonView(new
  10676. {
  10677. parentId = id,
  10678. choiceTwoJJ = dto.ChoiceTwoJJ,
  10679. jjcItemTotal = jjcItemTotal,
  10680. choiceTwoGW = dto.ChoiceTwoGW,
  10681. gwcItemTotal = gwcItemTotal,
  10682. choiceTwoTD = dto.ChoiceTwoTD,
  10683. tdcItemTotal = tdcItemTotal
  10684. }));
  10685. }
  10686. /// <summary>
  10687. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10688. /// </summary>
  10689. /// <returns></returns>
  10690. [HttpPost]
  10691. [ApiExplorerSettings(IgnoreApi = true)]
  10692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10693. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10694. {
  10695. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10696. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10697. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10698. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10699. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10700. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10701. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10702. var infos = infos1.Select(x => new Grp_DayAndCost
  10703. {
  10704. Id = x.Id,
  10705. DiId = dto.DiId,
  10706. Type = dto.FeeType,
  10707. Days = x.Days,
  10708. NationalTravelFeeId = x.NationalTravelFeeId,
  10709. Cost = x.Cost,
  10710. Currency = x.Currency,
  10711. SubTotal = x.SubTotal,
  10712. CreateUserId = dto.CurrUserId
  10713. })
  10714. .ToList();
  10715. var adds = infos.Where(x => x.Id <= 0).ToList();
  10716. var upds = infos.Where(x => x.Id > 0).ToList();
  10717. if (adds.Count > 0)
  10718. {
  10719. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10720. if (add < 1) return Ok(JsonView(false));
  10721. }
  10722. if (upds.Count > 0)
  10723. {
  10724. var upd = await _sqlSugar.Updateable(adds)
  10725. .UpdateColumns(x => new
  10726. {
  10727. x.Days,
  10728. x.NationalTravelFeeId,
  10729. x.Cost,
  10730. x.Currency,
  10731. x.SubTotal
  10732. })
  10733. .WhereColumns(x => new { x.Id })
  10734. .ExecuteCommandAsync();
  10735. if (upd < 1) return Ok(JsonView(false));
  10736. }
  10737. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10738. //消息通知
  10739. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10740. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10741. return Ok(JsonView(new { itemTotal = itemTotal }));
  10742. }
  10743. /// <summary>
  10744. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10745. /// </summary>
  10746. /// <returns></returns>
  10747. [HttpPost]
  10748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10749. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10750. {
  10751. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10752. int subId = dto.SubId, feeType = dto.FeeType;
  10753. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10754. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10755. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10756. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10757. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10758. subInfo.Id = subId;
  10759. subInfo.DiId = dto.DiId;
  10760. if (feeType == 3) subInfo.Type = 1;
  10761. else if (feeType == 4) subInfo.Type = 2;
  10762. else if (feeType == 5) subInfo.Type = 3;
  10763. else if (feeType == 6) subInfo.Type = 4;
  10764. subInfo.CreateUserId = dto.CurrUserId;
  10765. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10766. if (parentId < 1) return Ok(JsonView(false));
  10767. //子表op
  10768. if (subId < 1)
  10769. {
  10770. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10771. if (subAdd < 1) return Ok(JsonView(false));
  10772. }
  10773. else
  10774. {
  10775. ////验证编辑权限
  10776. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10777. //if (!isEdit) return Ok(JsonView(false, msg));
  10778. var subUpd = await _sqlSugar.Updateable(subInfo)
  10779. .UpdateColumns(x => new
  10780. {
  10781. x.Days,
  10782. x.NationalTravelFeeId,
  10783. x.Cost,
  10784. x.Currency,
  10785. x.SubTotal
  10786. })
  10787. .WhereColumns(x => new { x.Id })
  10788. .ExecuteCommandAsync();
  10789. if (subUpd < 1) return Ok(JsonView(false));
  10790. }
  10791. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10792. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10793. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10794. }
  10795. /// <summary>
  10796. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10797. /// </summary>
  10798. /// <returns></returns>
  10799. [HttpPost]
  10800. [ApiExplorerSettings(IgnoreApi = true)]
  10801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10802. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10803. {
  10804. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10805. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10806. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10807. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10808. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10809. {
  10810. Id = x.Id,
  10811. Diid = dto.DiId,
  10812. SetDataId = x.SetDataId,
  10813. Index = x.Index,
  10814. Cost = x.Cost,
  10815. Currency = x.Currency,
  10816. SubTotal = x.SubTotal,
  10817. CreateUserId = dto.CurrUserId,
  10818. Remark = x.Remark
  10819. }).ToList();
  10820. var adds = infos.Where(x => x.Id <= 0).ToList();
  10821. var upds = infos.Where(x => x.Id > 0).ToList();
  10822. if (adds.Count > 0)
  10823. {
  10824. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10825. if (add < 1) return Ok(JsonView(false));
  10826. }
  10827. if (upds.Count > 0)
  10828. {
  10829. var upd = await _sqlSugar.Updateable(adds)
  10830. .UpdateColumns(x => new
  10831. {
  10832. x.Index,
  10833. x.SetDataId,
  10834. x.Cost,
  10835. x.Currency,
  10836. x.SubTotal,
  10837. x.Remark
  10838. })
  10839. .WhereColumns(x => new { x.Id })
  10840. .ExecuteCommandAsync();
  10841. if (upd < 1) return Ok(JsonView(false));
  10842. }
  10843. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10844. //消息通知
  10845. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10846. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10847. return Ok(JsonView(new { itemTotal = itemTotal }));
  10848. }
  10849. /// <summary>
  10850. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10851. /// </summary>
  10852. /// <returns></returns>
  10853. [HttpPost]
  10854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10855. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10856. {
  10857. int subId = dto.SubId;
  10858. int diId = dto.Diid;
  10859. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10860. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10861. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10862. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10863. subInfo.Id = subId;
  10864. subInfo.Diid = dto.Diid;
  10865. subInfo.CreateUserId = dto.CurrUserId;
  10866. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10867. if (parentId < 1) return Ok(JsonView(false));
  10868. #region 子表op
  10869. if (subId < 1)//add
  10870. {
  10871. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10872. if (subAdd < 1) return Ok(JsonView(false));
  10873. }
  10874. else //upd
  10875. {
  10876. ////验证编辑权限
  10877. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10878. //if (!isEdit) return Ok(JsonView(false, msg));
  10879. var subUpd = await _sqlSugar.Updateable(subInfo)
  10880. .UpdateColumns(x => new
  10881. {
  10882. x.Index,
  10883. x.SetDataId,
  10884. x.Cost,
  10885. x.Currency,
  10886. x.SubTotal,
  10887. x.Remark
  10888. })
  10889. .WhereColumns(x => new { x.Id })
  10890. .ExecuteCommandAsync();
  10891. if (subUpd < 1) return Ok(JsonView(false));
  10892. }
  10893. #endregion
  10894. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10895. //消息通知
  10896. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10897. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10898. }
  10899. /// <summary>
  10900. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10901. /// </summary>
  10902. /// <returns></returns>
  10903. [HttpPost]
  10904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10905. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10906. {
  10907. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10908. if (data.Code != 0)
  10909. {
  10910. return Ok(JsonView(false, data.Msg));
  10911. }
  10912. return Ok(JsonView(true, "操作成功!", data.Data));
  10913. }
  10914. /// <summary>
  10915. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10916. /// </summary>
  10917. /// <param name="dto"></param>
  10918. /// <returns></returns>
  10919. [HttpPost]
  10920. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10921. {
  10922. var data = new Grp_DayOtherPrice()
  10923. {
  10924. Id = dto.Id,
  10925. IsDel = 1,
  10926. DeleteUserId = dto.DeleteUserId,
  10927. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10928. };
  10929. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10930. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10931. return Ok(JsonView(false, "删除失败!"));
  10932. }
  10933. #endregion
  10934. #endregion
  10935. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10936. /// <summary>
  10937. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10938. /// </summary>
  10939. /// <returns></returns>
  10940. [HttpGet]
  10941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10942. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10943. {
  10944. var provData = await _groupRepository.ProvinceBasicSource();
  10945. return Ok(JsonView(true, "查询成功!", provData));
  10946. }
  10947. /// <summary>
  10948. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10949. /// </summary>
  10950. /// <returns></returns>
  10951. [HttpPost]
  10952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10953. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10954. {
  10955. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10956. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10957. RefAsync<int> total = 0;
  10958. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10959. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10960. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10961. .Select(x => new
  10962. {
  10963. Id = x.Id,
  10964. DraftName = x.DraftName,
  10965. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10966. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10967. .Any()
  10968. })
  10969. .OrderByDescending(x => x.Id)
  10970. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10971. return Ok(JsonView(true, "查询成功!", data, total));
  10972. }
  10973. /// <summary>
  10974. /// 出入境费用-草稿 移动端
  10975. /// 获取币种基础数据(含逻辑处理)
  10976. /// </summary>
  10977. /// <returns></returns>
  10978. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10979. {
  10980. return await GeneralMethod.EnterExitCostInitRate();
  10981. }
  10982. /// <summary>
  10983. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10984. /// </summary>
  10985. /// <returns></returns>
  10986. [HttpPost]
  10987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10988. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10989. {
  10990. //验证城市归属并给默认值
  10991. int provinceId = dto.ProvinceId;
  10992. if (provinceId < 1) provinceId = 122;
  10993. var dataSource = await _sqlSugar
  10994. .Queryable<Sys_SetData>()
  10995. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10996. .ToListAsync();
  10997. //三公费用-Word明细类型
  10998. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10999. .Select(x => new SetDataInfoView
  11000. {
  11001. Id = x.Id,
  11002. Name = x.Name,
  11003. Remark = x.Remark
  11004. })
  11005. .ToList();
  11006. //三公费用-Excel明细类型
  11007. var excelTypeData = dataSource.Where(it => it.STid == 73)
  11008. .Select(x => new SetDataInfoView
  11009. {
  11010. Id = x.Id,
  11011. Name = x.Name,
  11012. Remark = x.Remark
  11013. })
  11014. .ToList();
  11015. //默认币种显示
  11016. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  11017. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  11018. return Ok(JsonView(true, "查询成功!", new
  11019. {
  11020. WordTypeData = wordTypeData,
  11021. ExcelTypeData = excelTypeData,
  11022. CurrencyInit = _currencyInfos,
  11023. viewPermissionData = viewPermissionData
  11024. }));
  11025. }
  11026. /// <summary>
  11027. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  11028. /// </summary>
  11029. /// <returns></returns>
  11030. [HttpPost]
  11031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11032. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  11033. {
  11034. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11035. RefAsync<int> total = 0;
  11036. int diId = 0;
  11037. var status = int.TryParse(dto.GroupName, out diId);
  11038. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  11039. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  11040. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  11041. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  11042. .OrderByDescending(x => x.VisitStartDate)
  11043. .Select(x => new
  11044. {
  11045. Id = x.Id,
  11046. GroupName = x.TeamName
  11047. })
  11048. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11049. return Ok(JsonView(true, "查询成功!", data, total));
  11050. }
  11051. /// <summary>
  11052. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  11053. /// </summary>
  11054. /// <returns></returns>
  11055. [HttpPost]
  11056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11057. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  11058. {
  11059. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11060. RefAsync<int> total = 0;
  11061. var data = await _sqlSugar.Queryable<Sys_SetData>()
  11062. .Where(x => x.IsDel == 0 && x.STid == 66)
  11063. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  11064. .Select(x => new
  11065. {
  11066. id = x.Id,
  11067. name = x.Name,
  11068. remark = x.Remark,
  11069. })
  11070. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11071. return Ok(JsonView(true, "查询成功!", data, total));
  11072. }
  11073. /// <summary>
  11074. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  11075. /// </summary>
  11076. /// <returns></returns>
  11077. [HttpPost]
  11078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11079. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  11080. {
  11081. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11082. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11083. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  11084. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  11085. var groupOtherRateData = groupRateData.TeamRates;
  11086. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11087. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  11088. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  11089. groupOtherRateData = groupOtherRateData
  11090. .Select(x => new TeamRateDescAddCurrencyIdView
  11091. {
  11092. CurrencyId = x.CurrencyId,
  11093. CurrencyName = x.CurrencyName,
  11094. CurrencyCode = x.CurrencyCode,
  11095. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  11096. }).ToList();
  11097. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  11098. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  11099. }
  11100. /// <summary>
  11101. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  11102. /// </summary>
  11103. /// <returns></returns>
  11104. [HttpPost]
  11105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11106. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  11107. {
  11108. int portType = dto.PortType;
  11109. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11110. var tipsData = new List<int>() { 1, 2, 3 };
  11111. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  11112. if (dto.TipsType == 1)
  11113. {
  11114. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  11115. }
  11116. else if (dto.TipsType == 2)
  11117. {
  11118. if (portType == 2)
  11119. {
  11120. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11121. }
  11122. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11123. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11124. .Select(x => x.NationalTravelFeeId)
  11125. .Distinct()
  11126. .ToListAsync();
  11127. if (portType == 2)
  11128. {
  11129. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11130. }
  11131. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11132. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11133. .Select(x => x.Country)
  11134. .Distinct()
  11135. .ToArrayAsync();
  11136. if (portType == 2)
  11137. {
  11138. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11139. }
  11140. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11141. return Ok(JsonView(true, "查询成功!", new
  11142. {
  11143. totalAmt = totalAmt,
  11144. remark = remark
  11145. }));
  11146. }
  11147. else if (dto.TipsType == 3)
  11148. {
  11149. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  11150. }
  11151. return Ok(JsonView(false));
  11152. }
  11153. /// <summary>
  11154. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  11155. /// </summary>
  11156. /// <returns></returns>
  11157. [HttpPost]
  11158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11159. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  11160. {
  11161. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  11162. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11163. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11164. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  11165. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  11166. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  11167. var info = new Grp_EnterExitCostDraft()
  11168. {
  11169. ProvinceId = dto.ProvinceId,
  11170. DraftName = dto.DraftName,
  11171. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  11172. CreateUserId = dto.CurrUserId
  11173. };
  11174. _sqlSugar.BeginTran();
  11175. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11176. if (draftId < 1)
  11177. {
  11178. _sqlSugar.RollbackTran();
  11179. return Ok(JsonView(false, "草稿创建失败!"));
  11180. }
  11181. //添加默认权限
  11182. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  11183. _sqlSugar.CommitTran();
  11184. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  11185. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11186. mobileInfo.Id = draftId;
  11187. mobileInfo.DraftName = dto.DraftName;
  11188. mobileInfo.Currencys = rateInfos;
  11189. mobileInfo.IsAssignPerm = assignPerm;
  11190. return Ok(JsonView(mobileInfo));
  11191. }
  11192. /// <summary>
  11193. /// 出入境费用-草稿-移动端 查看编辑提示消息
  11194. /// </summary>
  11195. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  11196. /// <summary>
  11197. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  11198. /// </summary>
  11199. /// <returns></returns>
  11200. [HttpPost]
  11201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11202. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  11203. {
  11204. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11205. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11206. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11207. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11208. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  11209. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  11210. //验证查看编辑权限
  11211. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11212. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11213. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  11214. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  11215. mobileInfo.IsAssignPerm = assignPerm;
  11216. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11217. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11218. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11219. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11220. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11221. {
  11222. ParentId = dac.ParentId,
  11223. SubId = dac.Id,
  11224. Type = dac.Type,
  11225. Days = dac.Days,
  11226. NationalTravelFeeId = dac.NationalTravelFeeId,
  11227. Arae = $"{ntf.Country}-{ntf.City}",
  11228. Cost = dac.Cost,
  11229. Currency = dac.Currency,
  11230. CurrencyName = sd.Name,
  11231. SubTotal = dac.SubTotal,
  11232. })
  11233. .ToList();
  11234. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  11235. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  11236. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  11237. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  11238. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  11239. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  11240. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  11241. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  11242. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  11243. //其他款项
  11244. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11245. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11246. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11247. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11248. .OrderBy((dop, sd1, sd2) => dop.Index)
  11249. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11250. {
  11251. ParentId = dop.ParentId,
  11252. SubId = dop.Id,
  11253. Index = dop.Index,
  11254. SetDataId = dop.SetDataId,
  11255. SetDataName = sd1.Name,
  11256. Cost = dop.Cost,
  11257. Currency = dop.Currency,
  11258. CurrencyName = sd2.Remark,
  11259. SubTotal = dop.SubTotal,
  11260. Remark = dop.Remark,
  11261. })
  11262. .ToArray();
  11263. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  11264. return Ok(mobileInfo);
  11265. }
  11266. /// <summary>
  11267. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  11268. /// </summary>
  11269. /// <returns></returns>
  11270. [HttpPost]
  11271. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11272. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  11273. {
  11274. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11275. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11276. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11277. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  11278. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  11279. //验证查看编辑权限
  11280. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11281. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11282. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11283. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  11284. var subType = dto.SubType;
  11285. if (subType == 1) //1:境内费用
  11286. {
  11287. var oneData = new ChoiceOneMobileSubInfoView()
  11288. {
  11289. Id = eecInfo.Id,
  11290. ChoiceOne = eecInfo.ChoiceOne,
  11291. ChoiceOneTotalCost = eecInfo.InsidePay,
  11292. Visa = eecInfo.Visa,
  11293. VisaRemark = eecInfo.VisaRemark,
  11294. YiMiao = eecInfo.YiMiao,
  11295. HeSuan = eecInfo.HeSuan,
  11296. Service = eecInfo.Service,
  11297. Ticket = eecInfo.Ticket,
  11298. Safe = eecInfo.Safe,
  11299. FirstItemRemark = eecInfo.FirstItemRemark
  11300. };
  11301. return Ok(JsonView(oneData));
  11302. }
  11303. else if (subType == 2) //2:国际旅费
  11304. {
  11305. var twoData = new ChoiceTwoMobileSubInfoView()
  11306. {
  11307. Id = eecInfo.Id,
  11308. ChoiceTwoJJ = eecInfo.SumJJC,
  11309. OutsideJJPay = eecInfo.OutsideJJPay,
  11310. ChoiceTwoGW = eecInfo.SumGWC,
  11311. OutsideGWPay = eecInfo.OutsideGWPay,
  11312. ChoiceTwoTD = eecInfo.SumTDC,
  11313. OutsideTDPay = eecInfo.OutsideTDPay,
  11314. AirJJ = eecInfo.AirJJ,
  11315. AirGW = eecInfo.AirGW,
  11316. AirTD = eecInfo.AirTD,
  11317. CityTranffic = eecInfo.CityTranffic,
  11318. TwoItemRemark = eecInfo.TwoItemRemark
  11319. };
  11320. return Ok(JsonView(twoData));
  11321. }
  11322. else if (subType == 3) //3:住宿费
  11323. {
  11324. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11325. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11326. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11327. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11328. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11329. {
  11330. ParentId = dac.ParentId,
  11331. SubId = dac.Id,
  11332. Type = dac.Type,
  11333. Days = dac.Days,
  11334. NationalTravelFeeId = dac.NationalTravelFeeId,
  11335. Arae = $"{ntf.Country}-{ntf.City}",
  11336. Cost = dac.Cost,
  11337. Currency = dac.Currency,
  11338. CurrencyName = sd.Name,
  11339. SubTotal = dac.SubTotal,
  11340. })
  11341. .ToArray();
  11342. var data = new ChoiceDraftMobileSubInfo3To6View()
  11343. {
  11344. ParentId = eecInfo.Id,
  11345. Choice = eecInfo.ChoiceThree,
  11346. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11347. Details = dayAndCostDatas
  11348. };
  11349. return Ok(JsonView(data));
  11350. }
  11351. else if (subType == 4) //4:伙食费
  11352. {
  11353. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11354. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11355. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11356. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  11357. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11358. {
  11359. ParentId = dac.ParentId,
  11360. SubId = dac.Id,
  11361. Type = dac.Type,
  11362. Days = dac.Days,
  11363. NationalTravelFeeId = dac.NationalTravelFeeId,
  11364. Arae = $"{ntf.Country}-{ntf.City}",
  11365. Cost = dac.Cost,
  11366. Currency = dac.Currency,
  11367. CurrencyName = sd.Name,
  11368. SubTotal = dac.SubTotal,
  11369. })
  11370. .ToArray();
  11371. var data = new ChoiceDraftMobileSubInfo3To6View()
  11372. {
  11373. ParentId = eecInfo.Id,
  11374. Choice = eecInfo.ChoiceFour,
  11375. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11376. Details = dayAndCostDatas
  11377. };
  11378. return Ok(JsonView(data));
  11379. }
  11380. else if (subType == 5) //5:公杂费
  11381. {
  11382. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11383. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11384. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11385. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  11386. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11387. {
  11388. ParentId = dac.ParentId,
  11389. SubId = dac.Id,
  11390. Type = dac.Type,
  11391. Days = dac.Days,
  11392. NationalTravelFeeId = dac.NationalTravelFeeId,
  11393. Arae = $"{ntf.Country}-{ntf.City}",
  11394. Cost = dac.Cost,
  11395. Currency = dac.Currency,
  11396. CurrencyName = sd.Name,
  11397. SubTotal = dac.SubTotal,
  11398. })
  11399. .ToArray();
  11400. var data = new ChoiceDraftMobileSubInfo3To6View()
  11401. {
  11402. ParentId = eecInfo.Id,
  11403. Choice = eecInfo.ChoiceFive,
  11404. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11405. Details = dayAndCostDatas
  11406. };
  11407. return Ok(JsonView(data));
  11408. }
  11409. else if (subType == 6) //6:培训费
  11410. {
  11411. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11412. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11413. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11414. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  11415. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11416. {
  11417. ParentId = dac.ParentId,
  11418. SubId = dac.Id,
  11419. Type = dac.Type,
  11420. Days = dac.Days,
  11421. NationalTravelFeeId = dac.NationalTravelFeeId,
  11422. Arae = $"{ntf.Country}-{ntf.City}",
  11423. Cost = dac.Cost,
  11424. Currency = dac.Currency,
  11425. CurrencyName = sd.Name,
  11426. SubTotal = dac.SubTotal,
  11427. })
  11428. .ToArray();
  11429. var data = new ChoiceDraftMobileSubInfo3To6View()
  11430. {
  11431. ParentId = eecInfo.Id,
  11432. Choice = eecInfo.ChoiceSix,
  11433. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11434. Details = dayAndCostDatas
  11435. };
  11436. return Ok(JsonView(data));
  11437. }
  11438. else if (subType == 7) //7:其他
  11439. {
  11440. //其他款项
  11441. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11442. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11443. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11444. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11445. .OrderBy((dop, sd1, sd2) => dop.Index)
  11446. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11447. {
  11448. ParentId = dop.ParentId,
  11449. SubId = dop.Id,
  11450. Index = dop.Index,
  11451. SetDataId = dop.SetDataId,
  11452. SetDataName = sd1.Name,
  11453. Cost = dop.Cost,
  11454. Currency = dop.Currency,
  11455. CurrencyName = sd2.Name,
  11456. SubTotal = dop.SubTotal,
  11457. Remark = dop.Remark,
  11458. })
  11459. .ToArray();
  11460. var data = new ChoiceSevenDraftMobileSubInfoView()
  11461. {
  11462. ParentId = eecInfo.Id,
  11463. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11464. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11465. Details = otherData
  11466. };
  11467. return Ok(JsonView(data));
  11468. }
  11469. return Ok(JsonView(false));
  11470. }
  11471. #region op
  11472. ///// <summary>
  11473. ///// 移动端更新费用消息通知
  11474. ///// </summary>
  11475. ///// <param name="draftId"></param>
  11476. ///// <param name="id"></param>
  11477. ///// <param name="currUserId"></param>
  11478. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11479. //{
  11480. // try
  11481. // {
  11482. // ////生成默认文件pdf并且通知人员
  11483. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11484. // //{
  11485. // // DiId = draftId,
  11486. // // ExportType = 1,
  11487. // // SubTypeId = 1005
  11488. // //}, "pdf");
  11489. // ////发送通知
  11490. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11491. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11492. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11493. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11494. // ////汇率信息记录
  11495. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11496. // }
  11497. // catch (Exception ex)
  11498. // {
  11499. // //记录日志
  11500. // throw;
  11501. // }
  11502. //}
  11503. /// <summary>
  11504. /// 验证出入境费用数据是否存在
  11505. /// 不存在添加
  11506. /// </summary>
  11507. /// <param name="draftId"></param>
  11508. /// <param name="currUserId"></param>
  11509. /// <returns></returns>
  11510. /// <exception cref="CustomException"></exception>
  11511. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11512. {
  11513. var parentId = 0;
  11514. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11515. if (info != null) parentId = info.Id;
  11516. else
  11517. {
  11518. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11519. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11520. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11521. parentId = addId;
  11522. }
  11523. return parentId;
  11524. }
  11525. /// <summary>
  11526. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11527. /// </summary>
  11528. /// <returns></returns>
  11529. [HttpPost]
  11530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11531. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11532. {
  11533. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11534. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11535. //验证查看权限
  11536. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11537. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11538. var userIds = await _sqlSugar
  11539. .Queryable<Grp_EnterExitCostDraftPermission>()
  11540. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11541. .Select(x => x.UserId)
  11542. .ToArrayAsync();
  11543. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11544. var perUsersView = new List<dynamic>();
  11545. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11546. var viewPermissionData = new List<PermissionViewUserview>();
  11547. if (feeBasePerm.Any())
  11548. {
  11549. foreach (var item in feeBasePerm)
  11550. {
  11551. if (item.Users.Any())
  11552. {
  11553. viewPermissionData.AddRange(item.Users);
  11554. }
  11555. }
  11556. }
  11557. foreach (var item in perUsers)
  11558. {
  11559. bool isView1 = false;
  11560. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11561. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11562. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11563. }
  11564. return Ok(JsonView(perUsersView));
  11565. }
  11566. /// <summary>
  11567. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11568. /// </summary>
  11569. /// <returns></returns>
  11570. [HttpPost]
  11571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11572. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11573. {
  11574. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11575. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11576. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11577. //验证查看编辑权限
  11578. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11579. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11580. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11581. foreach (var userId in dto.UserIds)
  11582. {
  11583. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11584. }
  11585. if (permissions.Any())
  11586. {
  11587. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11588. {
  11589. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11590. }
  11591. _sqlSugar.BeginTran();
  11592. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11593. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11594. if (result < 1)
  11595. {
  11596. _sqlSugar.RollbackTran();
  11597. return Ok(JsonView(false));
  11598. }
  11599. _sqlSugar.CommitTran();
  11600. return Ok(JsonView(true));
  11601. }
  11602. return Ok(JsonView(false));
  11603. }
  11604. /// <summary>
  11605. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11606. /// </summary>
  11607. /// <returns></returns>
  11608. [HttpPost]
  11609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11610. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11611. {
  11612. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11613. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11614. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11615. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11616. int id = dto.DraftId;
  11617. if (id <= 0) //add
  11618. {
  11619. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11620. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11621. if (add < 1) return Ok(JsonView(false));
  11622. id = add;
  11623. }
  11624. else //update
  11625. {
  11626. //验证查看编辑权限
  11627. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11628. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11629. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11630. if (upd < 1) return Ok(JsonView(false));
  11631. }
  11632. return Ok(JsonView(new { parentId = id }));
  11633. }
  11634. /// <summary>
  11635. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11636. /// </summary>
  11637. /// <returns></returns>
  11638. [HttpPost]
  11639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11640. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11641. {
  11642. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11643. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11644. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11645. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11646. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11647. int id = dto.DraftId;
  11648. if (id <= 0) //add
  11649. {
  11650. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11651. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11652. if (add < 1) return Ok(JsonView(false));
  11653. id = add;
  11654. }
  11655. else //update
  11656. {
  11657. //验证查看编辑权限
  11658. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11659. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11660. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11661. if (upd < 1) return Ok(JsonView(false));
  11662. }
  11663. #region 汇率变更时更改币种相关费用
  11664. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11665. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11666. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11667. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11668. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11669. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11670. .Select((dac, sd) => new
  11671. {
  11672. dac.Id,
  11673. dac.ParentId,
  11674. CurrencyCode = sd.Name,
  11675. dac.Cost
  11676. })
  11677. .ToList();
  11678. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11679. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11680. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11681. .Select((dop, sd) => new
  11682. {
  11683. dop.Id,
  11684. dop.ParentId,
  11685. CurrencyCode = sd.Name,
  11686. dop.Cost
  11687. })
  11688. .ToList();
  11689. if (dayCosts.Count > 0)
  11690. {
  11691. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11692. foreach (var dc in new_dayCosts)
  11693. {
  11694. var thisCurrency = dc.Key.ToUpper();
  11695. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11696. if (thisRate == 0.00M) continue;
  11697. foreach (var dcSub in dc)
  11698. {
  11699. opDayCosts.Add(new Grp_DayAndCostDraft()
  11700. {
  11701. Id = dcSub.Id,
  11702. ParentId = dcSub.ParentId,
  11703. Cost = dcSub.Cost,
  11704. SubTotal = dcSub.Cost * thisRate,
  11705. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11706. });
  11707. }
  11708. }
  11709. if (opDayCosts.Count > 0)
  11710. {
  11711. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11712. }
  11713. }
  11714. if (dayOtherCosts.Count > 0)
  11715. {
  11716. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11717. foreach (var dc in new_dayOtherCosts)
  11718. {
  11719. var thisCurrency = dc.Key.ToUpper();
  11720. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11721. if (thisRate == 0.00M) continue;
  11722. foreach (var dcSub in dc)
  11723. {
  11724. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11725. {
  11726. Id = dcSub.Id,
  11727. ParentId = dcSub.ParentId,
  11728. Cost = dcSub.Cost,
  11729. SubTotal = dcSub.Cost * thisRate,
  11730. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11731. });
  11732. }
  11733. }
  11734. if (opDayOtherCosts.Count > 0)
  11735. {
  11736. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11737. }
  11738. }
  11739. #endregion
  11740. ////消息通知
  11741. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11742. ////汇率信息记录
  11743. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11744. return Ok(JsonView(new { parentId = id }));
  11745. }
  11746. /// <summary>
  11747. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11748. /// </summary>
  11749. /// <returns></returns>
  11750. [HttpPost]
  11751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11752. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11753. {
  11754. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11755. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11756. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11757. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11758. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11759. int id = dto.DraftId;
  11760. if (id <= 0) //add
  11761. {
  11762. checkboxInfo.ProvinceId = dto.ProvinceId;
  11763. checkboxInfo.CreateUserId = dto.CurrUserId;
  11764. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11765. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11766. if (add < 1) return Ok(JsonView(false));
  11767. }
  11768. else //update
  11769. {
  11770. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11771. .UpdateColumns(x => new
  11772. {
  11773. x.ChoiceOne,
  11774. x.ChoiceTwo,
  11775. x.SumJJC,
  11776. x.SumGWC,
  11777. x.SumTDC,
  11778. x.ChoiceThree,
  11779. x.ChoiceFour,
  11780. x.ChoiceFive,
  11781. x.ChoiceSix,
  11782. x.OtherExpenses_Checked
  11783. })
  11784. .Where(x => x.Id == id)
  11785. .ExecuteCommandAsync();
  11786. if (upd < 1) return Ok(JsonView(false));
  11787. }
  11788. return Ok(JsonView(new { parentId = id }));
  11789. }
  11790. /// <summary>
  11791. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11792. /// </summary>
  11793. /// <returns></returns>
  11794. [HttpPost]
  11795. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11796. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11797. {
  11798. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11799. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11800. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11801. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11802. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11803. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11804. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11805. var checkboxInfo = new Grp_EnterExitCostDraft()
  11806. {
  11807. Id = draftId,
  11808. ProvinceId = dto.ProvinceId,
  11809. CreateUserId = currUserId
  11810. };
  11811. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11812. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11813. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11814. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11815. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11816. if (draftId <= 0) //add
  11817. {
  11818. checkboxInfo.CreateUserId = dto.CurrUserId;
  11819. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11820. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11821. if (add < 1) return Ok(JsonView(false));
  11822. }
  11823. else //update
  11824. {
  11825. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11826. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11827. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11828. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11829. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11830. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11831. .Where(x => x.Id == draftId)
  11832. .ExecuteCommandAsync();
  11833. if (upd < 1) return Ok(JsonView(false));
  11834. }
  11835. return Ok(JsonView(new { parentId = draftId }));
  11836. }
  11837. /// <summary>
  11838. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11839. /// </summary>
  11840. /// <returns></returns>
  11841. [HttpPost]
  11842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11843. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11844. {
  11845. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11846. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11847. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11848. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11849. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11850. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11851. info.ProvinceId = dto.ProvinceId;
  11852. info.FirstItemRemark = dto.FirstItemRemark;
  11853. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11854. if (id <= 0) //add
  11855. {
  11856. info.CreateUserId = dto.CurrUserId;
  11857. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11858. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11859. if (add < 1) return Ok(JsonView(false));
  11860. id = add;
  11861. }
  11862. else //update
  11863. {
  11864. var upd = await _sqlSugar.Updateable(info)
  11865. .UpdateColumns(x => new
  11866. {
  11867. x.ChoiceOne,
  11868. x.InsidePay,
  11869. x.VisaRemark,
  11870. x.Visa,
  11871. x.Service,
  11872. x.Safe,
  11873. x.Ticket,
  11874. x.HeSuan,
  11875. x.YiMiao,
  11876. x.FirstItemRemark
  11877. })
  11878. .Where(x => x.Id == id)
  11879. .ExecuteCommandAsync();
  11880. if (upd < 1) return Ok(JsonView(false));
  11881. }
  11882. ////消息通知
  11883. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11884. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11885. }
  11886. /// <summary>
  11887. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11888. /// </summary>
  11889. /// <returns></returns>
  11890. [HttpPost]
  11891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11892. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11893. {
  11894. int id = dto.DraftId;
  11895. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11896. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11897. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11898. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11899. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11900. info.ProvinceId = dto.ProvinceId;
  11901. info.OutsideJJPay = dto.OutsideJJPay;
  11902. info.OutsideGWPay = dto.OutsideGWPay;
  11903. info.OutsideTDPay = dto.OutsideTDPay;
  11904. info.AirJJ = dto.AirJJ;
  11905. info.AirGW = dto.AirGW;
  11906. info.AirTD = dto.AirTD;
  11907. info.CityTranffic = dto.CityTranffic;
  11908. info.TwoItemRemark = dto.TwoItemRemark;
  11909. info.SumJJC = dto.ChoiceTwoJJ;
  11910. info.SumGWC = dto.ChoiceTwoGW;
  11911. info.SumTDC = dto.ChoiceTwoTD;
  11912. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11913. if (id <= 0) //add
  11914. {
  11915. info.CreateUserId = dto.CurrUserId;
  11916. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11917. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11918. if (addId <= 0) return Ok(JsonView(false));
  11919. id = addId;
  11920. }
  11921. else //update
  11922. {
  11923. var upd = await _sqlSugar.Updateable(info)
  11924. .UpdateColumns(x => new
  11925. {
  11926. x.SumJJC,
  11927. x.OutsideJJPay,
  11928. x.SumGWC,
  11929. x.OutsideGWPay,
  11930. x.SumTDC,
  11931. x.OutsideTDPay,
  11932. x.AirJJ,
  11933. x.AirGW,
  11934. x.AirTD,
  11935. x.CityTranffic,
  11936. x.TwoItemRemark
  11937. })
  11938. .Where(x => x.Id == id)
  11939. .ExecuteCommandAsync();
  11940. if (upd < 1) return Ok(JsonView(false));
  11941. }
  11942. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11943. gwcItemTotal = info.AirGW + info.CityTranffic;
  11944. tdcItemTotal = info.AirTD + info.CityTranffic;
  11945. ////消息通知
  11946. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11947. return Ok(JsonView(new
  11948. {
  11949. parentId = id,
  11950. choiceTwoJJ = dto.ChoiceTwoJJ,
  11951. jjcItemTotal = jjcItemTotal,
  11952. choiceTwoGW = dto.ChoiceTwoGW,
  11953. gwcItemTotal = gwcItemTotal,
  11954. choiceTwoTD = dto.ChoiceTwoTD,
  11955. tdcItemTotal = tdcItemTotal
  11956. }));
  11957. }
  11958. /// <summary>
  11959. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11960. /// </summary>
  11961. /// <returns></returns>
  11962. [HttpPost]
  11963. [ApiExplorerSettings(IgnoreApi = true)]
  11964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11965. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11966. {
  11967. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11968. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11969. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11970. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11971. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11972. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11973. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11974. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11975. {
  11976. Id = x.Id,
  11977. ParentId = dto.DraftId,
  11978. Type = dto.FeeType,
  11979. Days = x.Days,
  11980. NationalTravelFeeId = x.NationalTravelFeeId,
  11981. Cost = x.Cost,
  11982. Currency = x.Currency,
  11983. SubTotal = x.SubTotal,
  11984. CreateUserId = dto.CurrUserId
  11985. })
  11986. .ToList();
  11987. var adds = infos.Where(x => x.Id <= 0).ToList();
  11988. var upds = infos.Where(x => x.Id > 0).ToList();
  11989. if (adds.Count > 0)
  11990. {
  11991. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11992. if (add < 1) return Ok(JsonView(false));
  11993. }
  11994. if (upds.Count > 0)
  11995. {
  11996. var upd = await _sqlSugar.Updateable(adds)
  11997. .UpdateColumns(x => new
  11998. {
  11999. x.Days,
  12000. x.NationalTravelFeeId,
  12001. x.Cost,
  12002. x.Currency,
  12003. x.SubTotal
  12004. })
  12005. .WhereColumns(x => new { x.Id })
  12006. .ExecuteCommandAsync();
  12007. if (upd < 1) return Ok(JsonView(false));
  12008. }
  12009. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  12010. ////消息通知
  12011. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  12012. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12013. return Ok(JsonView(new { itemTotal = itemTotal }));
  12014. }
  12015. /// <summary>
  12016. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  12017. /// </summary>
  12018. /// <returns></returns>
  12019. [HttpPost]
  12020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12021. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  12022. {
  12023. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  12024. int subId = dto.SubId, feeType = dto.FeeType;
  12025. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12026. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12027. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12028. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12029. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  12030. subInfo.Id = subId;
  12031. subInfo.ParentId = dto.DraftId;
  12032. if (feeType == 3) subInfo.Type = 1;
  12033. else if (feeType == 4) subInfo.Type = 2;
  12034. else if (feeType == 5) subInfo.Type = 3;
  12035. else if (feeType == 6) subInfo.Type = 4;
  12036. subInfo.CreateUserId = dto.CurrUserId;
  12037. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  12038. if (parentId < 1) return Ok(JsonView(false));
  12039. //子表op
  12040. if (subId < 1)
  12041. {
  12042. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12043. if (subAdd < 1) return Ok(JsonView(false));
  12044. }
  12045. else
  12046. {
  12047. var subUpd = await _sqlSugar.Updateable(subInfo)
  12048. .UpdateColumns(x => new
  12049. {
  12050. x.Days,
  12051. x.NationalTravelFeeId,
  12052. x.Cost,
  12053. x.Currency,
  12054. x.SubTotal
  12055. })
  12056. .WhereColumns(x => new { x.Id })
  12057. .ExecuteCommandAsync();
  12058. if (subUpd < 1) return Ok(JsonView(false));
  12059. }
  12060. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  12061. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12062. }
  12063. /// <summary>
  12064. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  12065. /// </summary>
  12066. /// <returns></returns>
  12067. [HttpPost]
  12068. [ApiExplorerSettings(IgnoreApi = true)]
  12069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12070. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  12071. {
  12072. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12073. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12074. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12075. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  12076. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  12077. {
  12078. Id = x.Id,
  12079. ParentId = dto.DraftId,
  12080. SetDataId = x.SetDataId,
  12081. Index = x.Index,
  12082. Cost = x.Cost,
  12083. Currency = x.Currency,
  12084. SubTotal = x.SubTotal,
  12085. CreateUserId = dto.CurrUserId,
  12086. Remark = x.Remark
  12087. }).ToList();
  12088. var adds = infos.Where(x => x.Id <= 0).ToList();
  12089. var upds = infos.Where(x => x.Id > 0).ToList();
  12090. if (adds.Count > 0)
  12091. {
  12092. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12093. if (add < 1) return Ok(JsonView(false));
  12094. }
  12095. if (upds.Count > 0)
  12096. {
  12097. var upd = await _sqlSugar.Updateable(adds)
  12098. .UpdateColumns(x => new
  12099. {
  12100. x.Index,
  12101. x.SetDataId,
  12102. x.Cost,
  12103. x.Currency,
  12104. x.SubTotal,
  12105. x.Remark
  12106. })
  12107. .WhereColumns(x => new { x.Id })
  12108. .ExecuteCommandAsync();
  12109. if (upd < 1) return Ok(JsonView(false));
  12110. }
  12111. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  12112. //消息通知
  12113. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  12114. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12115. return Ok(JsonView(new { itemTotal = itemTotal }));
  12116. }
  12117. /// <summary>
  12118. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  12119. /// </summary>
  12120. /// <returns></returns>
  12121. [HttpPost]
  12122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12123. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  12124. {
  12125. int subId = dto.SubId, id = dto.DraftId;
  12126. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12127. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  12128. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12129. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  12130. subInfo.Id = subId;
  12131. subInfo.ParentId = id;
  12132. subInfo.CreateUserId = dto.CurrUserId;
  12133. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  12134. if (parentId < 1) return Ok(JsonView(false));
  12135. #region 子表op
  12136. if (subId < 1)//add
  12137. {
  12138. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12139. if (subAdd < 1) return Ok(JsonView(false));
  12140. }
  12141. else //upd
  12142. {
  12143. var subUpd = await _sqlSugar.Updateable(subInfo)
  12144. .UpdateColumns(x => new
  12145. {
  12146. x.Index,
  12147. x.SetDataId,
  12148. x.Cost,
  12149. x.Currency,
  12150. x.SubTotal,
  12151. x.Remark
  12152. })
  12153. .WhereColumns(x => new { x.Id })
  12154. .ExecuteCommandAsync();
  12155. if (subUpd < 1) return Ok(JsonView(false));
  12156. }
  12157. #endregion
  12158. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  12159. ////消息通知
  12160. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  12161. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12162. }
  12163. /// <summary>
  12164. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  12165. /// </summary>
  12166. /// <returns></returns>
  12167. [HttpPost]
  12168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12169. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12170. {
  12171. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  12172. if (data.Code != 0)
  12173. {
  12174. return Ok(JsonView(false, data.Msg));
  12175. }
  12176. return Ok(JsonView(true, "操作成功!", data.Data));
  12177. }
  12178. /// <summary>
  12179. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  12180. /// </summary>
  12181. /// <param name="dto"></param>
  12182. /// <returns></returns>
  12183. [HttpPost]
  12184. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  12185. {
  12186. var data = new Grp_DayOtherPriceDraft()
  12187. {
  12188. Id = dto.Id,
  12189. IsDel = 1,
  12190. DeleteUserId = dto.DeleteUserId,
  12191. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12192. };
  12193. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12194. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  12195. return Ok(JsonView(false, "删除失败!"));
  12196. }
  12197. #endregion
  12198. #endregion
  12199. #region 团组经理模块 出入境费用报价表
  12200. /// <summary>
  12201. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  12202. /// </summary>
  12203. /// <returns></returns>
  12204. [HttpPost]
  12205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12206. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  12207. {
  12208. var initRates = await GeneralMethod.EnterExitCostInitRate();
  12209. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  12210. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  12211. initRates.Insert(0, cnyInfo);
  12212. liveRates.Insert(0, cnyInfo);
  12213. return Ok(JsonView(true, "查询成功!", new
  12214. {
  12215. InitRates = initRates,
  12216. LiveRates = liveRates
  12217. }));
  12218. }
  12219. /// <summary>
  12220. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  12221. /// </summary>
  12222. /// <returns></returns>
  12223. [HttpPost]
  12224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12225. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  12226. {
  12227. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  12228. }
  12229. /// <summary>
  12230. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  12231. /// </summary>
  12232. /// <returns></returns>
  12233. [HttpPost]
  12234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12235. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  12236. {
  12237. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  12238. }
  12239. /// <summary>
  12240. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  12241. /// </summary>
  12242. /// <returns></returns>
  12243. [HttpPost]
  12244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12245. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  12246. {
  12247. int groupId = dto.DiId,
  12248. currUserId = dto.CurrUserId;
  12249. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  12250. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  12251. //验证报价数据是否存在
  12252. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  12253. if (isNull != null)
  12254. {
  12255. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  12256. if (!info1.Rates.Any())
  12257. {
  12258. var rates = await GeneralMethod.EnterExitCostInitRate();
  12259. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12260. info1.Rates = rates.ToArray();
  12261. }
  12262. return Ok(JsonView(info1));
  12263. }
  12264. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  12265. result.GroupId = groupId;
  12266. //处理报价名称
  12267. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  12268. if (groupInfo != null)
  12269. {
  12270. var visitCountry = groupInfo.VisitCountry;
  12271. if (!string.IsNullOrEmpty(visitCountry))
  12272. {
  12273. string quoteName = string.Empty;
  12274. if (visitCountry.Contains("|"))
  12275. {
  12276. var countrys = visitCountry.Split("|");
  12277. quoteName = string.Join("、", countrys);
  12278. }
  12279. else quoteName = visitCountry;
  12280. quoteName += $"团组报价表";
  12281. result.Name = quoteName;
  12282. }
  12283. }
  12284. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12285. if (info.Code != StatusCodes.Status200OK)
  12286. {
  12287. if (!result.Rates.Any())
  12288. {
  12289. var rates = await GeneralMethod.EnterExitCostInitRate();
  12290. result.Rates = rates.ToArray();
  12291. }
  12292. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  12293. }
  12294. var infoView = info.Data as EnterExitCostInfoView;
  12295. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  12296. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  12297. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  12298. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  12299. var eecRates = infoView.Currencys;
  12300. //默认添加人名币
  12301. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  12302. {
  12303. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12304. }
  12305. //处理团组人数
  12306. int pplNum = 1;
  12307. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  12308. var views = new List<QuoteSubItemInfo>();
  12309. #region 数据填充
  12310. var intTravelCosts = new List<QuoteSubItemInfo>();
  12311. #region 机票费用 1354
  12312. int intTravelIndex = 1;
  12313. if (infoView.SumJJC == 1)
  12314. {
  12315. intTravelCosts.Add(new QuoteSubItemInfo
  12316. {
  12317. ItemId = 1354,
  12318. Index = intTravelIndex,
  12319. FeeName = "经济舱",
  12320. UnitPrice = infoView.AirJJ,
  12321. Currency = "CNY",
  12322. Quantity = 1,
  12323. PplNum = 1,
  12324. TotalAmt = infoView.AirJJ,
  12325. Remark = "",
  12326. });
  12327. intTravelIndex++;
  12328. }
  12329. if (infoView.SumGWC == 1)
  12330. {
  12331. intTravelCosts.Add(new QuoteSubItemInfo
  12332. {
  12333. ItemId = 1354,
  12334. Index = intTravelIndex,
  12335. FeeName = "公务舱",
  12336. UnitPrice = infoView.AirGW,
  12337. Currency = "CNY",
  12338. Quantity = 1,
  12339. PplNum = 1,
  12340. TotalAmt = infoView.AirGW,
  12341. Remark = "",
  12342. });
  12343. intTravelIndex++;
  12344. }
  12345. if (infoView.SumTDC == 1)
  12346. {
  12347. intTravelCosts.Add(new QuoteSubItemInfo
  12348. {
  12349. ItemId = 1354,
  12350. Index = intTravelIndex,
  12351. FeeName = "头等舱",
  12352. UnitPrice = infoView.AirTD,
  12353. Currency = "CNY",
  12354. Quantity = 1,
  12355. PplNum = 1,
  12356. TotalAmt = infoView.AirTD,
  12357. Remark = "",
  12358. });
  12359. intTravelIndex++;
  12360. }
  12361. intTravelCosts.Add(new QuoteSubItemInfo
  12362. {
  12363. ItemId = 1354,
  12364. Index = intTravelIndex,
  12365. FeeName = "城市间交通费用",
  12366. UnitPrice = infoView.CityTranffic,
  12367. Currency = "CNY",
  12368. Quantity = 1,
  12369. PplNum = pplNum,
  12370. TotalAmt = infoView.CityTranffic * pplNum,
  12371. Remark = "",
  12372. });
  12373. views.AddRange(intTravelCosts);
  12374. #endregion
  12375. var accomCosts = new List<QuoteSubItemInfo>();
  12376. #region 住宿费 1355
  12377. if (infoView.QuarterageData.Any())
  12378. {
  12379. int accomIndex = 1;
  12380. int accomItemTypeId = 1355;
  12381. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  12382. foreach (var item in groupData)
  12383. {
  12384. string feeName = string.Empty;
  12385. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12386. if (countryInfo != null)
  12387. {
  12388. feeName = countryInfo.Country;
  12389. var city = countryInfo.City;
  12390. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12391. {
  12392. feeName += $"-{city}";
  12393. }
  12394. }
  12395. var hotelInfo = item.FirstOrDefault();
  12396. if (hotelInfo == null) continue;
  12397. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  12398. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12399. int quantity = item.ToList().Count;
  12400. accomCosts.Add(new QuoteSubItemInfo
  12401. {
  12402. ItemId = accomItemTypeId,
  12403. Index = accomIndex,
  12404. FeeName = feeName,
  12405. UnitPrice = hotelInfo.Cost,
  12406. Currency = thisCurrency,
  12407. Quantity = quantity,
  12408. PplNum = pplNum,
  12409. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  12410. Remark = "",
  12411. });
  12412. accomIndex++;
  12413. }
  12414. views.AddRange(accomCosts);
  12415. }
  12416. #endregion
  12417. var mealCosts = new List<QuoteSubItemInfo>();
  12418. #region 餐饮费 1356
  12419. if (infoView.BoardWagesData.Any())
  12420. {
  12421. var mealIndex = 1;
  12422. int mealItemTypeId = 1356;
  12423. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12424. foreach (var item in groupData)
  12425. {
  12426. string feeName = string.Empty;
  12427. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12428. if (countryInfo != null)
  12429. {
  12430. feeName = countryInfo.Country;
  12431. var city = countryInfo.City;
  12432. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12433. {
  12434. feeName += $"-{city}";
  12435. }
  12436. }
  12437. var mealInfo = item.FirstOrDefault();
  12438. if (mealInfo == null) continue;
  12439. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12440. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12441. int quantity = item.ToList().Count;
  12442. mealCosts.Add(new QuoteSubItemInfo
  12443. {
  12444. ItemId = mealItemTypeId,
  12445. Index = mealIndex,
  12446. FeeName = feeName,
  12447. UnitPrice = mealInfo.Cost,
  12448. Currency = thisCurrency,
  12449. Quantity = quantity,
  12450. PplNum = pplNum,
  12451. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12452. Remark = "",
  12453. });
  12454. mealIndex++;
  12455. }
  12456. views.AddRange(mealCosts);
  12457. }
  12458. #endregion
  12459. var miscCosts = new List<QuoteSubItemInfo>();
  12460. #region 公杂费 1364
  12461. if (infoView.MiscellaneousFeeData.Any())
  12462. {
  12463. var miscIndex = 1;
  12464. int miscItemTypeId = 1364;
  12465. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12466. foreach (var item in groupData)
  12467. {
  12468. string feeName = string.Empty;
  12469. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12470. if (countryInfo != null)
  12471. {
  12472. feeName = countryInfo.Country;
  12473. var city = countryInfo.City;
  12474. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12475. {
  12476. feeName += $"-{city}";
  12477. }
  12478. }
  12479. var miscInfo = item.FirstOrDefault();
  12480. if (miscInfo == null) continue;
  12481. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12482. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12483. int quantity = item.ToList().Count;
  12484. miscCosts.Add(new QuoteSubItemInfo
  12485. {
  12486. ItemId = miscItemTypeId,
  12487. Index = miscIndex,
  12488. FeeName = feeName,
  12489. UnitPrice = miscInfo.Cost,
  12490. Currency = thisCurrency,
  12491. Quantity = quantity,
  12492. PplNum = pplNum,
  12493. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12494. Remark = "",
  12495. });
  12496. miscIndex++;
  12497. }
  12498. views.AddRange(miscCosts);
  12499. }
  12500. #endregion
  12501. #region 签证+保险 1362
  12502. int visaInsIndex = 1;
  12503. int visaInsItemTypeId = 1362;
  12504. if (infoView.Visa > 0)
  12505. {
  12506. views.Add(new QuoteSubItemInfo()
  12507. {
  12508. ItemId = visaInsItemTypeId,
  12509. Index = visaInsIndex,
  12510. FeeName = $"签证",
  12511. UnitPrice = infoView.Visa,
  12512. Currency = $"CNY",
  12513. Quantity = 1,
  12514. PplNum = pplNum,
  12515. TotalAmt = infoView.Visa * pplNum,
  12516. Remark = "",
  12517. });
  12518. visaInsIndex++;
  12519. }
  12520. if (infoView.Safe > 0)
  12521. {
  12522. views.Add(new QuoteSubItemInfo()
  12523. {
  12524. ItemId = visaInsItemTypeId,
  12525. Index = visaInsIndex,
  12526. FeeName = $"保险",
  12527. UnitPrice = infoView.Safe,
  12528. Currency = $"CNY",
  12529. Quantity = 1,
  12530. PplNum = pplNum,
  12531. TotalAmt = infoView.Safe * pplNum,
  12532. Remark = "",
  12533. });
  12534. }
  12535. #endregion
  12536. #region 服务费 1363
  12537. int serviceFeeIndex = 1;
  12538. int serviceFeeItemTypeId = 1363;
  12539. if (infoView.Service > 0)
  12540. {
  12541. views.Add(new QuoteSubItemInfo()
  12542. {
  12543. ItemId = serviceFeeItemTypeId,
  12544. Index = serviceFeeIndex,
  12545. FeeName = $"服务费",
  12546. UnitPrice = infoView.Service,
  12547. Currency = $"CNY",
  12548. Quantity = 1,
  12549. PplNum = pplNum,
  12550. TotalAmt = infoView.Service * pplNum,
  12551. Remark = "",
  12552. });
  12553. }
  12554. #endregion
  12555. #endregion
  12556. if (result.FeeItems.Any())
  12557. {
  12558. result.FeeItems.Select(x =>
  12559. {
  12560. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12561. if (feeInfos.Any()) x.Infos = feeInfos;
  12562. return x;
  12563. }
  12564. ).OrderBy(x => x.Index)
  12565. .ToList();
  12566. if (!result.Rates.Any())
  12567. {
  12568. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12569. else
  12570. {
  12571. var rates = await GeneralMethod.EnterExitCostInitRate();
  12572. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12573. result.Rates = rates.ToArray();
  12574. }
  12575. }
  12576. }
  12577. return Ok(JsonView(result));
  12578. }
  12579. /// <summary>
  12580. /// 团组模块 - 出入境费用报价表 - Info
  12581. /// </summary>
  12582. /// <returns></returns>
  12583. [HttpPost]
  12584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12585. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12586. {
  12587. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12588. if (!info.Rates.Any())
  12589. {
  12590. var rates = await GeneralMethod.EnterExitCostInitRate();
  12591. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12592. info.Rates = rates.ToArray();
  12593. }
  12594. return Ok(JsonView(info));
  12595. }
  12596. /// <summary>
  12597. /// 团组模块 - 出入境费用报价表 - OP
  12598. /// </summary>
  12599. /// <returns></returns>
  12600. [HttpPost]
  12601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12602. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12603. {
  12604. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12605. }
  12606. /// <summary>
  12607. /// 团组模块 - 出入境费用报价表 - 删除 项
  12608. /// </summary>
  12609. /// <returns></returns>
  12610. [HttpPost]
  12611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12612. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12613. {
  12614. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12615. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12616. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12617. }
  12618. /// <summary>
  12619. /// 团组模块 - 出入境费用报价表 - 导出
  12620. /// </summary>
  12621. /// <returns></returns>
  12622. [HttpPost]
  12623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12624. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12625. {
  12626. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12627. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12628. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12629. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12630. var rates = info.Rates;
  12631. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12632. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12633. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12634. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12635. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12636. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12637. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12638. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12639. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12640. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12641. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12642. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12643. //获取模板
  12644. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12645. var designer = new WorkbookDesigner();
  12646. designer.Workbook = new Workbook(tempPath);
  12647. designer.SetDataSource("QuoteName", info.Name);
  12648. designer.SetDataSource("CompanyTitle", "公司名称");
  12649. designer.SetDataSource("CompanyLabel", "");
  12650. #region 国际旅费
  12651. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12652. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12653. {
  12654. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12655. var label = new StringBuilder();
  12656. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12657. if (infos.Any())
  12658. {
  12659. label.Append(infos.Sum(x => x.PplNum));
  12660. label.Append("人全程机票:");
  12661. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12662. label.AppendLine("元");
  12663. }
  12664. foreach (var item in intTravelCosts.Infos)
  12665. {
  12666. label.Append(item.FeeName);
  12667. label.Append(":");
  12668. label.Append(item.UnitPrice.TruncDecimals(2));
  12669. label.Append("元/人*");
  12670. label.Append(item.PplNum);
  12671. label.AppendLine("人");
  12672. }
  12673. if (label.HasValue())
  12674. {
  12675. label.Append("\r\n以上小计:");
  12676. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12677. label.Append("元");
  12678. }
  12679. designer.SetDataSource("IntTravelLabel", label.ToString());
  12680. }
  12681. #endregion
  12682. #region 住宿费
  12683. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12684. if (accomCosts != null && accomCosts.Infos.Any())
  12685. {
  12686. string currencyName = string.Empty,
  12687. countryName = string.Empty;
  12688. decimal rate = 1.0000M;
  12689. var label = new StringBuilder();
  12690. label.AppendLine("全程五星酒店,每人1间房");
  12691. foreach (var item in accomCosts.Infos)
  12692. {
  12693. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12694. string name = string.Empty, thisCountryName = string.Empty;
  12695. if (item.FeeName.Contains('-'))
  12696. {
  12697. var feeName = item.FeeName.Split('-');
  12698. thisCountryName = feeName[0];
  12699. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12700. name = feeName[1];
  12701. }
  12702. else name = item.FeeName;
  12703. string thisFeeName = string.Empty;
  12704. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12705. else thisFeeName = $"\r\n{name}:";
  12706. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12707. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12708. rate = rateInfo?.Rate ?? 1.0000M;
  12709. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12710. label.AppendLine(subLabel);
  12711. }
  12712. if (label.HasValue())
  12713. {
  12714. //以上小计:52440元(美金汇率:7.5 )
  12715. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12716. label.AppendLine(subLabel);
  12717. }
  12718. designer.SetDataSource("AccomLabel", label.ToString());
  12719. }
  12720. #endregion
  12721. #region 餐饮费
  12722. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12723. if (mealCosts != null && mealCosts.Infos.Any())
  12724. {
  12725. string currencyName = string.Empty;
  12726. decimal rate = 1.0000M;
  12727. var label = new StringBuilder();
  12728. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12729. foreach (var item in mealCosts.Infos)
  12730. {
  12731. string name = string.Empty;
  12732. if (item.FeeName.Contains('-'))
  12733. {
  12734. var feeName = item.FeeName.Split('-');
  12735. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12736. }
  12737. else name = $"\r\n{item.FeeName}:";
  12738. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12739. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12740. rate = rateInfo?.Rate ?? 1.0000M;
  12741. label.Append(name);
  12742. label.Append(item.UnitPrice.TruncDecimals(2));
  12743. label.Append(currencyName);
  12744. label.Append("/天*");
  12745. label.Append(item.Quantity.ToString("#0"));
  12746. label.Append('*');
  12747. label.Append(item.PplNum);
  12748. label.Append("人\r\n");
  12749. }
  12750. if (label.HasValue())
  12751. {
  12752. label.Append("\r\n以上小计:");
  12753. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12754. label.Append("元\r\n(");
  12755. label.Append("汇率:");
  12756. label.Append(rate.TruncDecimals(4));
  12757. label.Append(')');
  12758. }
  12759. designer.SetDataSource("MealLabel", label.ToString());
  12760. }
  12761. #endregion
  12762. #region 车辆安排
  12763. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12764. if (vehArranges != null && vehArranges.Infos.Any())
  12765. {
  12766. string currencyName = string.Empty;
  12767. //decimal rate = 1.0000M;
  12768. var label = new StringBuilder();
  12769. foreach (var item in vehArranges.Infos)
  12770. {
  12771. label.AppendLine();
  12772. label.AppendLine();
  12773. label.Append(item.FeeName);
  12774. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12775. }
  12776. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12777. }
  12778. #endregion
  12779. #region 邀请函发放对象
  12780. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12781. designer.SetDataSource("InviteToContent", "");
  12782. #endregion
  12783. #region 邀请函费
  12784. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12785. var is_label = new StringBuilder();
  12786. if (inviteCosts != null && inviteCosts.Infos.Any())
  12787. {
  12788. string currencyName = string.Empty;
  12789. decimal rate = 1.0000M;
  12790. foreach (var item in inviteCosts.Infos)
  12791. {
  12792. //乌兹别克斯坦:2000美金
  12793. currencyName = item.Currency;
  12794. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12795. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12796. is_label.AppendLine(label);
  12797. }
  12798. if (is_label.HasValue())
  12799. {
  12800. //以上小计:28500元(美金汇率:7.5)
  12801. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12802. is_label.AppendLine(label);
  12803. }
  12804. }
  12805. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12806. #endregion
  12807. #region 邀请函发放时间
  12808. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12809. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12810. #endregion
  12811. #region 公务活动(含翻译)
  12812. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12813. var oa_label = new StringBuilder();
  12814. if (officialActs != null && officialActs.Infos.Any())
  12815. {
  12816. string currencyName = string.Empty;
  12817. decimal rate = 1.0000M;
  12818. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12819. foreach (var item in officialActs.Infos)
  12820. {
  12821. //乌兹别克斯坦:1000美金/场
  12822. currencyName = item.Currency;
  12823. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12824. string label_remark = string.Empty;
  12825. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12826. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12827. }
  12828. label_content += "*总费用中未含超出公务活动价格";
  12829. //8场公务活动(以上小计:60000元)
  12830. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12831. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12832. oa_label.AppendLine(label_title);
  12833. oa_label.AppendLine(label_content);
  12834. }
  12835. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12836. #endregion
  12837. #region 签证+保险
  12838. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12839. var vi_label = new StringBuilder();
  12840. if (visaIns != null && visaIns.Infos.Any())
  12841. {
  12842. foreach (var item in visaIns.Infos)
  12843. {
  12844. //签证:500元/人
  12845. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12846. vi_label.AppendLine(label);
  12847. }
  12848. if (vi_label.HasValue())
  12849. {
  12850. //以上小计:6000元
  12851. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12852. vi_label.AppendLine(label);
  12853. }
  12854. }
  12855. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12856. #endregion
  12857. #region 服务费
  12858. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12859. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12860. #endregion
  12861. #region 公杂费
  12862. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12863. var pm_label = new StringBuilder();
  12864. if (pubMiscs != null && pubMiscs.Infos.Any())
  12865. {
  12866. string currencyName = string.Empty,
  12867. countryName = string.Empty;
  12868. decimal rate = 1.0000M;
  12869. foreach (var item in pubMiscs.Infos)
  12870. {
  12871. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12872. string name = string.Empty, thisCountryName = string.Empty;
  12873. if (item.FeeName.Contains('-'))
  12874. {
  12875. var feeName = item.FeeName.Split('-');
  12876. thisCountryName = feeName[0];
  12877. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12878. name = feeName[1];
  12879. }
  12880. else name = item.FeeName;
  12881. string thisFeeName = string.Empty;
  12882. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12883. else thisFeeName = $"\r\n{name}:";
  12884. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12885. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12886. rate = rateInfo?.Rate ?? 1.0000M;
  12887. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12888. pm_label.AppendLine(label);
  12889. }
  12890. if (pm_label.HasValue())
  12891. {
  12892. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12893. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12894. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12895. pm_label.AppendLine(string.Format("部分发放成员"));
  12896. }
  12897. }
  12898. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12899. #endregion
  12900. #region 税费
  12901. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12902. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12903. #endregion
  12904. #region 合计(单位:元)
  12905. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12906. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12907. #endregion
  12908. #region 汇率 Remark
  12909. var rate_label = new StringBuilder();
  12910. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12911. foreach (var item in rateGroups)
  12912. {
  12913. //美元汇率按\r\n1:7.5
  12914. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12915. rate_label.AppendLine(label);
  12916. }
  12917. designer.SetDataSource("RateLabel", rate_label.ToString());
  12918. #endregion
  12919. designer.Process();
  12920. //文件名
  12921. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12922. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12923. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12924. return Ok(JsonView(true, "成功", url));
  12925. }
  12926. #endregion
  12927. #region 签证费用录入
  12928. /// <summary>
  12929. /// 根据diid查询签证费用列表
  12930. /// </summary>
  12931. /// <param name="dto"></param>
  12932. /// <returns></returns>
  12933. [HttpPost]
  12934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12935. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12936. {
  12937. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12938. if (groupData.Code != 0)
  12939. {
  12940. return Ok(JsonView(false, groupData.Msg));
  12941. }
  12942. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12943. }
  12944. /// <summary>
  12945. /// 根据签证费用Id查询单条数据及c表数据
  12946. /// </summary>
  12947. /// <param name="dto"></param>
  12948. /// <returns></returns>
  12949. [HttpPost]
  12950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12951. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12952. {
  12953. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12954. if (groupData.Code != 0)
  12955. {
  12956. return Ok(JsonView(false, groupData.Msg));
  12957. }
  12958. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12959. }
  12960. /// <summary>
  12961. /// 签证费用删除
  12962. /// </summary>
  12963. /// <param name="dto"></param>
  12964. /// <returns></returns>
  12965. [HttpPost]
  12966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12967. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12968. {
  12969. _sqlSugar.BeginTran();
  12970. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12971. if (!res)
  12972. {
  12973. _sqlSugar.RollbackTran();
  12974. return Ok(JsonView(false, "删除失败"));
  12975. }
  12976. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12977. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12978. .SetColumns(a => new Grp_CreditCardPayment()
  12979. {
  12980. IsDel = 1,
  12981. DeleteUserId = dto.DeleteUserId,
  12982. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12983. })
  12984. .ExecuteCommand();
  12985. if (resSub < 1)
  12986. {
  12987. _sqlSugar.RollbackTran();
  12988. return Ok(JsonView(false, "删除失败"));
  12989. }
  12990. _sqlSugar.CommitTran();
  12991. return Ok(JsonView(true, "删除成功!"));
  12992. }
  12993. /// <summary>
  12994. /// 签证费用录入下拉框初始化
  12995. /// </summary>
  12996. /// <returns></returns>
  12997. [HttpPost]
  12998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12999. public async Task<IActionResult> VisaPriceAddSelect()
  13000. {
  13001. //支付方式
  13002. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  13003. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  13004. //币种
  13005. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  13006. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  13007. //乘客类型
  13008. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  13009. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  13010. //卡类型
  13011. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  13012. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  13013. //代办费类型
  13014. var agencyFeeTypeData = new List<dynamic>() {
  13015. new { id = 0 , Text = "未选择" },
  13016. new { id = 1 , Text = "小公务" },
  13017. new { id = 2 , Text = "大公务" },
  13018. };
  13019. //签证费用标准国家Data
  13020. var visaSql = string.Format(@"select
  13021. id,
  13022. case
  13023. when FeeType = 0 then Country+'(因公)'
  13024. when FeeType = 1 then Country+'(因私)'
  13025. else Country+'(未设置)'
  13026. end as 'country'
  13027. from Res_VisaFeeStandard where isdel = 0");
  13028. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  13029. var data = new
  13030. {
  13031. Payment = _Payment,
  13032. CurrencyList = _CurrencyList,
  13033. PassengerType = _PassengerType,
  13034. BankCard = _BankCard,
  13035. AgencyFeeType = agencyFeeTypeData,
  13036. CountryFeeData = visaCountryFeeData
  13037. };
  13038. return Ok(JsonView(true, "查询成功!", data));
  13039. }
  13040. /// <summary>
  13041. /// 签证费用录入操作(Status:1.新增,2.修改)
  13042. /// </summary>
  13043. /// <param name="dto"></param>
  13044. /// <returns></returns>
  13045. [HttpPost]
  13046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13047. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  13048. {
  13049. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  13050. if (groupData.Code != 0)
  13051. {
  13052. return Ok(JsonView(false, groupData.Msg));
  13053. }
  13054. #region 应用推送
  13055. try
  13056. {
  13057. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13058. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13059. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13060. //2024-10-21 新增LZ UID
  13061. var userIds = new List<int>() { 21 };
  13062. string title = $"系统通知";
  13063. string content = "";
  13064. var diId = dto.DiId;
  13065. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13066. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13067. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13068. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13069. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13070. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  13071. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13072. }
  13073. catch (Exception ex)
  13074. {
  13075. }
  13076. #endregion
  13077. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13078. }
  13079. #endregion
  13080. #region 签证提成录入
  13081. /// <summary>
  13082. /// 签证提成录入
  13083. /// 基础数据
  13084. /// </summary>
  13085. /// <returns></returns>
  13086. [HttpGet]
  13087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13088. public async Task<IActionResult> VisaCommissionInit()
  13089. {
  13090. return Ok(await _visaCommissionRep.Init());
  13091. }
  13092. /// <summary>
  13093. /// 签证提成录入
  13094. /// Item
  13095. /// </summary>
  13096. /// <param name="_dto"></param>
  13097. /// <returns></returns>
  13098. [HttpPost]
  13099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13100. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  13101. {
  13102. var validator = new VisaCommissionItemDtoValidator();
  13103. var validatorRes = await validator.ValidateAsync(_dto);
  13104. if (!validatorRes.IsValid)
  13105. {
  13106. var sb = new StringBuilder();
  13107. foreach (var item in validatorRes.Errors)
  13108. {
  13109. sb.AppendLine(item.ErrorMessage);
  13110. }
  13111. return Ok(JsonView(false, sb.ToString()));
  13112. }
  13113. return Ok(await _visaCommissionRep.Item(_dto));
  13114. }
  13115. /// <summary>
  13116. /// 签证提成录入
  13117. /// Save
  13118. /// </summary>
  13119. /// <param name="_dto"></param>
  13120. /// <returns></returns>
  13121. [HttpPost]
  13122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13123. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  13124. {
  13125. //参数验证
  13126. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  13127. foreach (var item in _dto.Items)
  13128. {
  13129. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  13130. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  13131. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  13132. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  13133. }
  13134. return Ok(await _visaCommissionRep.Save(_dto));
  13135. }
  13136. /// <summary>
  13137. /// 签证提成录入
  13138. /// Create
  13139. /// </summary>
  13140. /// <param name="_dto"></param>
  13141. /// <returns></returns>
  13142. [HttpPost]
  13143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13144. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  13145. {
  13146. var validator = new VisaCommissionCreateDtoValidator();
  13147. var validatorRes = await validator.ValidateAsync(_dto);
  13148. if (!validatorRes.IsValid)
  13149. {
  13150. var sb = new StringBuilder();
  13151. foreach (var item in validatorRes.Errors)
  13152. {
  13153. sb.AppendLine(item.ErrorMessage);
  13154. }
  13155. return Ok(JsonView(false, sb.ToString()));
  13156. }
  13157. return Ok(await _visaCommissionRep.Create(_dto));
  13158. }
  13159. /// <summary>
  13160. /// 签证提成录入
  13161. /// Put(编辑)
  13162. /// </summary>
  13163. /// <param name="id"></param>
  13164. /// <param name="_dto"></param>
  13165. /// <returns></returns>
  13166. [HttpPut]
  13167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13168. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  13169. {
  13170. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13171. var validator = new VisaCommissionCreateDtoValidator();
  13172. var validatorRes = await validator.ValidateAsync(_dto);
  13173. if (!validatorRes.IsValid)
  13174. {
  13175. var sb = new StringBuilder();
  13176. foreach (var item in validatorRes.Errors)
  13177. {
  13178. sb.AppendLine(item.ErrorMessage);
  13179. }
  13180. return Ok(JsonView(false, sb.ToString()));
  13181. }
  13182. return Ok(await _visaCommissionRep.Edit(id, _dto));
  13183. }
  13184. /// <summary>
  13185. /// 签证提成录入
  13186. /// Del
  13187. /// </summary>
  13188. /// <param name="id"></param>
  13189. /// <param name="currUserId"></param>
  13190. /// <returns></returns>
  13191. [HttpPost]
  13192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13193. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  13194. {
  13195. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13196. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  13197. return Ok(await _visaCommissionRep.Del(id, currUserId));
  13198. }
  13199. #endregion
  13200. #region op费用录入
  13201. /// <summary>
  13202. /// 根据diid查询op费用列表
  13203. /// </summary>
  13204. /// <param name="dto"></param>
  13205. /// <returns></returns>
  13206. [HttpPost]
  13207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13208. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  13209. {
  13210. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  13211. if (groupData.Code != 0)
  13212. {
  13213. return Ok(JsonView(false, groupData.Msg));
  13214. }
  13215. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13216. }
  13217. /// <summary>
  13218. /// 根据op费用Id查询单条数据及c表数据
  13219. /// </summary>
  13220. /// <param name="dto"></param>
  13221. /// <returns></returns>
  13222. [HttpPost]
  13223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13224. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  13225. {
  13226. try
  13227. {
  13228. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  13229. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  13230. var data = new
  13231. {
  13232. CarTouristGuideGround = _groupData,
  13233. CreditCardPayment = _creditCardPayment
  13234. };
  13235. return Ok(JsonView(true, "查询成功!", data));
  13236. }
  13237. catch (Exception ex)
  13238. {
  13239. return Ok(JsonView(false, "程序错误!"));
  13240. }
  13241. }
  13242. /// <summary>
  13243. /// op费用删除
  13244. /// </summary>
  13245. /// <param name="dto"></param>
  13246. /// <returns></returns>
  13247. [HttpPost]
  13248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13249. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  13250. {
  13251. try
  13252. {
  13253. _sqlSugar.BeginTran();
  13254. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  13255. if (!res)
  13256. {
  13257. return Ok(JsonView(false, "删除失败"));
  13258. }
  13259. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  13260. {
  13261. IsDel = 1,
  13262. DeleteUserId = dto.DeleteUserId,
  13263. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13264. }).ExecuteCommandAsync();
  13265. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  13266. {
  13267. IsDel = 1,
  13268. DeleteUserId = dto.DeleteUserId,
  13269. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13270. }).ExecuteCommandAsync();
  13271. #region 删除超支相关数据
  13272. //删除导入的超支数据
  13273. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  13274. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  13275. {
  13276. IsDel = 1,
  13277. DeleteUserId = dto.DeleteUserId,
  13278. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13279. }).ExecuteCommand();
  13280. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  13281. {
  13282. IsDel = 1,
  13283. DeleteUserId = dto.DeleteUserId,
  13284. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13285. }).ExecuteCommand();
  13286. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  13287. {
  13288. IsDel = 1,
  13289. DeleteUserId = dto.DeleteUserId,
  13290. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13291. }).ExecuteCommand();
  13292. #endregion
  13293. _sqlSugar.CommitTran();
  13294. return Ok(JsonView(true, "删除成功!"));
  13295. }
  13296. catch (Exception ex)
  13297. {
  13298. _sqlSugar.RollbackTran();
  13299. return Ok(JsonView(false, "程序错误!" + ex.Message));
  13300. }
  13301. }
  13302. /// <summary>
  13303. /// op费用录入操作(Status:1.新增,2.修改)
  13304. /// </summary>
  13305. /// <param name="dto"></param>
  13306. /// <returns></returns>
  13307. [HttpPost]
  13308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13309. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  13310. {
  13311. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  13312. if (groupData.Code != 0)
  13313. {
  13314. return Ok(JsonView(false, groupData.Msg));
  13315. }
  13316. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13317. }
  13318. /// <summary>
  13319. /// 填写费用详细页面初始化绑定
  13320. /// </summary>
  13321. /// <param name="dto"></param>
  13322. /// <returns></returns>
  13323. [HttpPost]
  13324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13325. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  13326. {
  13327. try
  13328. {
  13329. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13330. if (groupData.Code != 0)
  13331. {
  13332. return Ok(JsonView(false, groupData.Msg));
  13333. }
  13334. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13335. }
  13336. catch (Exception ex)
  13337. {
  13338. return Ok(JsonView(false, ex.Message));
  13339. }
  13340. }
  13341. /// <summary>
  13342. /// 根据op费用Id查询详细数据
  13343. /// </summary>
  13344. /// <param name="dto"></param>
  13345. /// <returns></returns>
  13346. [HttpPost]
  13347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13348. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13349. {
  13350. try
  13351. {
  13352. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13353. if (groupData.Code != 0)
  13354. {
  13355. return Ok(JsonView(false, groupData.Msg));
  13356. }
  13357. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13358. }
  13359. catch (Exception ex)
  13360. {
  13361. return Ok(JsonView(false, ex.Message));
  13362. }
  13363. }
  13364. /// <summary>
  13365. /// OP费用录入填写详情
  13366. /// </summary>
  13367. /// <param name="dto"></param>
  13368. /// <returns></returns>
  13369. [HttpPost]
  13370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13371. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  13372. {
  13373. try
  13374. {
  13375. #region 参数校验
  13376. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  13377. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  13378. if (di == null) return Ok(JsonView(false, "团组错误!"));
  13379. #endregion
  13380. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  13381. if (groupData.Code != 0)
  13382. {
  13383. return Ok(JsonView(false, groupData.Msg));
  13384. }
  13385. //自动审核
  13386. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  13387. #region 尾款自动审核
  13388. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13389. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  13390. if (opinfos.PriceType == 1062)
  13391. {
  13392. var isAuto = false;
  13393. //找对应的首付款
  13394. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13395. .InnerJoin<Grp_CreditCardPayment>((x, a) => a.IsDel == 0 && a.CTable == 79 && a.CId == x.Id && a.DIId == x.DiId && (a.IsAuditGM == 1 || a.IsAuditGM == 3))
  13396. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  13397. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  13398. x.PriceType == 1061 && x.DiId == dto.DiId);
  13399. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  13400. {
  13401. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  13402. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  13403. //合计中排除城市税
  13404. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  13405. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  13406. .Sum(x => x.Price * x.Count);
  13407. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  13408. if (balance >= opinfos.ServiceQuotedPrice)
  13409. {
  13410. isAuto = true;
  13411. }
  13412. }
  13413. if (isAuto)
  13414. {
  13415. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13416. .SetColumns(a => new Grp_CreditCardPayment
  13417. {
  13418. IsAuditGM = 3, //自动审核通过
  13419. AuditGMOperate = 4,
  13420. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13421. })
  13422. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  13423. .ExecuteCommand();
  13424. }
  13425. }
  13426. #endregion
  13427. #region 应用推送
  13428. try
  13429. {
  13430. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13431. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13432. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13433. //2024-10-21 新增LZ UID
  13434. var userIds = new List<int>() { 21 };
  13435. string title = $"系统通知";
  13436. var diId = dto.DiId;
  13437. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13438. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13439. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  13440. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13441. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  13442. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13443. }
  13444. catch (Exception ex)
  13445. {
  13446. }
  13447. #endregion
  13448. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13449. }
  13450. catch (Exception ex)
  13451. {
  13452. return Ok(JsonView(false, ex.Message));
  13453. }
  13454. }
  13455. /// <summary>
  13456. /// 获取三公详细所有城市
  13457. /// </summary>
  13458. /// <returns></returns>
  13459. [HttpGet]
  13460. public IActionResult OpCarCityResult()
  13461. {
  13462. var jw = JsonView(false);
  13463. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13464. {
  13465. x.Id,
  13466. x.Country,
  13467. x.City,
  13468. }).ToList();
  13469. if (data.Count > 0)
  13470. {
  13471. jw = JsonView(true, "获取成功!", data);
  13472. }
  13473. else
  13474. {
  13475. jw.Msg = "城市数据为空!";
  13476. jw.Data = Array.Empty<string>();
  13477. }
  13478. return Ok(jw);
  13479. }
  13480. /// <summary>
  13481. /// 导出地接费用明细
  13482. /// </summary>
  13483. /// <param name="dto"></param>
  13484. /// <returns></returns>
  13485. [HttpPost]
  13486. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13487. {
  13488. var jw = JsonView(false);
  13489. if (dto.Diid < 1)
  13490. {
  13491. jw.Msg = "请输入正确的diid!";
  13492. return Ok(jw);
  13493. }
  13494. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13495. if (group == null)
  13496. {
  13497. jw.Msg = "未找到团组信息!";
  13498. return Ok(jw);
  13499. }
  13500. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13501. if (localGuideArr.Count == 0)
  13502. {
  13503. jw.Msg = "该团组暂无地接信息!";
  13504. return Ok(jw);
  13505. }
  13506. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13507. var overspendSoure = new Dictionary<int, int>
  13508. {
  13509. { 91, 982 }, //车
  13510. { 92 , 1059} ,//导游
  13511. { 994 , 1073}, //翻译
  13512. { 988 , 1074 }, //早餐
  13513. { 93 , 1075 }, //午餐
  13514. { 989 , 1076 }, //晚餐
  13515. };
  13516. var Zips = new Dictionary<string, Stream>();
  13517. foreach (var groupArr in localGroup)
  13518. {
  13519. var keyValue = groupArr.Key;
  13520. if (int.TryParse(keyValue, out int cityid))
  13521. {
  13522. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13523. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13524. }
  13525. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13526. foreach (var item in groupArr)
  13527. {
  13528. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13529. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13530. new Grp_CarTouristGuideGroundReservationsContentExtend
  13531. {
  13532. Count = a.Count,
  13533. CreateTime = a.CreateTime,
  13534. CreateUserId = a.CreateUserId,
  13535. CTGGRId = a.CTGGRId,
  13536. Currency = a.Currency,
  13537. DatePrice = a.DatePrice,
  13538. DeleteTime = a.DeleteTime,
  13539. DeleteUserId = a.DeleteUserId,
  13540. DiId = a.DiId,
  13541. Id = a.Id,
  13542. IsDel = a.IsDel,
  13543. Price = a.Price,
  13544. PriceContent = a.PriceContent,
  13545. Remark = a.Remark,
  13546. SId = a.SId,
  13547. SidName = b.Name,
  13548. Units = a.Units,
  13549. }
  13550. ).ToList();
  13551. if (content.Count > 0)
  13552. {
  13553. contentArr.Add(content);
  13554. }
  13555. }
  13556. //open excel
  13557. //set excel
  13558. //save excel
  13559. try
  13560. {
  13561. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13562. IWorkbook workbook;
  13563. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13564. {
  13565. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13566. }
  13567. else
  13568. {
  13569. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13570. }
  13571. ISheet sheet = workbook.GetSheetAt(0);
  13572. var rowStartIndex = 2;
  13573. var clounmCount = 10;
  13574. var initStyleRow = sheet.GetRow(2);
  13575. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13576. //var overspendArrDetail =
  13577. var existsId = new List<CarCompare>();
  13578. var lastElem = arr.Last();
  13579. var thisSid = -1;
  13580. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13581. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13582. {
  13583. Name = "未知币种!",
  13584. Remark = "未知币种!",
  13585. };
  13586. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13587. Action cloneRowFn = () =>
  13588. {
  13589. rowStartIndex++;
  13590. var cloneRow = sheet.CreateRow(rowStartIndex);
  13591. // 复制样式
  13592. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13593. {
  13594. ICell sourceCell = initStyleRow.GetCell(i);
  13595. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13596. // 确保单元格存在样式
  13597. if (sourceCell.CellStyle != null)
  13598. {
  13599. targetCell.CellStyle = sourceCell.CellStyle;
  13600. }
  13601. }
  13602. };
  13603. var mergeRow = () =>
  13604. {
  13605. for (int i = 2; i < sheet.LastRowNum; i++)
  13606. {
  13607. var row = sheet.GetRow(i);
  13608. var cellFirst = row.GetCell(0);
  13609. var thisIndex = i + 1;
  13610. while (thisIndex < sheet.LastRowNum)
  13611. {
  13612. var nextRow = sheet.GetRow(thisIndex);
  13613. var nextCellFirst = nextRow.GetCell(0);
  13614. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13615. {
  13616. thisIndex++;
  13617. }
  13618. else
  13619. {
  13620. break;
  13621. }
  13622. }
  13623. thisIndex--;
  13624. if (thisIndex != i)
  13625. {
  13626. //合并row
  13627. var cellRangeAddress = new CellRangeAddress(
  13628. i, // 起始行索引(0-based)
  13629. thisIndex, // 结束行索引(0-based)
  13630. 0, // 起始列索引(0-based)
  13631. 0 // 结束列索引(0-based)
  13632. );
  13633. sheet.AddMergedRegion(cellRangeAddress);
  13634. i = thisIndex;
  13635. }
  13636. }
  13637. };
  13638. var chaoshiNumber = 0;
  13639. var totalNumber = 0.00M;
  13640. string lastStr = "";
  13641. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13642. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13643. {
  13644. b.IsAuditGM,
  13645. x.Id,
  13646. x.Area,
  13647. b.PayPercentage,
  13648. b.PayMoney,
  13649. }).ToList();
  13650. string yesPayment = "", noPayment = "";
  13651. foreach (var item in queryCarArrByCityAndDiid)
  13652. {
  13653. if (item.IsAuditGM == 1)
  13654. {
  13655. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13656. }
  13657. else
  13658. {
  13659. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13660. }
  13661. }
  13662. lastStr = yesPayment + noPayment;
  13663. foreach (var item in arr)
  13664. {
  13665. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13666. {
  13667. if (thisSid != item.SId)
  13668. {
  13669. if (thisSid == -1)
  13670. {
  13671. thisSid = item.SId;
  13672. }
  13673. else
  13674. {
  13675. //合并小计行
  13676. //创建合并区域的实例
  13677. var cellRangeAddress = new CellRangeAddress(
  13678. rowStartIndex, // 起始行索引(0-based)
  13679. rowStartIndex, // 结束行索引(0-based)
  13680. 0, // 起始列索引(0-based)
  13681. 3 // 结束列索引(0-based)
  13682. );
  13683. sheet.AddMergedRegion(cellRangeAddress);
  13684. var CellStyle = workbook.CreateCellStyle();
  13685. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13686. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13687. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13688. for (int i = 0; i <= clounmCount; i++)
  13689. {
  13690. if (i > 6)
  13691. {
  13692. var CellStyle1 = workbook.CreateCellStyle();
  13693. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13694. IFont Font = workbook.CreateFont(); // 创建字体
  13695. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13696. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13697. CellStyle1.SetFont(Font);
  13698. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13699. }
  13700. else
  13701. {
  13702. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13703. }
  13704. }
  13705. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13706. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13707. //超时合计
  13708. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13709. //超时数
  13710. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13711. //超时合计费用
  13712. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13713. thisSid = item.SId;
  13714. cloneRowFn();
  13715. chaoshiNumber = 0;
  13716. totalNumber = 0;
  13717. }
  13718. }
  13719. IRow row = sheet.GetRow(rowStartIndex);
  13720. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13721. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13722. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13723. if (isOpenOverspendSoure)
  13724. {
  13725. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13726. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13727. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13728. }
  13729. for (int i = 0; i <= clounmCount; i++)
  13730. {
  13731. var cell = row.GetCell(i);
  13732. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13733. if (cell == null)
  13734. {
  13735. cell = row.CreateCell(i);
  13736. }
  13737. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13738. fontRed.CloneStyleFrom(cell.CellStyle);
  13739. IFont Font = workbook.CreateFont(); // 创建字体
  13740. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13741. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13742. fontRed.SetFont(Font);
  13743. byte[] rgb = new byte[3] { 255, 242, 204 };
  13744. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13745. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13746. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13747. if (workbook is XSSFWorkbook)
  13748. {
  13749. BackgroundColor255_242_204.FillForegroundColor = 0;
  13750. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13751. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13752. }
  13753. else
  13754. {
  13755. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13756. }
  13757. if (i == 1 || i > 6)
  13758. {
  13759. if (i > 6)
  13760. {
  13761. fontRed.FillForegroundColor = 0;
  13762. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13763. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13764. }
  13765. cell.CellStyle = fontRed;
  13766. }
  13767. if (i > 2 && i < 7)
  13768. {
  13769. cell.CellStyle = BackgroundColor255_242_204;
  13770. }
  13771. cell.SetCellValue(setCellValue); //写入单元格
  13772. }
  13773. if (overspendSoure.ContainsKey(thisSid))
  13774. {
  13775. var overspendId = overspendSoure[thisSid];
  13776. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13777. }
  13778. cloneRowFn();
  13779. existsId.Add(new CarCompare
  13780. {
  13781. DataPrice = item.DatePrice.ObjToDate(),
  13782. Sid = item.SId
  13783. });
  13784. }
  13785. if (item.Equals(lastElem))
  13786. {
  13787. //合并小计行
  13788. //创建合并区域的实例
  13789. var cellRangeAddress = new CellRangeAddress(
  13790. rowStartIndex, // 起始行索引(0-based)
  13791. rowStartIndex, // 结束行索引(0-based)
  13792. 0, // 起始列索引(0-based)
  13793. 3 // 结束列索引(0-based)
  13794. );
  13795. sheet.AddMergedRegion(cellRangeAddress);
  13796. var CellStyle = workbook.CreateCellStyle();
  13797. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13798. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13799. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13800. for (int i = 0; i <= clounmCount; i++)
  13801. {
  13802. if (i > 6)
  13803. {
  13804. var CellStyle1 = workbook.CreateCellStyle();
  13805. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13806. IFont Font = workbook.CreateFont(); // 创建字体
  13807. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13808. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13809. CellStyle1.SetFont(Font);
  13810. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13811. }
  13812. else
  13813. {
  13814. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13815. }
  13816. }
  13817. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13818. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13819. //超时合计
  13820. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13821. //超时数
  13822. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13823. //超时合计费用
  13824. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13825. cloneRowFn();
  13826. // 创建合并区域的实例
  13827. cellRangeAddress = new CellRangeAddress(
  13828. rowStartIndex, // 起始行索引(0-based)
  13829. rowStartIndex, // 结束行索引(0-based)
  13830. 0, // 起始列索引(0-based)
  13831. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13832. );
  13833. // 添加合并区域
  13834. sheet.AddMergedRegion(cellRangeAddress);
  13835. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13836. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13837. }
  13838. }
  13839. mergeRow();
  13840. // 保存修改后的Excel文件到新文件
  13841. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13842. // new FileStream(newFilePath, FileMode.CreateNew)
  13843. using (var stream = new MemoryStream())
  13844. {
  13845. workbook.Write(stream, true);
  13846. stream.Flush();
  13847. stream.Seek(0, SeekOrigin.Begin);
  13848. var memoryStream = new MemoryStream();
  13849. stream.CopyTo(memoryStream);
  13850. memoryStream.Seek(0, SeekOrigin.Begin);
  13851. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13852. }
  13853. workbook.Close();
  13854. workbook.Dispose();
  13855. }
  13856. catch (Exception ex)
  13857. {
  13858. jw.Msg = "出现异常!" + ex.Message;
  13859. return Ok(jw);
  13860. }
  13861. }
  13862. if (Zips.Count > 0)
  13863. {
  13864. var io = new IOOperatorHelper();
  13865. var byts = io.ConvertZipStream(Zips);
  13866. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13867. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13868. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13869. }
  13870. else
  13871. {
  13872. jw.Msg = "暂无生成文件!";
  13873. }
  13874. return Ok(jw);
  13875. }
  13876. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13877. {
  13878. string outStr = string.Empty;
  13879. switch (i)
  13880. {
  13881. case 0:
  13882. outStr = arr[0].SidName;
  13883. break;
  13884. case 1:
  13885. outStr = arr[0].DataPriceStr;
  13886. break;
  13887. case 2:
  13888. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13889. break;
  13890. case 4:
  13891. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13892. break;
  13893. case 7:
  13894. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13895. {
  13896. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13897. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13898. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13899. }
  13900. break;
  13901. case 8:
  13902. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13903. {
  13904. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13905. }
  13906. break;
  13907. case 9:
  13908. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13909. {
  13910. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13911. }
  13912. break;
  13913. case 10:
  13914. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13915. {
  13916. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13917. }
  13918. break;
  13919. }
  13920. return outStr;
  13921. }
  13922. #region OP行程单
  13923. /// <summary>
  13924. /// OP行程单初始化
  13925. /// </summary>
  13926. /// <param name="dto"></param>
  13927. /// <returns></returns>
  13928. [HttpPost]
  13929. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13930. {
  13931. var jw = JsonView(false);
  13932. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13933. var group = groupList.First();
  13934. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13935. if (group == null)
  13936. {
  13937. jw.Msg = "暂无团组!";
  13938. return Ok(jw);
  13939. }
  13940. group = groupList.Find(x => x.Id == diid);
  13941. if (group == null)
  13942. {
  13943. jw.Msg = "请输入正确的团组ID!";
  13944. return Ok(jw);
  13945. }
  13946. string city = string.Empty;
  13947. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13948. if (blackCode.Count > 0)
  13949. {
  13950. var black = blackCode.First();
  13951. black.BlackCode = black.BlackCode ?? "";
  13952. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13953. if (blackSp.Length > 0)
  13954. {
  13955. try
  13956. {
  13957. var cityArrCode = new List<string>(20);
  13958. foreach (var item in blackSp)
  13959. {
  13960. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13961. var IndexSelect = itemSp[2];
  13962. var cityArrCodeLength = cityArrCode.Count - 1;
  13963. var startCity = IndexSelect.Substring(0, 3);
  13964. if (cityArrCodeLength > 0)
  13965. {
  13966. var arrEndCity = cityArrCode[cityArrCodeLength];
  13967. if (arrEndCity != startCity)
  13968. {
  13969. cityArrCode.Add(startCity.ToUpper());
  13970. }
  13971. }
  13972. else
  13973. {
  13974. cityArrCode.Add(startCity.ToUpper());
  13975. }
  13976. var endCity = IndexSelect.Substring(3, 3);
  13977. cityArrCode.Add(endCity.ToUpper());
  13978. }
  13979. var cityThree = string.Empty;
  13980. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13981. cityThree = cityThree.TrimEnd(',');
  13982. if (string.IsNullOrWhiteSpace(cityThree))
  13983. {
  13984. throw new
  13985. Exception("error");
  13986. }
  13987. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13988. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13989. foreach (var item in cityArrCode)
  13990. {
  13991. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13992. if (find != null)
  13993. {
  13994. city += find.City + "/";
  13995. }
  13996. else
  13997. {
  13998. city += item + "三字码未收入/";
  13999. }
  14000. }
  14001. city = city.TrimEnd('/');
  14002. }
  14003. catch (Exception e)
  14004. {
  14005. city = "黑屏代码格式不正确!";
  14006. }
  14007. }
  14008. }
  14009. else
  14010. {
  14011. city = "未录入黑屏代码";
  14012. }
  14013. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  14014. {
  14015. Date = x.Date,
  14016. Days = x.Days,
  14017. Diffgroup = x.Diffgroup,
  14018. Diid = x.Diid,
  14019. Traffic_First = x.Traffic_First,
  14020. Traffic_Second = x.Traffic_Second,
  14021. Trip = x.Trip,
  14022. WeekDay = x.WeekDay,
  14023. Id = x.Id
  14024. }).ToList();
  14025. jw.Data = new
  14026. {
  14027. groupList = groupList.Select(x => new
  14028. {
  14029. x.Id,
  14030. x.TeamName,
  14031. x.TourCode
  14032. }).ToList(),
  14033. groupInfo = new
  14034. {
  14035. group.VisitDays,
  14036. group.TourCode,
  14037. group.VisitPNumber,
  14038. group.TeamName,
  14039. city
  14040. },
  14041. OpTravelList
  14042. };
  14043. jw.Code = 200;
  14044. jw.Msg = "操作成功!";
  14045. return Ok(jw);
  14046. }
  14047. /// <summary>
  14048. /// 删除团组行程单
  14049. /// </summary>
  14050. /// <returns></returns>
  14051. [HttpPost]
  14052. public IActionResult DelTravel(DelOpTravelDto dto)
  14053. {
  14054. var jw = JsonView(false);
  14055. if (dto.UserId <= 0 || dto.Diid <= 0)
  14056. {
  14057. jw.Msg = "请输入正确的参数!";
  14058. return Ok(jw);
  14059. }
  14060. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  14061. .SetColumns(x => new Grp_TravelList
  14062. {
  14063. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  14064. DeleteUserId = dto.UserId,
  14065. IsDel = 1,
  14066. }).ExecuteCommand();
  14067. jw = JsonView(true);
  14068. return Ok(jw);
  14069. }
  14070. /// <summary>
  14071. /// 行程单保存
  14072. /// </summary>
  14073. /// <returns></returns>
  14074. [HttpPost]
  14075. public IActionResult TravelSave(TravelSaveDto dto)
  14076. {
  14077. var jw = JsonView(false);
  14078. if (dto.Arr.Count > 0)
  14079. {
  14080. try
  14081. {
  14082. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  14083. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  14084. .ToList();
  14085. _sqlSugar.BeginTran();
  14086. foreach (var item in dto.Arr)
  14087. {
  14088. if (item.Id == 0)
  14089. {
  14090. throw new Exception("请传入正确的Id");
  14091. }
  14092. //比较上一次的差异
  14093. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  14094. if (findTravel != null)
  14095. {
  14096. item.Trip = item.Trip.Replace("[++]", string.Empty);
  14097. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  14098. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  14099. }
  14100. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  14101. .SetColumns(x => new Grp_TravelList
  14102. {
  14103. Trip = item.Trip
  14104. }).ExecuteCommand();
  14105. }
  14106. _sqlSugar.CommitTran();
  14107. jw = JsonView(true);
  14108. }
  14109. catch (Exception ex)
  14110. {
  14111. _sqlSugar.RollbackTran();
  14112. jw.Msg = "程序异常!" + ex.Message;
  14113. }
  14114. }
  14115. else
  14116. {
  14117. jw.Msg = "请传入正确的参数!";
  14118. }
  14119. return Ok(jw);
  14120. }
  14121. private static string CheckStr(string original, string changed)
  14122. {
  14123. // 创建diff_match_patch对象
  14124. var dmp = new diff_match_patch();
  14125. // 计算差异
  14126. List<Diff> diffs = dmp.diff_main(original, changed);
  14127. // 清理和合并差异
  14128. dmp.diff_cleanupSemantic(diffs);
  14129. // 使用StringBuilder构建最终的字符串
  14130. var finalString = new StringBuilder();
  14131. // 输出差异结果,并构建变动后的字符串
  14132. foreach (Diff diff in diffs)
  14133. {
  14134. switch (diff.operation)
  14135. {
  14136. case Operation.EQUAL:
  14137. // 相等的部分,直接添加到最终字符串
  14138. finalString.Append(diff.text);
  14139. break;
  14140. case Operation.INSERT:
  14141. // 插入的部分,添加标记并添加到最终字符串
  14142. finalString.Append("[++]" + diff.text + "[++]");
  14143. break;
  14144. case Operation.DELETE:
  14145. // 删除的部分,不添加到最终字符串
  14146. //finalString.Append("[++]" + diff.text + "[++]");
  14147. break;
  14148. }
  14149. }
  14150. // 输出变动后的字符串
  14151. return finalString.ToString();
  14152. }
  14153. private class tagContent
  14154. {
  14155. public DateTime Date { get; set; }
  14156. public string StartTag { get; set; }
  14157. public string EndTag { get; set; }
  14158. public string Content { get; set; }
  14159. public static int tagLength { get { return 3; } }
  14160. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  14161. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  14162. public bool IsFinally { get; set; }
  14163. }
  14164. private static List<string> ExtractContentBetweenTags(string input, string tag)
  14165. {
  14166. var results = new List<string>();
  14167. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  14168. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  14169. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  14170. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  14171. string[] strValueArr = new string[1];
  14172. foreach (System.Text.RegularExpressions.Match match in matches)
  14173. {
  14174. var strValue = match.Groups[1].Value;
  14175. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  14176. }
  14177. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  14178. return results;
  14179. }
  14180. /// <summary>
  14181. /// 导出行程单
  14182. /// </summary>
  14183. /// <param name="dto"></param>
  14184. /// <returns></returns>
  14185. [HttpPost]
  14186. public IActionResult ExportTravel(ExportTravelDto dto)
  14187. {
  14188. var jw = JsonView(false);
  14189. jw.Data = "";
  14190. int diid = 0;
  14191. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  14192. if (Find == null)
  14193. {
  14194. jw.Msg = "请选择正确的团组!";
  14195. return Ok(jw);
  14196. }
  14197. else
  14198. {
  14199. diid = Find.Id;
  14200. }
  14201. //数据源
  14202. var _travelList = new List<Grp_TravelList>();
  14203. DataTable dtBlack = null;
  14204. try
  14205. {
  14206. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  14207. }
  14208. catch (Exception)
  14209. {
  14210. jw.Msg = "机票黑屏代码有误!";
  14211. return Ok(jw);
  14212. }
  14213. string CityStr = string.Empty;
  14214. if (dtBlack.Rows.Count == 0)
  14215. {
  14216. jw.Msg = "机票黑屏代码有误!";
  14217. return Ok(jw);
  14218. }
  14219. else
  14220. {
  14221. foreach (DataRow row in dtBlack.Rows)
  14222. {
  14223. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14224. {
  14225. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  14226. return Ok(jw);
  14227. }
  14228. }
  14229. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  14230. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  14231. }
  14232. // 指定的文字
  14233. var targetTextDic = new Dictionary<string, List<string>>();
  14234. //创建数据源Table
  14235. var dtSource = new DataTable();
  14236. dtSource.Columns.Add("Days", typeof(string));
  14237. dtSource.Columns.Add("Date", typeof(string));
  14238. dtSource.Columns.Add("Week", typeof(string));
  14239. dtSource.Columns.Add("Traffic", typeof(string));
  14240. dtSource.Columns.Add("Trip", typeof(string));
  14241. //获取数据,放到datatable
  14242. foreach (var item in _travelList)
  14243. {
  14244. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  14245. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  14246. .Replace(tagContent.TagFormat.Item2, string.Empty)
  14247. .Replace("[++]", string.Empty);
  14248. DataRow dr = dtSource.NewRow();
  14249. dr["Days"] = item.Days;
  14250. dr["Date"] = item.Date;
  14251. dr["Week"] = item.WeekDay;
  14252. dr["Traffic"] = item.Traffic_First
  14253. + "\r\n"
  14254. + item.Traffic_Second;
  14255. dr["Trip"] = item.Trip;
  14256. dtSource.Rows.Add(dr);
  14257. }
  14258. var dic = new Dictionary<string, string>
  14259. {
  14260. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  14261. { "City", CityStr },
  14262. { "Days", Find.VisitDays.ToString() },
  14263. { "DeleCode", Find.TourCode },
  14264. { "Pnum", Find.VisitPNumber.ToString() }
  14265. };
  14266. //模板路径
  14267. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  14268. //载入模板
  14269. Document doc = null;
  14270. DocumentBuilder builder = null;
  14271. try
  14272. {
  14273. //载入模板
  14274. doc = new Document(tempPath);
  14275. builder = new DocumentBuilder(doc);
  14276. }
  14277. catch (Exception)
  14278. {
  14279. jw.Msg = "模板位置不存在!";
  14280. return Ok(jw);
  14281. }
  14282. foreach (var key in dic.Keys)
  14283. {
  14284. Bookmark bookmark = doc.Range.Bookmarks[key];
  14285. if (bookmark != null)
  14286. {
  14287. builder.MoveToBookmark(key);
  14288. builder.Write(dic[key]);
  14289. }
  14290. }
  14291. //获取word里所有表格
  14292. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14293. //获取所填表格的序数
  14294. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14295. try
  14296. {
  14297. //循环赋值
  14298. for (int i = 0; i < dtSource.Rows.Count; i++)
  14299. {
  14300. builder.MoveToCell(0, i + 1, 0, 0);
  14301. builder.Write(dtSource.Rows[i]["Days"].ToString());
  14302. builder.MoveToCell(0, i + 1, 1, 0);
  14303. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  14304. builder.MoveToCell(0, i + 1, 2, 0);
  14305. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  14306. var trip = dtSource.Rows[i]["Trip"].ToString();
  14307. builder.MoveToCell(0, i + 1, 3, 0);
  14308. builder.Write(trip);
  14309. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  14310. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14311. // 获取特定索引的段落
  14312. Paragraph paragraph = (Paragraph)paragraphs[0];
  14313. Run run = paragraph.Runs[0];
  14314. Aspose.Words.Font font = run.Font;
  14315. font.Name = "黑体";
  14316. //设置双休红色
  14317. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  14318. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14319. paragraph = (Paragraph)paragraphs[1];
  14320. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  14321. {
  14322. run = paragraph.Runs[0];
  14323. font = run.Font;
  14324. font.Color = Color.Red;
  14325. }
  14326. }
  14327. }
  14328. catch (Exception ex)
  14329. {
  14330. }
  14331. //删除多余行
  14332. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  14333. {
  14334. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  14335. }
  14336. var targetTextList = new List<string>();
  14337. // 遍历文档中的表格
  14338. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14339. {
  14340. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14341. {
  14342. var cellIndex = 0;
  14343. foreach (Cell cell in row.Cells)
  14344. {
  14345. if (cellIndex == 1 && row.Cells.Count == 4)
  14346. {
  14347. foreach (var target in targetTextDic.Keys)
  14348. {
  14349. if (cell.GetText().Contains(target))
  14350. {
  14351. targetTextList = targetTextDic[target];
  14352. break;
  14353. }
  14354. }
  14355. }
  14356. // 遍历单元格中的所有段落
  14357. foreach (Paragraph paragraph in cell.Paragraphs)
  14358. {
  14359. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  14360. var runs = new List<Run>();
  14361. foreach (Run run in paragraph.Runs)
  14362. {
  14363. runs.Add(run);
  14364. }
  14365. foreach (Run run in runs)
  14366. {
  14367. foreach (var targetText in targetTextList)
  14368. {
  14369. // 检查文字是否包含指定文字
  14370. if (run.Text.Contains(targetText))
  14371. {
  14372. // 将包含的部分设置为红色
  14373. HighlightText(run, targetText, Color.Red);
  14374. }
  14375. }
  14376. }
  14377. }
  14378. cellIndex++;
  14379. }
  14380. }
  14381. }
  14382. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  14383. if (!Directory.Exists(savePath))
  14384. {
  14385. try
  14386. {
  14387. Directory.CreateDirectory(savePath);
  14388. }
  14389. catch
  14390. {
  14391. }
  14392. }
  14393. string path = savePath + Find.TeamName + "出访日程";
  14394. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  14395. try
  14396. {
  14397. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  14398. string postfix = ".docx";
  14399. if (dto.IsPDF == 1)
  14400. {
  14401. saveFormat = Aspose.Words.SaveFormat.Pdf;
  14402. postfix = ".pdf";
  14403. }
  14404. doc.Save(path + postfix, saveFormat);
  14405. jw = JsonView(true, "导出成功", ftpPath + postfix);
  14406. }
  14407. catch (Exception)
  14408. {
  14409. jw = JsonView(false);
  14410. }
  14411. return Ok(jw);
  14412. }
  14413. /// <summary>
  14414. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  14415. /// </summary>
  14416. /// <param name="num"></param>
  14417. /// <returns></returns>
  14418. static string GetNum(string num)
  14419. {
  14420. string str = "";
  14421. switch (num)
  14422. {
  14423. case "1":
  14424. str = "一";
  14425. break;
  14426. case "2":
  14427. str = "二";
  14428. break;
  14429. case "3":
  14430. str = "三";
  14431. break;
  14432. case "4":
  14433. str = "四";
  14434. break;
  14435. case "5":
  14436. str = "五";
  14437. break;
  14438. case "6":
  14439. str = "六";
  14440. break;
  14441. case "7":
  14442. str = "七";
  14443. break;
  14444. case "8":
  14445. str = "八";
  14446. break;
  14447. case "9":
  14448. str = "九";
  14449. break;
  14450. case "10":
  14451. str = "十";
  14452. break;
  14453. case "11":
  14454. str = "十一";
  14455. break;
  14456. case "12":
  14457. str = "十二";
  14458. break;
  14459. case "一":
  14460. str = "1";
  14461. break;
  14462. case "二":
  14463. str = "2";
  14464. break;
  14465. case "三":
  14466. str = "3";
  14467. break;
  14468. case "四":
  14469. str = "4";
  14470. break;
  14471. case "五":
  14472. str = "5";
  14473. break;
  14474. case "六":
  14475. str = "6";
  14476. break;
  14477. case "七":
  14478. str = "7";
  14479. break;
  14480. case "八":
  14481. str = "8";
  14482. break;
  14483. case "九":
  14484. str = "9";
  14485. break;
  14486. case "十":
  14487. str = "10";
  14488. break;
  14489. case "十一":
  14490. str = "11";
  14491. break;
  14492. case "十二":
  14493. str = "12";
  14494. break;
  14495. }
  14496. return str;
  14497. }
  14498. /// <summary>
  14499. /// 高亮包含指定文字的部分
  14500. /// </summary>
  14501. /// <param name="run"></param>
  14502. /// <param name="targetText"></param>
  14503. /// <param name="color"></param>
  14504. static void HighlightText(Run run, string targetText, Color color)
  14505. {
  14506. string text = run.Text;
  14507. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14508. if (startIndex >= 0)
  14509. {
  14510. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14511. // 前部分
  14512. if (startIndex > 0)
  14513. {
  14514. Run beforeRun = (Run)run.Clone(true);
  14515. beforeRun.Text = text.Substring(0, startIndex);
  14516. parentParagraph.InsertBefore(beforeRun, run);
  14517. }
  14518. // 匹配部分
  14519. Run matchRun = (Run)run.Clone(true);
  14520. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14521. matchRun.Font.Color = color;
  14522. parentParagraph.InsertBefore(matchRun, run);
  14523. // 后部分
  14524. if (startIndex + targetText.Length < text.Length)
  14525. {
  14526. Run afterRun = (Run)run.Clone(true);
  14527. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14528. parentParagraph.InsertBefore(afterRun, run);
  14529. }
  14530. // 删除原始Run
  14531. run.Remove();
  14532. }
  14533. }
  14534. #endregion
  14535. #endregion
  14536. #region 团组成本
  14537. /// <summary>
  14538. /// 团组成本数据初始化
  14539. /// </summary>
  14540. /// <param name="dto"></param>
  14541. /// <returns></returns>
  14542. [HttpPost]
  14543. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14544. {
  14545. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14546. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14547. WHEN COUNT(*) >= 0 THEN 'True'
  14548. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14549. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14550. ").ToList(); //团组列表
  14551. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14552. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14553. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14554. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14555. if (groupinfoValue != null)
  14556. {
  14557. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14558. var spArr = new string[1] { countryArr };
  14559. if (countryArr.Contains("|"))
  14560. {
  14561. spArr = countryArr.Split("|");
  14562. }
  14563. else if (countryArr.Contains("、"))
  14564. {
  14565. spArr = countryArr.Split("、");
  14566. }
  14567. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14568. {
  14569. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14570. if (dbQueryCountry != null)
  14571. {
  14572. visaCountryInfoArr.Add(dbQueryCountry);
  14573. }
  14574. }
  14575. }
  14576. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14577. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14578. #region 屏蔽黑屏代码生成
  14579. //var create = _GroupCostRepository.
  14580. // CreateGroupCostByBlackCode(dto.Diid);
  14581. //if (groupCost.Count == 0 && create.Code == 0)
  14582. //{
  14583. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14584. //}
  14585. #endregion
  14586. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14587. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14588. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14589. groupCostMap = groupCostMap.Select(x =>
  14590. {
  14591. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14592. {
  14593. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14594. }
  14595. return x;
  14596. }).ToList();
  14597. //GroupCostParameter.Add(new
  14598. // Grp_GroupCostParameter());
  14599. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14600. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14601. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14602. return Ok(JsonView(new
  14603. {
  14604. groupList,
  14605. groupInfo,
  14606. groupChecks,
  14607. groupCost = groupCostMap,
  14608. hotelNumber,
  14609. GroupCostParameter = GroupCostParameterMap,
  14610. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14611. {
  14612. x.VisaCountry,
  14613. x.VisaPrice,
  14614. x.Id,
  14615. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14616. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14617. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14618. x.VisaTime, // 一般签证时间
  14619. x.PettyBusinessAgencyFee, //小公务代办费
  14620. x.GrandBusinessAgencyFee //大公务代办费
  14621. }).ToList(),
  14622. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14623. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14624. hotelIsTrue,
  14625. groupModuleOperators
  14626. }));
  14627. }
  14628. /// <summary>
  14629. /// 团组成本信息保存
  14630. /// </summary>
  14631. /// <param name="dto"></param>
  14632. /// <returns></returns>
  14633. [HttpPost]
  14634. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14635. {
  14636. if (dto.Diid <= 0 || dto.Userid <= 0)
  14637. {
  14638. return Ok(JsonView(false));
  14639. }
  14640. JsonView jw = null;
  14641. bool isTrue = false;
  14642. #region 复制团组成本
  14643. //if (dto.Diid == 2581)
  14644. //{
  14645. // dto.Diid = 2599;
  14646. // dto.CheckBoxs.ForEach(x =>
  14647. // {
  14648. // x.Diid = 2599;
  14649. // });
  14650. // dto.GroupCosts.ForEach(x =>
  14651. // {
  14652. // x.Diid = 2599;
  14653. // });
  14654. // dto.CostTypeHotelNumbers.ForEach(x =>
  14655. // {
  14656. // x.Diid = 2599;
  14657. // });
  14658. // dto.GroupCostParameters.ForEach(x =>
  14659. // {
  14660. // x.DiId = 2599;
  14661. // });
  14662. //}
  14663. #endregion
  14664. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14665. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14666. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14667. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14668. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14669. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14670. try
  14671. {
  14672. _sqlSugar.BeginTran();
  14673. isTrue = await _GroupCostRepository.
  14674. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14675. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14676. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14677. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14678. _sqlSugar.CommitTran();
  14679. jw = JsonView(true, "保存成功!", isTrue);
  14680. }
  14681. catch (Exception)
  14682. {
  14683. _sqlSugar.RollbackTran();
  14684. jw = JsonView(false);
  14685. }
  14686. return Ok(jw);
  14687. }
  14688. /// <summary>
  14689. /// 复制团组成本信息
  14690. /// </summary>
  14691. /// <param name="dto"></param>
  14692. /// <returns></returns>
  14693. [HttpPost]
  14694. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14695. {
  14696. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14697. {
  14698. return Ok(JsonView(false, "参数有误!"));
  14699. }
  14700. #region 复制团组成本
  14701. dto.Diid = dto.ToGroupId;
  14702. dto.CheckBoxs.ForEach(x =>
  14703. {
  14704. x.Diid = dto.ToGroupId;
  14705. });
  14706. dto.GroupCosts.ForEach(x =>
  14707. {
  14708. x.Diid = dto.ToGroupId;
  14709. });
  14710. dto.CostTypeHotelNumbers.ForEach(x =>
  14711. {
  14712. x.Diid = dto.ToGroupId;
  14713. });
  14714. dto.GroupCostParameters.ForEach(x =>
  14715. {
  14716. x.DiId = dto.ToGroupId;
  14717. });
  14718. #endregion
  14719. JsonView jw = null;
  14720. bool isTrue = false;
  14721. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14722. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14723. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14724. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14725. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14726. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14727. try
  14728. {
  14729. _sqlSugar.BeginTran();
  14730. isTrue = await _GroupCostRepository.
  14731. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14732. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14733. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14734. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14735. _sqlSugar.CommitTran();
  14736. jw = JsonView(true, "保存成功!", isTrue);
  14737. }
  14738. catch (Exception)
  14739. {
  14740. _sqlSugar.RollbackTran();
  14741. jw = JsonView(false);
  14742. }
  14743. return Ok(jw);
  14744. }
  14745. /// <summary>
  14746. /// 司兼导数据
  14747. /// </summary>
  14748. /// <param name="dto"></param>
  14749. /// <returns></returns>
  14750. [HttpPost]
  14751. public IActionResult GetCarGuides(CarGuidesDto dto)
  14752. {
  14753. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14754. return Ok(JsonView(true, "获取成功!", Data));
  14755. }
  14756. /// <summary>
  14757. /// 导游数据
  14758. /// </summary>
  14759. /// <param name="dto"></param>
  14760. /// <returns></returns>
  14761. [HttpPost]
  14762. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14763. {
  14764. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14765. // 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
  14766. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14767. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14768. return Ok(JsonView(true, "获取成功!", Data));
  14769. }
  14770. /// <summary>
  14771. /// 成本车数据
  14772. /// </summary>
  14773. /// <param name="dto"></param>
  14774. /// <returns></returns>
  14775. [HttpPost]
  14776. public IActionResult GetCarInfo(CarGuidesDto dto)
  14777. {
  14778. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14779. return Ok(JsonView(true, "获取成功!", Data));
  14780. }
  14781. /// <summary>
  14782. /// 景点数据
  14783. /// </summary>
  14784. /// <param name="dto"></param>
  14785. /// <returns></returns>
  14786. [HttpPost]
  14787. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14788. {
  14789. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14790. return Ok(JsonView(true, "获取成功!", Data));
  14791. }
  14792. /// <summary>
  14793. /// 成本通知
  14794. /// </summary>
  14795. /// <param name="dto"></param>
  14796. /// <returns></returns>
  14797. [HttpPost]
  14798. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14799. {
  14800. if (dto.Diid < 0)
  14801. {
  14802. return Ok(JsonView(false));
  14803. }
  14804. JsonView jw;
  14805. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14806. if (GroupCostParameter != null)
  14807. {
  14808. int IsShare = 0;
  14809. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14810. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14811. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14812. string msg = string.Empty;
  14813. if (isTrue)
  14814. {
  14815. if (IsShare == 0)
  14816. {
  14817. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14818. }
  14819. else
  14820. {
  14821. #region 企微通知对应岗位用户
  14822. try
  14823. {
  14824. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14825. }
  14826. catch (Exception)
  14827. {
  14828. }
  14829. #endregion
  14830. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14831. }
  14832. jw = JsonView(isTrue, msg, new { IsShare });
  14833. }
  14834. else
  14835. {
  14836. msg = "修改失败!";
  14837. jw = JsonView(isTrue, msg);
  14838. }
  14839. }
  14840. else
  14841. {
  14842. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14843. }
  14844. return Ok(jw);
  14845. }
  14846. /// <summary>
  14847. /// 导出报价单
  14848. /// </summary>
  14849. /// <param name="dto"></param>
  14850. /// <returns></returns>
  14851. [HttpPost]
  14852. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14853. {
  14854. if (dto.Diid == 0)
  14855. {
  14856. return Ok(JsonView(false, "请传递团组id"));
  14857. }
  14858. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14859. if (deleInfo.Code != 0)
  14860. {
  14861. return Ok(JsonView(false, "团组信息查询失败!"));
  14862. }
  14863. var di = deleInfo.Data as DelegationInfoWebView;
  14864. if (di != null)
  14865. {
  14866. di.TeamName = di.TeamName.Replace("|", "、");
  14867. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14868. //文件名
  14869. string strFileName = di.TeamName + "-收款账单.doc";
  14870. //获取模板
  14871. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14872. //载入模板
  14873. Document doc = new Document(tmppath);
  14874. decimal TotalPrice = 0.00M;
  14875. string itemStr = string.Empty;
  14876. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14877. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14878. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14879. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14880. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14881. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14882. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14883. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14884. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14885. foreach (var cost in groupCostType)
  14886. {
  14887. var List = cost.ToList();
  14888. if (cost.Key == "A")
  14889. {
  14890. foreach (var ListItem in List)
  14891. {
  14892. if (ListItem.number > 0)
  14893. {
  14894. if (ListItem.code.Contains("TBR"))
  14895. {
  14896. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14897. }
  14898. else
  14899. {
  14900. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14901. }
  14902. TotalPrice += (ListItem.number * ListItem.price);
  14903. }
  14904. }
  14905. }
  14906. else
  14907. {
  14908. itemStr = itemStr.Insert(0, "A段\r\n");
  14909. itemStr += "B段\r\n";
  14910. foreach (var ListItem in List)
  14911. {
  14912. if (ListItem.number > 0)
  14913. {
  14914. if (ListItem.code.Contains("TBR"))
  14915. {
  14916. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14917. }
  14918. else
  14919. {
  14920. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14921. }
  14922. TotalPrice += (ListItem.number * ListItem.price);
  14923. }
  14924. }
  14925. }
  14926. }
  14927. #region 替换Word模板书签内容
  14928. Dictionary<string, string> marks = new Dictionary<string, string>();
  14929. marks.Add("To", di.ClientUnit);//付款方
  14930. marks.Add("ToTel", di.TellPhone);//付款方电话
  14931. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14932. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14933. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14934. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14935. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14936. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14937. marks.Add("PayItemContent", itemStr);//详细信息
  14938. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14939. #endregion
  14940. ////注
  14941. //if (doc.Range.Bookmarks["Attention"] != null)
  14942. //{
  14943. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14944. // mark.Text = frList[0].Attention;
  14945. //}
  14946. foreach (var item in marks.Keys)
  14947. {
  14948. if (doc.Range.Bookmarks[item] != null)
  14949. {
  14950. Bookmark mark = doc.Range.Bookmarks[item];
  14951. mark.Text = marks[item];
  14952. }
  14953. }
  14954. byte[] bytes = null;
  14955. using (MemoryStream stream = new MemoryStream())
  14956. {
  14957. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14958. bytes = stream.ToArray();
  14959. }
  14960. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14961. return Ok(JsonView(true, "", new
  14962. {
  14963. Data = bytes,
  14964. strFileName,
  14965. }));
  14966. }
  14967. else
  14968. {
  14969. return Ok(JsonView(false, "团组信息不存在!"));
  14970. }
  14971. }
  14972. /// <summary>
  14973. /// 导出团组成本
  14974. /// </summary>
  14975. /// <param name="dto"></param>
  14976. /// <returns></returns>
  14977. [HttpPost]
  14978. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14979. {
  14980. var jw = JsonView(false);
  14981. if (dto.Diid == 0)
  14982. {
  14983. return Ok(JsonView(false, "请传递团组id"));
  14984. }
  14985. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14986. if (deleInfo.Code != 0)
  14987. {
  14988. return Ok(JsonView(false, "团组信息查询失败!"));
  14989. }
  14990. var di = deleInfo.Data as DelegationInfoWebView;
  14991. if (di == null)
  14992. {
  14993. return Ok(JsonView(false, "团组信息查询失败!"));
  14994. }
  14995. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14996. WorkbookDesigner designer = new WorkbookDesigner();
  14997. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14998. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14999. List<int> hideColumnList = new List<int>();
  15000. var ColumnSetting = new[]
  15001. {
  15002. new { tag = "VF", Index = 4, P = "CarCost" },
  15003. new { tag = "VN", Index = 5, P = "CarNumber" },
  15004. new { tag = "VRD", Index = 6, P = "CarTiming" },
  15005. new { tag = "T/G S", Index = 7, P = "TGS" },
  15006. new { tag = "TGWH", Index = 8, P = "TGWH" },
  15007. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  15008. new { tag = "T/G M", Index = 10, P = "TGM" },
  15009. new { tag = "T/G A", Index = 11, P = "TGA" },
  15010. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  15011. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  15012. new { tag = "C/F S", Index = 14, P = "CFS" },
  15013. new { tag = "C/F M", Index = 15, P = "CFM" },
  15014. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  15015. new { tag = "B", Index = 17, P = "B" },
  15016. new { tag = "L", Index = 18, P = "L" },
  15017. new { tag = "D", Index = 19, P = "D" },
  15018. new { tag = "TBR", Index = 20, P = "TBR" },
  15019. new { tag = "SGR", Index = 21, P = "SGR" },
  15020. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  15021. new { tag = "Suite", Index = 23, P = "Suite" },
  15022. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  15023. new { tag = "T/V", Index = 25, P = "TV" },
  15024. new { tag = "1/L", Index = 26, P = "iL" },
  15025. new { tag = "I/F", Index = 27, P = "IF" },
  15026. new { tag = "EF", Index = 28, P = "EF" },
  15027. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  15028. new { tag = "TE", Index = 30, P = "TE" },
  15029. new { tag = "T/G T", Index = 31, P = "TGTips" },
  15030. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  15031. new { tag = "P/C", Index = 33, P = "PC" },
  15032. new { tag = "T/L F", Index = 34, P = "TLF" },
  15033. new { tag = "E/C T", Index = 35, P = "ECT" }
  15034. };
  15035. Func<string, bool> isEmpty = (str) =>
  15036. {
  15037. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  15038. {
  15039. return true;
  15040. }
  15041. if (string.IsNullOrWhiteSpace(str))
  15042. {
  15043. return true;
  15044. }
  15045. return false;
  15046. };
  15047. for (int i = 0; i < List_GC.Count; i++)
  15048. {
  15049. GroupCost_Excel gc = new GroupCost_Excel();
  15050. gc.Id = List_GC[i].Id;
  15051. gc.Diid = List_GC[i].Diid.ToString();
  15052. gc.DAY = List_GC[i].DAY;
  15053. string week = "";
  15054. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  15055. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  15056. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  15057. gc.ITIN = List_GC[i].ITIN;
  15058. gc.CarType = List_GC[i].CarType;
  15059. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  15060. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  15061. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  15062. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  15063. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  15064. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  15065. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  15066. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  15067. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  15068. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  15069. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  15070. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  15071. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  15072. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  15073. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  15074. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  15075. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  15076. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  15077. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  15078. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  15079. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  15080. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  15081. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  15082. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  15083. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  15084. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  15085. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  15086. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  15087. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  15088. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  15089. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  15090. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  15091. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  15092. gc.EFR = List_GC[i].EFR;
  15093. List_GC1.Add(gc);
  15094. }
  15095. if (List_GC1.Count > 0)
  15096. {
  15097. var p = List_GC1[0];
  15098. var prs = p.GetType().GetProperties();
  15099. foreach (var item in prs)
  15100. {
  15101. var tp = item.PropertyType;
  15102. if (tp == typeof(int))
  15103. {
  15104. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  15105. if (val == 0)
  15106. {
  15107. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15108. if (columnSetting != null)
  15109. {
  15110. hideColumnList.Add(columnSetting.Index);
  15111. }
  15112. }
  15113. }
  15114. if (tp == typeof(decimal))
  15115. {
  15116. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  15117. if (val == 0)
  15118. {
  15119. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15120. if (columnSetting != null)
  15121. {
  15122. hideColumnList.Add(columnSetting.Index);
  15123. }
  15124. }
  15125. }
  15126. if (tp == typeof(string))
  15127. {
  15128. var val = List_GC1.Sum(x =>
  15129. {
  15130. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  15131. if (decimal.TryParse(str, out decimal str_De))
  15132. {
  15133. return str_De;
  15134. }
  15135. else
  15136. {
  15137. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  15138. }
  15139. });
  15140. if (val == 0)
  15141. {
  15142. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15143. if (columnSetting != null)
  15144. {
  15145. hideColumnList.Add(columnSetting.Index);
  15146. }
  15147. }
  15148. }
  15149. }
  15150. }
  15151. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  15152. dt.TableName = "TB";
  15153. //报表标题等不用dt的值
  15154. designer.SetDataSource("TeamName", dto.title.TeamName);
  15155. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  15156. designer.SetDataSource("Tax", dto.title.Tax);
  15157. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  15158. designer.SetDataSource("Currency", dto.title.Currency);
  15159. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  15160. designer.SetDataSource("Rate", dto.title.Rate);
  15161. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  15162. var Aparams = hotels.Find(x => x.Type == "Default");
  15163. if (Aparams == null)
  15164. {
  15165. return Ok(jw);
  15166. }
  15167. //酒店数量
  15168. var txtSGRNumber = Aparams.SGR.ToString();
  15169. var txtTBRNumber = Aparams.TBR.ToString();
  15170. var txtJSESNumber = Aparams.JSES.ToString();
  15171. var txtSUITENumbe = Aparams.SUITE.ToString();
  15172. if (dto.costType == "B")
  15173. {
  15174. Aparams = hotels.Find(x => x.Type == "A");
  15175. var Bparams = hotels.Find(x => x.Type == "B");
  15176. if (Aparams == null || Bparams == null)
  15177. {
  15178. return Ok(jw);
  15179. }
  15180. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  15181. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  15182. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  15183. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  15184. }
  15185. designer.SetDataSource("SGRNumber", txtSGRNumber);
  15186. designer.SetDataSource("TBRNumber", txtTBRNumber);
  15187. designer.SetDataSource("JSESNumber", txtJSESNumber);
  15188. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  15189. var ws = designer.Workbook.Worksheets[1];
  15190. int Row = List_GC.Count;
  15191. int startIndex = 0;
  15192. int HideRows = 0;
  15193. Row = 0;
  15194. List<int> hideRowsList = new List<int>();
  15195. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  15196. #region A段left数据
  15197. var left = dto.leftInfo.Find(x => x.Type == "A");
  15198. if (left == null)
  15199. {
  15200. return Ok(jw);
  15201. }
  15202. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  15203. if (leftBindData != null)
  15204. {
  15205. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  15206. designer.SetDataSource("VisaRS", leftBindData.rs);
  15207. designer.SetDataSource("VisaXS", leftBindData.xs);
  15208. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15209. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15210. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15211. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15212. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15213. }
  15214. else
  15215. {
  15216. hideRowsList.Add(Row + startIndex + HideRows);
  15217. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15218. }
  15219. HideRows += 2;
  15220. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  15221. if (leftBindData != null)
  15222. {
  15223. designer.SetDataSource("BXDRCB", leftBindData.cb);
  15224. designer.SetDataSource("BXRS", leftBindData.rs);
  15225. designer.SetDataSource("BXXS", leftBindData.xs);
  15226. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15227. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15228. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15229. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15230. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15231. }
  15232. else
  15233. {
  15234. hideRowsList.Add(Row + startIndex + HideRows);
  15235. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15236. }
  15237. HideRows += 2;
  15238. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15239. if (leftBindData != null)
  15240. {
  15241. designer.SetDataSource("HSDRCB", leftBindData.cb);
  15242. designer.SetDataSource("HSRS", leftBindData.rs);
  15243. designer.SetDataSource("HSXS", leftBindData.xs);
  15244. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15245. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15246. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15247. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15248. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15249. }
  15250. else
  15251. {
  15252. hideRowsList.Add(Row + startIndex + HideRows);
  15253. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15254. }
  15255. HideRows += 2;
  15256. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15257. if (leftBindData != null)
  15258. {
  15259. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  15260. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  15261. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  15262. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15263. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15264. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15265. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15266. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15267. }
  15268. else
  15269. {
  15270. hideRowsList.Add(Row + startIndex + HideRows);
  15271. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15272. }
  15273. HideRows += 2;
  15274. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15275. if (leftBindData != null)
  15276. {
  15277. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  15278. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  15279. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  15280. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15281. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15282. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15283. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15284. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15285. }
  15286. else
  15287. {
  15288. hideRowsList.Add(Row + startIndex + HideRows);
  15289. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15290. }
  15291. HideRows += 2;
  15292. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15293. if (leftBindData != null)
  15294. {
  15295. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  15296. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  15297. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  15298. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15299. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15300. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15301. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15302. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15303. }
  15304. else
  15305. {
  15306. hideRowsList.Add(Row + startIndex + HideRows);
  15307. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15308. }
  15309. HideRows += 2;
  15310. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15311. if (leftBindData != null)
  15312. {
  15313. ////TBR
  15314. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  15315. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  15316. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  15317. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15318. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15319. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15320. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15321. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15322. }
  15323. else
  15324. {
  15325. hideRowsList.Add(Row + startIndex + HideRows);
  15326. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15327. }
  15328. HideRows += 2;
  15329. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15330. if (leftBindData != null)
  15331. {
  15332. ////SGR
  15333. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  15334. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  15335. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  15336. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15337. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15338. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15339. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15340. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15341. }
  15342. else
  15343. {
  15344. hideRowsList.Add(Row + startIndex + HideRows);
  15345. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15346. }
  15347. HideRows += 2;
  15348. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15349. if (leftBindData != null)
  15350. {
  15351. ////JS/ES
  15352. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  15353. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  15354. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  15355. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15356. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15357. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15358. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15359. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15360. }
  15361. else
  15362. {
  15363. hideRowsList.Add(Row + startIndex + HideRows);
  15364. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15365. }
  15366. HideRows += 2;
  15367. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15368. if (leftBindData != null)
  15369. {
  15370. ////SUITE
  15371. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  15372. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  15373. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  15374. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15375. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15376. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15377. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15378. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15379. }
  15380. else
  15381. {
  15382. hideRowsList.Add(Row + startIndex + HideRows);
  15383. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15384. }
  15385. HideRows += 2;
  15386. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15387. if (leftBindData != null)
  15388. {
  15389. designer.SetDataSource("DJDRCB", leftBindData.cb);
  15390. designer.SetDataSource("DJRS", leftBindData.rs);
  15391. designer.SetDataSource("DJXS", leftBindData.xs);
  15392. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15393. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15394. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15395. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15396. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15397. }
  15398. else
  15399. {
  15400. hideRowsList.Add(Row + startIndex + HideRows);
  15401. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15402. }
  15403. HideRows += 2;
  15404. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15405. if (leftBindData != null)
  15406. {
  15407. designer.SetDataSource("HCPCB", leftBindData.cb);
  15408. designer.SetDataSource("HCPRS", leftBindData.rs);
  15409. designer.SetDataSource("HCPXS", leftBindData.xs);
  15410. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15411. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15412. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15413. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15414. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15415. }
  15416. else
  15417. {
  15418. hideRowsList.Add(Row + startIndex + HideRows);
  15419. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15420. }
  15421. HideRows += 2;
  15422. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15423. if (leftBindData != null)
  15424. {
  15425. designer.SetDataSource("CPCB", leftBindData.cb);
  15426. designer.SetDataSource("CPRS", leftBindData.rs);
  15427. designer.SetDataSource("CPXS", leftBindData.xs);
  15428. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15429. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15430. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15431. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15432. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15433. }
  15434. else
  15435. {
  15436. hideRowsList.Add(Row + startIndex + HideRows);
  15437. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15438. }
  15439. HideRows += 2;
  15440. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15441. if (leftBindData != null)
  15442. {
  15443. designer.SetDataSource("GWDRCD", leftBindData.cb);
  15444. designer.SetDataSource("GWRS", leftBindData.rs);
  15445. designer.SetDataSource("GWXS", leftBindData.xs);
  15446. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15447. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15448. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15449. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15450. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15451. }
  15452. else
  15453. {
  15454. hideRowsList.Add(Row + startIndex + HideRows);
  15455. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15456. }
  15457. HideRows += 2;
  15458. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15459. if (leftBindData != null)
  15460. {
  15461. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  15462. designer.SetDataSource("LYJRS", leftBindData.rs);
  15463. designer.SetDataSource("LYJXS", leftBindData.xs);
  15464. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15465. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15466. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15467. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15468. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15469. }
  15470. else
  15471. {
  15472. hideRowsList.Add(Row + startIndex + HideRows);
  15473. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15474. }
  15475. #endregion
  15476. #region A段Right信息
  15477. var right = dto.rightInfo.Find(x => x.Type == "A");
  15478. if (right == null)
  15479. {
  15480. return Ok(jw);
  15481. }
  15482. HideRows += 4;
  15483. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15484. if (rightBindData != null)
  15485. {
  15486. //经济舱 + 双人间 TBR
  15487. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  15488. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  15489. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15490. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  15491. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15492. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15493. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15494. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15495. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15496. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15497. }
  15498. else
  15499. {
  15500. hideRowsList.Add(Row + startIndex + HideRows);
  15501. }
  15502. HideRows += 2;
  15503. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15504. if (rightBindData != null)
  15505. {
  15506. //经济舱 + 单人间 SGR
  15507. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  15508. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  15509. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15510. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  15511. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15512. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15513. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15514. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15515. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15516. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15517. }
  15518. else
  15519. {
  15520. hideRowsList.Add(Row + startIndex + HideRows);
  15521. }
  15522. HideRows += 2;
  15523. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15524. if (rightBindData != null)
  15525. {
  15526. //公务舱 + 单人间 SGR
  15527. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  15528. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  15529. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15530. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  15531. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15532. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15533. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15534. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15535. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15536. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15537. }
  15538. else
  15539. {
  15540. hideRowsList.Add(Row + startIndex + HideRows);
  15541. }
  15542. HideRows += 2;
  15543. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15544. if (rightBindData != null)
  15545. {
  15546. //公务舱 + 小套房 JSES
  15547. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  15548. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  15549. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15550. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  15551. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15552. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15553. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15554. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15555. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15556. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15557. }
  15558. else
  15559. {
  15560. hideRowsList.Add(Row + startIndex + HideRows);
  15561. }
  15562. HideRows += 2;
  15563. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15564. if (rightBindData != null)
  15565. {
  15566. //公务舱 + 小套房 JSES
  15567. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  15568. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  15569. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15570. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  15571. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15572. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15573. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15574. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15575. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15576. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15577. }
  15578. else
  15579. {
  15580. hideRowsList.Add(Row + startIndex + HideRows);
  15581. }
  15582. HideRows += 2;
  15583. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15584. if (rightBindData != null)
  15585. {
  15586. //经济舱 + 大套房
  15587. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15588. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15589. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15590. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15591. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15592. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15593. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15594. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15595. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15596. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15597. }
  15598. else
  15599. {
  15600. hideRowsList.Add(Row + startIndex + HideRows);
  15601. }
  15602. HideRows += 2;
  15603. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15604. if (rightBindData != null)
  15605. {
  15606. //头等舱 + 小套房 JSES
  15607. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15608. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15609. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15610. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15611. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15612. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15613. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15614. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15615. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15616. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15617. }
  15618. else
  15619. {
  15620. hideRowsList.Add(Row + startIndex + HideRows);
  15621. }
  15622. HideRows += 2;
  15623. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15624. if (rightBindData != null)
  15625. {
  15626. //头等舱 + 大套房
  15627. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15628. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15629. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15630. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15631. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15632. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15633. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15634. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15635. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15636. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15637. }
  15638. else
  15639. {
  15640. hideRowsList.Add(Row + startIndex + HideRows);
  15641. }
  15642. #endregion
  15643. #region B段标题清空
  15644. designer.SetDataSource("CostBDRCB", "");
  15645. designer.SetDataSource("CostBRS", "");
  15646. designer.SetDataSource("CostBXS", "");
  15647. designer.SetDataSource("CostBZCB", "");
  15648. designer.SetDataSource("CostBDRBJ", "");
  15649. designer.SetDataSource("CostBZBJ", "");
  15650. designer.SetDataSource("CostBDRLR", "");
  15651. designer.SetDataSource("CostBZLR", "");
  15652. designer.SetDataSource("CostBDRCBOM", "");
  15653. designer.SetDataSource("CostBRSOM", "");
  15654. designer.SetDataSource("CostBZCBOM", "");
  15655. designer.SetDataSource("CostBDRBJOM", "");
  15656. designer.SetDataSource("CostBZBJOM", "");
  15657. designer.SetDataSource("CostBDRLROM", "");
  15658. designer.SetDataSource("CostBZLROM", "");
  15659. #endregion
  15660. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15661. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15662. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15663. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15664. designer.SetDataSource("DJName", "地接(CNY)");
  15665. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15666. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15667. designer.SetDataSource("GWName", "公务(CNY)");
  15668. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15669. designer.SetDataSource("LYJName", "零用金(CNY)");
  15670. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15671. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15672. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15673. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15674. designer.SetDataSource("BXName", "保险(CNY)");
  15675. designer.SetDataSource("VisaName", "签证(CNY)");
  15676. #region B段基本数据
  15677. if (dto.costType == "B")
  15678. {
  15679. left = dto.leftInfo.Find(x => x.Type == "B");
  15680. if (left == null)
  15681. {
  15682. return Ok(jw);
  15683. }
  15684. #region B段left数据
  15685. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15686. if (leftBindData != null)
  15687. {
  15688. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15689. designer.SetDataSource("BHSRS", leftBindData.rs);
  15690. designer.SetDataSource("BHSXS", leftBindData.xs);
  15691. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15692. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15693. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15694. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15695. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15696. }
  15697. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15698. if (leftBindData != null)
  15699. {
  15700. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15701. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15702. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15703. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15704. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15705. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15706. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15707. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15708. }
  15709. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15710. if (leftBindData != null)
  15711. {
  15712. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15713. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15714. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15715. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15716. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15717. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15718. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15719. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15720. }
  15721. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15722. if (leftBindData != null)
  15723. {
  15724. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15725. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15726. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15727. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15728. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15729. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15730. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15731. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15732. }
  15733. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15734. if (leftBindData != null)
  15735. {
  15736. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15737. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15738. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15739. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15740. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15741. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15742. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15743. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15744. }
  15745. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15746. if (leftBindData != null)
  15747. {
  15748. designer.SetDataSource("BCPCB", leftBindData.cb);
  15749. designer.SetDataSource("BCPRS", leftBindData.rs);
  15750. designer.SetDataSource("BCPXS", leftBindData.xs);
  15751. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15752. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15753. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15754. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15755. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15756. }
  15757. //TBR
  15758. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15759. if (leftBindData != null)
  15760. {
  15761. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15762. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15763. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15764. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15765. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15766. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15767. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15768. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15769. }
  15770. //SGR
  15771. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15772. if (leftBindData != null)
  15773. {
  15774. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15775. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15776. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15777. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15778. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15779. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15780. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15781. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15782. }
  15783. //JS/ES
  15784. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15785. if (leftBindData != null)
  15786. {
  15787. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15788. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15789. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15790. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15791. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15792. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15793. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15794. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15795. }
  15796. //SUITE
  15797. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15798. if (leftBindData != null)
  15799. {
  15800. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15801. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15802. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15803. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15804. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15805. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15806. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15807. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15808. }
  15809. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15810. if (leftBindData != null)
  15811. {
  15812. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15813. designer.SetDataSource("BDJRS", leftBindData.rs);
  15814. designer.SetDataSource("BDJXS", leftBindData.xs);
  15815. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15816. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15817. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15818. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15819. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15820. }
  15821. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15822. if (leftBindData != null)
  15823. {
  15824. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15825. designer.SetDataSource("BGWRS", leftBindData.rs);
  15826. designer.SetDataSource("BGWXS", leftBindData.xs);
  15827. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15828. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15829. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15830. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15831. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15832. }
  15833. #region 优化方案
  15834. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15835. //excelBind.Add("零用金", new {
  15836. //cb="",
  15837. //rs="",
  15838. //xs ="",
  15839. //zcb = "",
  15840. //});
  15841. #endregion
  15842. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15843. if (leftBindData != null)
  15844. {
  15845. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15846. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15847. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15848. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15849. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15850. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15851. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15852. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15853. }
  15854. #endregion
  15855. #region B段Right信息
  15856. right = dto.rightInfo.Find(x => x.Type == "B");
  15857. if (right == null)
  15858. {
  15859. return Ok(jw);
  15860. }
  15861. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15862. if (rightBindData != null)
  15863. {
  15864. //经济舱 + 双人间 TBR
  15865. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15866. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15867. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15868. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15869. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15870. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15871. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15872. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15873. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15874. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15875. }
  15876. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15877. if (rightBindData != null)
  15878. {
  15879. //经济舱 + 单人间 SGR
  15880. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15881. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15882. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15883. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15884. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15885. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15886. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15887. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15888. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15889. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15890. }
  15891. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15892. if (rightBindData != null)
  15893. {
  15894. //公务舱 + 单人间 SGR
  15895. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15896. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15897. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15898. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15899. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15900. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15901. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15902. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15903. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15904. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15905. }
  15906. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15907. if (rightBindData != null)
  15908. {
  15909. //公务舱 + 小套房 JSES
  15910. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15911. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15912. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15913. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15914. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15915. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15916. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15917. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15918. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15919. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15920. }
  15921. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15922. if (rightBindData != null)
  15923. {
  15924. //公务舱 + 小套房 JSES
  15925. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15926. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15927. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15928. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15929. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15930. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15931. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15932. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15933. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15934. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15935. }
  15936. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15937. if (rightBindData != null)
  15938. {
  15939. //经济舱 + 大套房
  15940. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15941. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15942. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15943. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15944. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15945. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15946. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15947. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15948. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15949. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15950. }
  15951. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15952. if (rightBindData != null)
  15953. {
  15954. //头等舱 + 小套房 JSES
  15955. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15956. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15957. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15958. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15959. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15960. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15961. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15962. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15963. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15964. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15965. }
  15966. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15967. if (rightBindData != null)
  15968. {
  15969. //头等舱 + 大套房
  15970. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15971. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15972. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15973. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15974. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15975. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15976. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15977. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15978. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15979. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15980. }
  15981. #endregion
  15982. #region 标题
  15983. designer.SetDataSource("CostBDRCB", "单人成本");
  15984. designer.SetDataSource("CostBRS", "人数");
  15985. designer.SetDataSource("CostBXS", "系数");
  15986. designer.SetDataSource("CostBZCB", "总成本");
  15987. designer.SetDataSource("CostBDRBJ", "单人报价");
  15988. designer.SetDataSource("CostBZBJ", "总报价");
  15989. designer.SetDataSource("CostBDRLR", "单人利润");
  15990. designer.SetDataSource("CostBZLR", "总利润");
  15991. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15992. designer.SetDataSource("CostBRSOM", "人数");
  15993. designer.SetDataSource("CostBZCBOM", "总成本");
  15994. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15995. designer.SetDataSource("CostBZBJOM", "总报价");
  15996. designer.SetDataSource("CostBDRLROM", "单人利润");
  15997. designer.SetDataSource("CostBZLROM", "总利润");
  15998. #endregion
  15999. }
  16000. #endregion
  16001. designer.SetDataSource("TzZCB2", TzZCB2);
  16002. designer.SetDataSource("TzZBJ2", TzZBJ2);
  16003. designer.SetDataSource("TzZLR2", TzZLR2);
  16004. string[] dataSourceKeys = new string[]
  16005. {
  16006. "VF",
  16007. "TGS",
  16008. "TGOF",
  16009. "TGM",
  16010. "TGA",
  16011. "TGTF",
  16012. "TGEF",
  16013. "CFM",
  16014. "CFOF",
  16015. "B",
  16016. "L",
  16017. "D",
  16018. "TBR",
  16019. "SGR",
  16020. "JSES",
  16021. "Suite",
  16022. "TV",
  16023. "1L",
  16024. "IF",
  16025. "EF",
  16026. "BRF",
  16027. "TE",
  16028. "TGT",
  16029. "DRVT",
  16030. "PC",
  16031. "TLF",
  16032. "ECT"
  16033. };
  16034. foreach (var item in dataSourceKeys)
  16035. {
  16036. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  16037. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  16038. var find = dto.titleModel.FirstOrDefault(expr);
  16039. if (find != null)
  16040. {
  16041. designer.SetDataSource(item, find.text);
  16042. }
  16043. else
  16044. {
  16045. designer.SetDataSource(item, 0);
  16046. }
  16047. }
  16048. designer.SetDataSource(dt);
  16049. //根据数据源处理生成报表内容
  16050. designer.Process();
  16051. designer.Workbook.Worksheets[0].Name = "费用明细";
  16052. designer.Workbook.Worksheets[1].Name = "费用总核算";
  16053. Worksheet sheet = designer.Workbook.Worksheets[0];
  16054. #region 隐藏舱位
  16055. var settingAir = new[]
  16056. {
  16057. new { key = "经济舱", index = 7 },
  16058. new { key = "公务舱", index = 19 },
  16059. new { key = "头等舱", index = 11 }
  16060. };
  16061. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  16062. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  16063. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  16064. .Select((c, s) => s.Name)
  16065. .ToList()
  16066. .GroupBy(x => x)
  16067. .Select(x => x.Key);
  16068. foreach (var item in settingAir)
  16069. {
  16070. if (!airType.Contains(item.key))
  16071. {
  16072. hideRowsList.Add(item.index);
  16073. }
  16074. }
  16075. #endregion
  16076. foreach (var Rowindex in hideRowsList)
  16077. {
  16078. ws.Cells.HideRows(Rowindex, 2);
  16079. }
  16080. ws = designer.Workbook.Worksheets[0];
  16081. foreach (var Column in hideColumnList)
  16082. {
  16083. ws.Cells.HideColumns(Column, 1);
  16084. }
  16085. byte[] bytes = null;
  16086. string strFileName = di.TeamName + "-团组-成本.xls";
  16087. using (MemoryStream stream = new MemoryStream())
  16088. {
  16089. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  16090. bytes = stream.ToArray();
  16091. }
  16092. return Ok(JsonView(true, "", new
  16093. {
  16094. Data = bytes,
  16095. strFileName,
  16096. }));
  16097. }
  16098. /// <summary>
  16099. /// 导出客户报表
  16100. /// </summary>
  16101. /// <returns></returns>
  16102. [HttpPost]
  16103. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  16104. {
  16105. var jw = JsonView(false);
  16106. if (dto.Diid == 0)
  16107. {
  16108. return Ok(JsonView(false, "请传递团组id"));
  16109. }
  16110. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  16111. if (deleInfo.Code != 0)
  16112. {
  16113. return Ok(JsonView(false, "团组信息查询失败!"));
  16114. }
  16115. var di = deleInfo.Data as DelegationInfoWebView;
  16116. if (di == null)
  16117. {
  16118. return Ok(JsonView(false, "团组信息查询失败!"));
  16119. }
  16120. //文件名
  16121. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  16122. //获取模板
  16123. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  16124. //载入模板
  16125. Document doc = new Document(tmppath);
  16126. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  16127. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  16128. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  16129. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  16130. var AParameter = ParameterList.Find(x => x.CostType == "A");
  16131. var BParameter = ParameterList.Find(x => x.CostType == "B");
  16132. if (AParameter == null)
  16133. {
  16134. return Ok(JsonView(false, "系数不存在!"));
  16135. }
  16136. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  16137. , TzAirDesc, TzZCost;
  16138. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  16139. = TzAirDesc = TzZCost = string.Empty;
  16140. TzNumber = AParameter.CostTypenumber.ToString();
  16141. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  16142. CarGuides1 = dto.CarGuides1;
  16143. Meal = dto.Meal;
  16144. SubsidizedMeals = dto.SubsidizedMeals;
  16145. NightRepair = dto.NightRepair;
  16146. AttractionsTickets = dto.AttractionsTickets;
  16147. MiscellaneousFees = dto.MiscellaneousFees;
  16148. ATip = dto.ATip;
  16149. TzHotelDesc = "";
  16150. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  16151. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  16152. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  16153. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  16154. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  16155. TzAirDesc = "";
  16156. TzZCost = dto.TzZCost;
  16157. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  16158. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  16159. var index = 1;
  16160. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  16161. foreach (var item in TzHotelDescArr)
  16162. {
  16163. if (AinfoArr != null)
  16164. {
  16165. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16166. if (Ainfo != null)
  16167. {
  16168. if (int.Parse(Ainfo.rs) <= 0)
  16169. {
  16170. continue;
  16171. }
  16172. var hotelText = string.Empty;
  16173. switch (item)
  16174. {
  16175. case "SGR":
  16176. hotelText = "单人间";
  16177. break;
  16178. case "JSES":
  16179. hotelText = "小套房";
  16180. break;
  16181. case "SUITE":
  16182. hotelText = "套房";
  16183. break;
  16184. case "TBR":
  16185. hotelText = "双人间";
  16186. break;
  16187. }
  16188. if (item != "TBR")
  16189. {
  16190. 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";
  16191. }
  16192. else
  16193. {
  16194. 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";
  16195. }
  16196. index++;
  16197. }
  16198. }
  16199. }
  16200. index = 1;
  16201. foreach (var item in TzAirDescArr)
  16202. {
  16203. if (AinfoArr != null)
  16204. {
  16205. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16206. if (Ainfo != null)
  16207. {
  16208. if (int.Parse(Ainfo.rs) <= 0)
  16209. {
  16210. continue;
  16211. }
  16212. 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";
  16213. index++;
  16214. }
  16215. }
  16216. }
  16217. if (dto.costType == "B")
  16218. {
  16219. if (BParameter == null)
  16220. {
  16221. return Ok(JsonView(false, "B段系数不存在!"));
  16222. }
  16223. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  16224. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  16225. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  16226. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  16227. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  16228. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  16229. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  16230. foreach (var item in TzHotelDescArr)
  16231. {
  16232. if (AinfoArr != null)
  16233. {
  16234. TzHotelDesc += "B段信息 \r\n";
  16235. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16236. if (Ainfo != null)
  16237. {
  16238. if (int.Parse(Ainfo.rs) <= 0)
  16239. {
  16240. continue;
  16241. }
  16242. var hotelText = string.Empty;
  16243. switch (item)
  16244. {
  16245. case "SGR":
  16246. hotelText = "单人间";
  16247. break;
  16248. case "JSES":
  16249. hotelText = "小套房";
  16250. break;
  16251. case "SUITE":
  16252. hotelText = "套房";
  16253. break;
  16254. case "TBR":
  16255. hotelText = "双人间";
  16256. break;
  16257. }
  16258. if (item != "TBR")
  16259. {
  16260. 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";
  16261. }
  16262. else
  16263. {
  16264. 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";
  16265. }
  16266. index++;
  16267. }
  16268. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  16269. }
  16270. }
  16271. index = 1;
  16272. foreach (var item in TzAirDescArr)
  16273. {
  16274. if (AinfoArr != null)
  16275. {
  16276. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16277. if (Ainfo != null)
  16278. {
  16279. if (int.Parse(Ainfo.rs) <= 0)
  16280. {
  16281. continue;
  16282. }
  16283. 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";
  16284. index++;
  16285. }
  16286. }
  16287. }
  16288. }
  16289. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  16290. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  16291. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  16292. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  16293. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  16294. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  16295. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  16296. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  16297. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  16298. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  16299. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  16300. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  16301. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  16302. DickeyValue.Add("Visa", Visa); // 签证单人报价
  16303. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  16304. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  16305. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  16306. DickeyValue.Add("TzZCost", TzZCost);
  16307. foreach (var key in DickeyValue.Keys)
  16308. {
  16309. if (doc.Range.Bookmarks[key] != null)
  16310. {
  16311. Bookmark mark = doc.Range.Bookmarks[key];
  16312. mark.Text = DickeyValue[key];
  16313. }
  16314. }
  16315. byte[] bytes = null;
  16316. string strFileName = di.TeamName + "-客户报价.doc";
  16317. using (MemoryStream stream = new MemoryStream())
  16318. {
  16319. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  16320. bytes = stream.ToArray();
  16321. }
  16322. return Ok(JsonView(true, "", new
  16323. {
  16324. Data = bytes,
  16325. strFileName,
  16326. }));
  16327. }
  16328. /// <summary>
  16329. /// 团组成本 各模块(酒店,地接,机票)成本提示
  16330. /// </summary>
  16331. /// <param name="dto"></param>
  16332. /// <returns></returns>
  16333. [HttpPost]
  16334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16335. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  16336. {
  16337. try
  16338. {
  16339. #region 参数验证
  16340. if (dto.DiId < 0)
  16341. {
  16342. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  16343. }
  16344. List<int> cTableIds = new List<int>() {
  16345. 76 ,//酒店预订
  16346. 77 ,//行程
  16347. 79 ,//车/导游地接
  16348. 80 ,//签证
  16349. 81 ,//邀请/公务活
  16350. 82 ,//团组客户保险
  16351. 85 ,//机票预订
  16352. 98 ,//其他款项
  16353. 285 ,//收款退还
  16354. 751 ,//酒店早餐
  16355. 1015 // 超支费用
  16356. };
  16357. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  16358. {
  16359. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  16360. }
  16361. #endregion
  16362. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  16363. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  16364. if (_GroupCostParameters.Count <= 0)
  16365. {
  16366. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  16367. }
  16368. if (_GroupCostParameters[0].IsShare == 0)
  16369. {
  16370. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  16371. }
  16372. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16373. //处理date为空问题
  16374. if (_GroupCosts.Count > 0)
  16375. {
  16376. for (int i = 0; i < _GroupCosts.Count; i++)
  16377. {
  16378. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  16379. {
  16380. if (i > 0)
  16381. {
  16382. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  16383. }
  16384. }
  16385. }
  16386. }
  16387. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  16388. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  16389. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  16390. string currCode = "";
  16391. #region currCode 验证
  16392. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  16393. if (isInt)
  16394. {
  16395. var currData = currDatas.Find(it => it.Id == intCurrency);
  16396. if (currData != null)
  16397. {
  16398. currCode = currData.Name;
  16399. }
  16400. }
  16401. else
  16402. {
  16403. currCode = _GroupCostParameters[0].Currency.Trim();
  16404. }
  16405. #endregion
  16406. //op,酒店单段模式存储
  16407. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  16408. {
  16409. CurrencyCode = currCode,
  16410. Rate = _GroupCostParameters[0].Rate,
  16411. CostType = _GroupCostParameters[0].CostType,
  16412. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  16413. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  16414. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  16415. };
  16416. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  16417. if (_GroupCostParameters.Count == 2)
  16418. {
  16419. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  16420. }
  16421. foreach (var item in _GroupCostParameters)
  16422. {
  16423. decimal _rate = 1;
  16424. decimal _rate1 = item.Rate;
  16425. decimal _scale = 1;
  16426. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  16427. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  16428. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  16429. //if (userInfo != null)
  16430. //{
  16431. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  16432. // {
  16433. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  16434. // {
  16435. // _scale = 1.00M;
  16436. // }
  16437. // }
  16438. //}
  16439. #endregion
  16440. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  16441. {
  16442. CurrencyCode = currCode,
  16443. Rate = _rate1,
  16444. CostType = item.CostType,
  16445. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  16446. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  16447. CostTypeNumber = item.CostTypenumber
  16448. };
  16449. if (_GroupCostParameters.Count > 1)
  16450. {
  16451. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  16452. }
  16453. else
  16454. {
  16455. modulePromptInfo.CostTypeNumber = item.LYJRS;
  16456. }
  16457. if (dto.CTable == 79)//
  16458. {
  16459. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  16460. modulePromptInfo.TotalCost = item.DJCB;
  16461. }
  16462. List<string> costTypes = new List<string>() { "A", "B" };
  16463. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  16464. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  16465. if (_GroupCostsDuplicates.Count() == 1)
  16466. {
  16467. _GroupCostsTypeData = _GroupCosts;
  16468. }
  16469. else
  16470. {
  16471. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  16472. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  16473. }
  16474. /*
  16475. * 76 酒店预订
  16476. * 77 行程
  16477. * 79 车/导游地接
  16478. * 80 签证
  16479. * 81 邀请/公务活动
  16480. * 82 团组客户保险
  16481. * 85 机票预订
  16482. * 98 其他款项
  16483. * 285 收款退还
  16484. * 751 酒店早餐
  16485. * 1015 超支费用
  16486. */
  16487. switch (dto.CTable)
  16488. {
  16489. case 76: // 酒店预订
  16490. _ModuleSubPromptInfo.AddRange(
  16491. _GroupCostsTypeData.Select(it => new
  16492. {
  16493. it.DAY,
  16494. it.Date,
  16495. it.ACCON,
  16496. it.ITIN,
  16497. it.SGR,
  16498. it.TBR,
  16499. it.JS_ES,
  16500. it.Suite
  16501. })
  16502. );
  16503. break;
  16504. case 79: // 车/导游地接
  16505. _ModuleSubPromptInfo.AddRange(
  16506. _GroupCostsTypeData.Select(it => new
  16507. {
  16508. Date = it.Date, //日期
  16509. CarFee = it.CarCost * _rate * _scale, //车费用
  16510. CarType = it.CarType, //车型
  16511. DriverFee = it.CFS * _rate * _scale, //司机工资
  16512. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  16513. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  16514. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  16515. GuideFee = it.TGS * _rate * _scale, //导游费用
  16516. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  16517. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  16518. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  16519. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  16520. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  16521. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  16522. Breakfast = it.B * _rate * _scale, //早餐费
  16523. Lunch = it.L * _rate * _scale, //午餐费
  16524. Dinner = it.D * _rate * _scale, //晚餐费
  16525. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  16526. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  16527. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  16528. TicketFee = it.EF * _rate * _scale, //门票费
  16529. TicketRemark = it.EFR, //门票费描述
  16530. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  16531. TravelSupplies = it.TE * _rate * _scale, //出行物资
  16532. SpentCash = it.PC * _rate * _scale, //零用金
  16533. LeadersFee = it.TLF * _rate * _scale, //领队费
  16534. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  16535. })
  16536. );
  16537. break;
  16538. case 85: // 机票
  16539. List<dynamic> datas = new List<dynamic>();
  16540. datas.Add(
  16541. new
  16542. {
  16543. AirType = "经济舱",
  16544. AirNum = item.JJCRS,
  16545. AirDRCB = item.JJCCB,
  16546. AirZCB = (item.JJCRS * item.JJCCB)
  16547. }
  16548. );
  16549. datas.Add(
  16550. new
  16551. {
  16552. AirType = "公务舱",
  16553. AirNum = item.GWCRS,
  16554. AirDRCB = item.GWCCB,
  16555. AirZCB = (item.GWCRS * item.GWCCB)
  16556. }
  16557. );
  16558. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16559. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  16560. modulePromptInfo.Data = new
  16561. {
  16562. airFeeData = datas,
  16563. airInitData = initDatas
  16564. };
  16565. _ModulePromptInfos.Add(modulePromptInfo);
  16566. break;
  16567. default:
  16568. break;
  16569. }
  16570. }
  16571. if (dto.CTable != 85)
  16572. {
  16573. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  16574. _ModulePromptInfos.Add(_ModulePromptInfo);
  16575. }
  16576. _view.ModulePromptInfos = _ModulePromptInfos;
  16577. return Ok(JsonView(true, "操作成功!", _view));
  16578. }
  16579. catch (Exception ex)
  16580. {
  16581. return Ok(JsonView(false, ex.Message));
  16582. }
  16583. }
  16584. /// <summary>
  16585. /// 根据黑屏代码重新生成行程
  16586. /// </summary>
  16587. /// <param name="dto"></param>
  16588. /// <returns></returns>
  16589. [HttpPost]
  16590. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  16591. {
  16592. var jw = JsonView(false, "Error");
  16593. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  16594. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  16595. .Select(x => new
  16596. {
  16597. x.Id,
  16598. x.Title
  16599. })
  16600. .ToList();
  16601. if (Create.Any())
  16602. {
  16603. jw.Msg = "获取成功!";
  16604. jw.Code = 200;
  16605. jw.Data = new
  16606. {
  16607. BlackCodeListSelect = Create,
  16608. blackCodeIsTrue = true
  16609. };
  16610. }
  16611. else
  16612. {
  16613. jw.Code = 400;
  16614. jw.Data = new
  16615. {
  16616. BlackCodeListSelect = Create,
  16617. blackCodeIsTrue = false,
  16618. };
  16619. }
  16620. return Ok(jw);
  16621. }
  16622. /// <summary>
  16623. /// 根据黑屏代码Id重新生成行程
  16624. /// </summary>
  16625. /// <param name="dto"></param>
  16626. /// <returns></returns>
  16627. [HttpPost]
  16628. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16629. {
  16630. var jw = JsonView(false, "Error");
  16631. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16632. if (result.Code == 0)
  16633. {
  16634. jw.Msg = "获取成功!";
  16635. jw.Code = 200;
  16636. jw.Data = new
  16637. {
  16638. groupCost = result.Data,
  16639. blackCodeIsTrue = true
  16640. };
  16641. }
  16642. else
  16643. {
  16644. jw.Code = 400;
  16645. jw.Data = new
  16646. {
  16647. groupCost = result.Data,
  16648. blackCodeIsTrue = false,
  16649. };
  16650. }
  16651. return Ok(jw);
  16652. }
  16653. /// <summary>
  16654. /// 成本获取OP历史车费用
  16655. /// </summary>
  16656. /// <param name="dto"></param>
  16657. /// <returns></returns>
  16658. [HttpPost]
  16659. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16660. {
  16661. var jw = JsonView(false);
  16662. try
  16663. {
  16664. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16665. //获取现有所有车的数据
  16666. if (!dto.Param.IsNullOrWhiteSpace())
  16667. {
  16668. string sql = $@"
  16669. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16670. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16671. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16672. 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
  16673. AND gctggr.ServiceEndTime is not NULL
  16674. ORDER by gctggrc.id DESC
  16675. ";
  16676. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16677. var numeberResult = await Task.Run(() =>
  16678. {
  16679. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16680. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16681. return numberArr;
  16682. });
  16683. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16684. foreach (var item in numeberResult)
  16685. {
  16686. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16687. {
  16688. Country = "数据异常!",
  16689. City = string.Empty,
  16690. };
  16691. item.Area = find.Country + " " + find.City;
  16692. }
  16693. dbResult.AddRange(numeberResult);
  16694. if (dto.Param.Contains("、"))
  16695. {
  16696. var sp = dto.Param.Split("、");
  16697. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16698. .Where(x =>
  16699. {
  16700. return System.Array.Exists(sp, e =>
  16701. {
  16702. bool where = false;
  16703. if (x.Area != null)
  16704. {
  16705. where = x.Area.Contains(e);
  16706. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16707. {
  16708. return false;
  16709. }
  16710. }
  16711. if (x.PriceName != null && !where)
  16712. {
  16713. where = x.PriceName.Contains(e);
  16714. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16715. {
  16716. return false;
  16717. }
  16718. }
  16719. return where;
  16720. });
  16721. }).ToList();
  16722. }
  16723. else
  16724. {
  16725. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16726. .Where(x =>
  16727. {
  16728. bool where = false;
  16729. if (x.Area != null)
  16730. {
  16731. where = x.Area.Contains(dto.Param);
  16732. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16733. {
  16734. return false;
  16735. }
  16736. }
  16737. if (x.PriceName != null && !where)
  16738. {
  16739. where = x.PriceName.Contains(dto.Param);
  16740. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16741. {
  16742. return false;
  16743. }
  16744. }
  16745. return where;
  16746. }
  16747. )
  16748. .ToList();
  16749. }
  16750. }
  16751. var view = dbResult.Select(x =>
  16752. {
  16753. decimal dp = 0.00M;
  16754. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16755. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16756. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16757. {
  16758. if (startB && endB)
  16759. {
  16760. var timesp = endD.Subtract(startD);
  16761. if ((timesp.Days + 1) != 0)
  16762. {
  16763. dp = x.Price / (timesp.Days + 1);
  16764. }
  16765. }
  16766. }
  16767. else
  16768. {
  16769. dp = x.Price;
  16770. }
  16771. return new
  16772. {
  16773. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16774. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16775. x.Area,
  16776. x.id,
  16777. price = x.Price.ToString("F2"),
  16778. x.PriceName,
  16779. x.PriceContent,
  16780. x.TeamName,
  16781. x.DatePrice,
  16782. dayPrice = dp.ToString("F2"),
  16783. };
  16784. }).OrderByDescending(x => x.id).ToList();
  16785. jw = JsonView(true, "获取成功!", view);
  16786. }
  16787. catch (Exception e)
  16788. {
  16789. jw = JsonView(false, e.Message);
  16790. }
  16791. return Ok(jw);
  16792. }
  16793. [HttpPost]
  16794. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16795. {
  16796. var jw = JsonView(true);
  16797. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16798. #region SQL语句
  16799. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16800. //{
  16801. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16802. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16803. // WHEN COUNT(*) >= 0 THEN 'True'
  16804. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16805. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16806. // ")
  16807. // .ToList();
  16808. //}
  16809. //else
  16810. //{
  16811. // string likeKey = string.Empty;
  16812. // foreach (var item in dto.Keyword)
  16813. // {
  16814. // likeKey += "%" + item;
  16815. // }
  16816. // likeKey += "%";
  16817. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16818. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16819. // WHEN COUNT(*) >= 0 THEN 'True'
  16820. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16821. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16822. // ")
  16823. // .ToList();
  16824. //}
  16825. #endregion
  16826. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16827. {
  16828. @KeyWord = dto.Keyword
  16829. });
  16830. if (table != null && table.Rows.Count > 0)
  16831. {
  16832. foreach (DataRow row in table.Rows)
  16833. {
  16834. matches.Add(new DelegationInfoAndIsTrueView
  16835. {
  16836. Id = row.Field<int>("Id"),
  16837. GroupName = row.Field<string>("GroupName"),
  16838. isTrue = row.Field<string>("isTrue")
  16839. });
  16840. }
  16841. }
  16842. if (matches.Any())
  16843. {
  16844. jw.Data = matches;
  16845. }
  16846. else
  16847. {
  16848. jw.Code = 201;
  16849. jw.Msg = "empty list";
  16850. jw.Data = new List<string>(1);
  16851. }
  16852. return Ok(jw);
  16853. }
  16854. /// <summary>
  16855. /// 报价Word下载
  16856. /// </summary>
  16857. /// <param name="dto"></param>
  16858. /// <returns></returns>
  16859. [HttpPost]
  16860. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16861. {
  16862. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16863. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16864. if (di == null)
  16865. {
  16866. return Ok(JsonView(false, "团组不存在!"));
  16867. }
  16868. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16869. if (mainPrice == null || mainPrice.IsShare == 0)
  16870. {
  16871. return Ok(JsonView(false, "团组成本不存在!"));
  16872. }
  16873. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16874. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16875. if (costTypeHotelNumbers == null)
  16876. {
  16877. return Ok(JsonView(false, "团组成本不存在!"));
  16878. }
  16879. //文件名
  16880. string strFileName = di.TeamName + "-收款账单.doc";
  16881. //获取模板
  16882. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16883. //载入模板
  16884. Document doc = new Document(tmppath);
  16885. decimal allPrice = 0.00M;
  16886. string itemStr = string.Empty;
  16887. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16888. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16889. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16890. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16891. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16892. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16893. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16894. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16895. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16896. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16897. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16898. {
  16899. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16900. ("BXRS", "BXCB", "BXXS", "bx"),
  16901. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16902. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16903. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16904. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16905. ("CPRS", "CPCB", "CPXS", "cp"),
  16906. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16907. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16908. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16909. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16910. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16911. ("DJRS", "DJCB", "DJXS", "dj"),
  16912. ("GWRS", "GWCB", "GWXS", "gw"),
  16913. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16914. };
  16915. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16916. var rightSum = 0.00M;
  16917. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16918. {
  16919. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16920. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16921. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16922. if (prefix == "tbr")
  16923. {
  16924. rsValue *= 2;
  16925. cbValue /= 2;
  16926. }
  16927. if (OtherCostPropertyBJ.Contains(prefix))
  16928. {
  16929. rightSum += cbValue * xsValue;
  16930. }
  16931. }
  16932. var hotelRooms = new Dictionary<string, int>
  16933. {
  16934. { "SGR", costTypeHotelNumbers.SGR },
  16935. { "TBR", costTypeHotelNumbers.TBR },
  16936. { "JSES", costTypeHotelNumbers.JSES },
  16937. { "SUITE", costTypeHotelNumbers.SUITE }
  16938. };
  16939. var flights = new Dictionary<string, int>
  16940. {
  16941. { "经济舱", mainPrice.JJCRS },
  16942. { "公务舱", mainPrice.GWCRS },
  16943. { "头等舱", mainPrice.TDCRS }
  16944. };
  16945. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16946. {
  16947. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16948. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16949. { "头等舱", new[] { "SUITE", "JSES" } }
  16950. };
  16951. var result = new Dictionary<string, int>();
  16952. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16953. foreach (var flight in flights.Keys)
  16954. {
  16955. // 获取当前舱位的匹配规则
  16956. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16957. {
  16958. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16959. }
  16960. }
  16961. #region right计算
  16962. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16963. {
  16964. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16965. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16966. airHotelPriceList.Add(new
  16967. AirHotelPrice
  16968. {
  16969. Name = "经济舱TBR",
  16970. Price = rightSum + air + hotel,
  16971. Count = result["经济舱TBR"] * 2
  16972. });
  16973. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16974. }
  16975. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16976. {
  16977. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16978. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16979. airHotelPriceList.Add(new
  16980. AirHotelPrice
  16981. {
  16982. Name = "经济舱SGR",
  16983. Price = rightSum + air + hotel,
  16984. Count = result["经济舱SGR"]
  16985. });
  16986. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16987. }
  16988. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16989. {
  16990. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16991. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16992. airHotelPriceList.Add(new
  16993. AirHotelPrice
  16994. {
  16995. Name = "公务舱SGR",
  16996. Price = rightSum + air + hotel,
  16997. Count = result["公务舱SGR"]
  16998. });
  16999. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17000. }
  17001. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17002. {
  17003. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17004. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17005. airHotelPriceList.Add(new
  17006. AirHotelPrice
  17007. {
  17008. Name = "公务舱JSES",
  17009. Price = rightSum + air + hotel,
  17010. Count = result["公务舱JSES"]
  17011. });
  17012. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17013. }
  17014. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17015. {
  17016. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17017. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17018. airHotelPriceList.Add(new
  17019. AirHotelPrice
  17020. {
  17021. Name = "公务舱SUITE",
  17022. Price = rightSum + air + hotel,
  17023. Count = result["公务舱SUITE"]
  17024. });
  17025. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17026. }
  17027. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17028. {
  17029. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17030. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17031. airHotelPriceList.Add(new
  17032. AirHotelPrice
  17033. {
  17034. Name = "经济舱SUITE",
  17035. Price = rightSum + air + hotel,
  17036. Count = result["经济舱SUITE"]
  17037. });
  17038. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17039. }
  17040. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17041. {
  17042. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17043. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17044. airHotelPriceList.Add(new
  17045. AirHotelPrice
  17046. {
  17047. Name = "头等舱JSES",
  17048. Price = rightSum + air + hotel,
  17049. Count = result["头等舱JSES"]
  17050. });
  17051. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17052. }
  17053. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17054. {
  17055. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17056. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17057. airHotelPriceList.Add(new
  17058. AirHotelPrice
  17059. {
  17060. Name = "头等舱SUITE",
  17061. Price = rightSum + air + hotel,
  17062. Count = result["头等舱SUITE"]
  17063. });
  17064. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17065. }
  17066. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17067. {
  17068. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17069. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17070. airHotelPriceList.Add(new
  17071. AirHotelPrice
  17072. {
  17073. Name = "经济舱JSES",
  17074. Price = rightSum + air + hotel,
  17075. Count = result["经济舱JSES"]
  17076. });
  17077. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17078. }
  17079. #endregion
  17080. foreach (var item in airSouer.Keys)
  17081. {
  17082. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  17083. if (find != null && find.Count > 0)
  17084. {
  17085. if (item.Contains("TBR"))
  17086. {
  17087. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17088. }
  17089. else
  17090. {
  17091. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17092. }
  17093. }
  17094. }
  17095. #region 替换Word模板书签内容
  17096. Dictionary<string, string> marks = new Dictionary<string, string>();
  17097. marks.Add("To", di.ClientUnit);//付款方
  17098. marks.Add("ToTel", di.TellPhone);//付款方电话
  17099. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17100. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17101. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17102. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17103. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17104. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17105. marks.Add("PayItemContent", itemStr);//详细信息
  17106. marks.Add("Total", allPrice.ToString("F2"));//合计
  17107. #endregion
  17108. foreach (var item in marks.Keys)
  17109. {
  17110. if (doc.Range.Bookmarks[item] != null)
  17111. {
  17112. Bookmark mark = doc.Range.Bookmarks[item];
  17113. mark.Text = marks[item];
  17114. }
  17115. }
  17116. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  17117. doc.Save(savePaht);
  17118. var jw = new JsonView();
  17119. jw.Msg = "生成成功!";
  17120. jw.Code = 200;
  17121. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  17122. return Ok(jw);
  17123. }
  17124. /// <summary>
  17125. /// 详细报价费用Excel下载
  17126. /// </summary>
  17127. /// <param name="dto"></param>
  17128. /// <returns></returns>
  17129. [HttpPost]
  17130. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  17131. {
  17132. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17133. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17134. if (di == null)
  17135. {
  17136. return Ok(JsonView(false, "团组不存在!"));
  17137. }
  17138. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17139. if (mainPrice == null || mainPrice.IsShare == 0)
  17140. {
  17141. return Ok(JsonView(false, "团组成本不存在!"));
  17142. }
  17143. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17144. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17145. if (costTypeHotelNumbers == null)
  17146. {
  17147. return Ok(JsonView(false, "团组成本不存在!"));
  17148. }
  17149. WorkbookDesigner designer = new WorkbookDesigner();
  17150. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  17151. List<int> hideRowsList = new List<int>();
  17152. int conterStartIndex = 3;
  17153. int rowIndex = conterStartIndex;
  17154. designer.SetDataSource("GroupName", di.TeamName);
  17155. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17156. {
  17157. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17158. ("BXRS", "BXCB", "BXXS", "bx"),
  17159. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17160. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17161. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  17162. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  17163. ("CPRS", "CPCB", "CPXS", "cp") ,
  17164. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  17165. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  17166. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  17167. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  17168. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  17169. ("DJRS", "DJCB", "DJXS", "dj") ,
  17170. ("GWRS", "GWCB", "GWXS", "gw") ,
  17171. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  17172. };
  17173. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17174. var rightSum = 0.00M;
  17175. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17176. {
  17177. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17178. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17179. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17180. if (prefix == "tbr")
  17181. {
  17182. rsValue *= 2;
  17183. cbValue /= 2;
  17184. }
  17185. if (OtherCostPropertyBJ.Contains(prefix))
  17186. {
  17187. rightSum += cbValue * xsValue;
  17188. }
  17189. if (rsValue == 0)
  17190. {
  17191. hideRowsList.Add(rowIndex);
  17192. }
  17193. else
  17194. {
  17195. designer.SetDataSource($"{prefix}rs", rsValue);
  17196. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  17197. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  17198. }
  17199. rowIndex += 2;
  17200. }
  17201. var hotelRooms = new Dictionary<string, int>
  17202. {
  17203. { "SGR", costTypeHotelNumbers.SGR },
  17204. { "TBR", costTypeHotelNumbers.TBR },
  17205. { "JSES", costTypeHotelNumbers.JSES },
  17206. { "SUITE", costTypeHotelNumbers.SUITE }
  17207. };
  17208. var flights = new Dictionary<string, int>
  17209. {
  17210. { "经济舱", mainPrice.JJCRS },
  17211. { "公务舱", mainPrice.GWCRS },
  17212. { "头等舱", mainPrice.TDCRS }
  17213. };
  17214. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17215. {
  17216. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17217. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17218. { "头等舱", new[] { "SUITE", "JSES" } }
  17219. };
  17220. var result = new Dictionary<string, int>();
  17221. foreach (var flight in flights.Keys)
  17222. {
  17223. // 获取当前舱位的匹配规则
  17224. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17225. {
  17226. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17227. }
  17228. }
  17229. var allPrice = 0.00M;
  17230. #region right计算
  17231. int airRowIndex = 35;
  17232. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17233. {
  17234. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17235. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17236. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  17237. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  17238. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  17239. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17240. }
  17241. else
  17242. {
  17243. hideRowsList.Add(airRowIndex);
  17244. }
  17245. airRowIndex += 2;
  17246. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17247. {
  17248. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17249. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17250. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  17251. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  17252. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  17253. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17254. }
  17255. else
  17256. {
  17257. hideRowsList.Add(airRowIndex);
  17258. }
  17259. airRowIndex += 2;
  17260. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17261. {
  17262. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17263. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17264. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  17265. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  17266. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  17267. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17268. }
  17269. else
  17270. {
  17271. hideRowsList.Add(airRowIndex);
  17272. }
  17273. airRowIndex += 2;
  17274. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17275. {
  17276. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17277. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17278. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  17279. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  17280. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  17281. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17282. }
  17283. else
  17284. {
  17285. hideRowsList.Add(airRowIndex);
  17286. }
  17287. airRowIndex += 2;
  17288. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17289. {
  17290. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17291. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17292. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  17293. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  17294. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  17295. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17296. }
  17297. else
  17298. {
  17299. hideRowsList.Add(airRowIndex);
  17300. }
  17301. airRowIndex += 2;
  17302. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17303. {
  17304. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17305. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17306. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  17307. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  17308. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  17309. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17310. }
  17311. else
  17312. {
  17313. hideRowsList.Add(airRowIndex);
  17314. }
  17315. airRowIndex += 2;
  17316. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17317. {
  17318. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17319. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17320. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  17321. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  17322. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  17323. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17324. }
  17325. else
  17326. {
  17327. hideRowsList.Add(airRowIndex);
  17328. }
  17329. airRowIndex += 2;
  17330. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17331. {
  17332. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17333. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17334. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  17335. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  17336. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  17337. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17338. }
  17339. else
  17340. {
  17341. hideRowsList.Add(airRowIndex);
  17342. }
  17343. airRowIndex += 2;
  17344. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17345. {
  17346. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17347. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17348. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  17349. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  17350. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  17351. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17352. }
  17353. else
  17354. {
  17355. hideRowsList.Add(airRowIndex);
  17356. }
  17357. #endregion
  17358. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  17359. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  17360. var ws = designer.Workbook.Worksheets[0];
  17361. foreach (var Rowindex in hideRowsList)
  17362. {
  17363. ws.Cells.HideRows(Rowindex, 2);
  17364. }
  17365. designer.Process();
  17366. designer.Workbook.Save(savePaht);
  17367. return Ok(JsonView(true, "生成成功!", new
  17368. {
  17369. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  17370. }));
  17371. }
  17372. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  17373. {
  17374. foreach (var roomType in roomTypes)
  17375. {
  17376. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  17377. {
  17378. hotelRooms[roomType]--;
  17379. flights[flightType]--;
  17380. if (roomType == "TBR")
  17381. {
  17382. flights[flightType]--; // 双人间在减少1
  17383. }
  17384. string key = flightType + roomType;
  17385. if (result.Keys.Contains(key))
  17386. {
  17387. result[key]++;
  17388. }
  17389. else
  17390. {
  17391. result.Add(key, 1);
  17392. }
  17393. }
  17394. }
  17395. }
  17396. private class AirHotelPrice
  17397. {
  17398. public string Name { get; set; }
  17399. public decimal Price { get; set; }
  17400. public int Count { get; set; }
  17401. }
  17402. /// <summary>
  17403. /// 团组系数设置
  17404. /// </summary>
  17405. /// <param name="dto"></param>
  17406. /// <returns></returns>
  17407. [HttpPost]
  17408. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  17409. {
  17410. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17411. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17412. if (di == null)
  17413. {
  17414. return Ok(JsonView(false, "团组不存在!"));
  17415. }
  17416. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  17417. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  17418. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  17419. // FirstAsync(firstExpression.ToExpression());
  17420. #region JSON
  17421. string hcpJson = @"
  17422. [
  17423. {
  17424. ""min"": 1,
  17425. ""max"": 500,
  17426. ""value"": 1.50
  17427. },
  17428. {
  17429. ""min"": 501,
  17430. ""max"": 1000,
  17431. ""value"": 1.40
  17432. },
  17433. {
  17434. ""min"": 1001,
  17435. ""max"": 2000,
  17436. ""value"": 1.35
  17437. }
  17438. ]";
  17439. #endregion
  17440. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  17441. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  17442. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  17443. .ToList();
  17444. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  17445. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  17446. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  17447. // new List<(Predicate<decimal>, decimal)>()
  17448. // {
  17449. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  17450. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  17451. // }
  17452. // ));
  17453. #region 签证系数
  17454. var visaXS = 0.00M;
  17455. switch (dto.VisaCB)
  17456. {
  17457. case decimal n when (n > 1 && n < 500):
  17458. switch (dto.VisaRS)
  17459. {
  17460. case 2 or 3:
  17461. visaXS = 1.35M;
  17462. break;
  17463. case 4 or 5:
  17464. visaXS = 1.30M;
  17465. break;
  17466. case 6 or 7:
  17467. visaXS = 1.25M;
  17468. break;
  17469. case 8 or 9 or 10:
  17470. visaXS = 1.20M;
  17471. break;
  17472. case > 10:
  17473. visaXS = 1.15M;
  17474. break;
  17475. default:
  17476. visaXS = 0.00M;
  17477. break;
  17478. }
  17479. break;
  17480. case decimal n when (n >= 500 && n < 1000):
  17481. switch (dto.VisaRS)
  17482. {
  17483. case 2 or 3 or 4:
  17484. visaXS = 1.30M;
  17485. break;
  17486. case 5 or 6 or 7 or 8:
  17487. visaXS = 1.25M;
  17488. break;
  17489. case 9 or 10:
  17490. visaXS = 1.20M;
  17491. break;
  17492. case > 10:
  17493. visaXS = 1.15M;
  17494. break;
  17495. default:
  17496. visaXS = 0.00M;
  17497. break;
  17498. }
  17499. break;
  17500. default:
  17501. switch (dto.VisaRS)
  17502. {
  17503. case 2 or 3 or 4:
  17504. visaXS = 1.30M;
  17505. break;
  17506. case 5 or 6 or 7 or 8:
  17507. visaXS = 1.25M;
  17508. break;
  17509. case 9 or 10:
  17510. visaXS = 1.20M;
  17511. break;
  17512. case > 10:
  17513. visaXS = 1.15M;
  17514. break;
  17515. default:
  17516. visaXS = 0.00M;
  17517. break;
  17518. }
  17519. break;
  17520. }
  17521. #endregion
  17522. #region 火车系数
  17523. var hcpXS = 0.00M;
  17524. foreach (var (condition, result) in hcpSwitchDictionary)
  17525. {
  17526. if (condition(dto.HCPCB))
  17527. {
  17528. hcpXS = result;
  17529. break;
  17530. }
  17531. }
  17532. #endregion
  17533. #region 机票系数
  17534. #region 经济舱系数
  17535. var jjcXS = 0.00M;
  17536. switch (dto.JJCCB)
  17537. {
  17538. case decimal x when (x >= 1000 && x <= 3000):
  17539. jjcXS = 2.6M;
  17540. break;
  17541. case decimal x when (x >= 3001 && x <= 8000):
  17542. jjcXS = 2.3M;
  17543. break;
  17544. case decimal x when (x >= 8001 && x <= 15000):
  17545. jjcXS = 2.1M;
  17546. break;
  17547. case decimal x when (x >= 15001 && x <= 30000):
  17548. jjcXS = 1.95M;
  17549. break;
  17550. case > 30000:
  17551. jjcXS = 1.8M;
  17552. break;
  17553. default:
  17554. break;
  17555. }
  17556. #endregion
  17557. #region 公务舱系数
  17558. var gwcXS = 0.00M;
  17559. switch (dto.GWCCB)
  17560. {
  17561. case decimal x when (x >= 1000 && x <= 3000):
  17562. gwcXS = 2.5M;
  17563. break;
  17564. case decimal x when (x >= 3001 && x <= 8000):
  17565. gwcXS = 2.2M;
  17566. break;
  17567. case decimal x when (x >= 8001 && x <= 15000):
  17568. gwcXS = 2.0M;
  17569. break;
  17570. case decimal x when (x >= 15001 && x <= 30000):
  17571. gwcXS = 1.85M;
  17572. break;
  17573. case > 30000:
  17574. gwcXS = 1.7M;
  17575. break;
  17576. default:
  17577. break;
  17578. }
  17579. #endregion
  17580. #region 头等舱系数
  17581. var tdcXS = 0.00M;
  17582. switch (dto.TDCCB)
  17583. {
  17584. case > 70000:
  17585. tdcXS = 1.5M;
  17586. break;
  17587. default:
  17588. tdcXS = 1.9M;
  17589. break;
  17590. }
  17591. #endregion
  17592. #endregion
  17593. #region 酒店系数
  17594. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  17595. {
  17596. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  17597. {1.5M, new List<string>(){"越南社会主义共和国",
  17598. "老挝",
  17599. "柬埔寨",
  17600. "泰国",
  17601. "缅甸",
  17602. "马来西亚",
  17603. //"新加坡",
  17604. "文莱达鲁萨兰",
  17605. "印度尼西亚",
  17606. "东帝汶"}},
  17607. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  17608. };
  17609. #region SGR
  17610. var sgrXS = 1.25M;
  17611. #endregion
  17612. #region TBR
  17613. var tbrXS = 1.25M;
  17614. #endregion
  17615. #region JSES
  17616. var jsesXS = 1.25M;
  17617. #endregion
  17618. #region SUITE
  17619. var suiteXS = 1.25M;
  17620. #endregion
  17621. var countryArr = di.VisitCountry.Split("|");
  17622. foreach (var item in dic)
  17623. {
  17624. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  17625. .Count();
  17626. if (extsisCount > 0)
  17627. {
  17628. jsesXS = item.Key;
  17629. sgrXS = item.Key;
  17630. tbrXS = item.Key;
  17631. suiteXS = item.Key;
  17632. }
  17633. }
  17634. #endregion
  17635. #region 地接系数
  17636. var djXS = 0.00M;
  17637. switch (dto.DJRS)
  17638. {
  17639. case 2 or 3:
  17640. djXS = 2.65M;
  17641. break;
  17642. case 4:
  17643. djXS = 2.6M;
  17644. break;
  17645. case 5 or 6:
  17646. djXS = 2.5M;
  17647. break;
  17648. case 7 or 8:
  17649. djXS = 2.4M;
  17650. break;
  17651. case 9 or 10:
  17652. djXS = 2.3M;
  17653. break;
  17654. case 11:
  17655. djXS = 2.2M;
  17656. break;
  17657. case 12:
  17658. djXS = 2.1M;
  17659. break;
  17660. case 13 or 14:
  17661. djXS = 2M;
  17662. break;
  17663. case 15:
  17664. djXS = 1.9M;
  17665. break;
  17666. case 16 or 17 or 18:
  17667. djXS = 1.8M;
  17668. break;
  17669. case 19 or 20:
  17670. djXS = 1.7M;
  17671. break;
  17672. }
  17673. #endregion
  17674. #region 零用金系数
  17675. var lyjXS = 0.00M;
  17676. switch (dto.LYJRS)
  17677. {
  17678. case 2:
  17679. lyjXS = 1.25M;
  17680. break;
  17681. case 3 or 4 or 5:
  17682. lyjXS = 1.2M;
  17683. break;
  17684. case int number when (number > 5 && number < 10):
  17685. lyjXS = 1.15M;
  17686. break;
  17687. case > 10:
  17688. lyjXS = 1.1M;
  17689. break;
  17690. default:
  17691. break;
  17692. }
  17693. #endregion
  17694. return Ok(JsonView(true, "查询成功", new ArrayList()
  17695. {
  17696. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  17697. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  17698. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  17699. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  17700. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  17701. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  17702. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  17703. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  17704. new { label = "地接系数", value = djXS, key = "djXS" },
  17705. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  17706. new { label = "公务系数", value = 2M, key = "gwXS" }
  17707. }));
  17708. }
  17709. #endregion
  17710. #region 酒店预订 New 2023-12-28 17:45
  17711. /// <summary>
  17712. /// 酒店预订
  17713. /// 酒店费用列表 根据团组Id查询
  17714. /// </summary>
  17715. /// <param name="_dto"></param>
  17716. /// <returns></returns>
  17717. [HttpPost]
  17718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17719. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  17720. {
  17721. #region 参数验证
  17722. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17723. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17724. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17725. #region 团组操作权限验证 76 酒店预定模块
  17726. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17727. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17728. #endregion
  17729. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17730. #region 页面操作权限验证
  17731. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17732. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17733. #endregion
  17734. #endregion
  17735. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  17736. }
  17737. /// <summary>
  17738. /// 酒店预订
  17739. /// 基础数据
  17740. /// </summary>
  17741. /// <param name="_dto"></param>
  17742. /// <returns></returns>
  17743. [HttpPost]
  17744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17745. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  17746. {
  17747. #region 参数验证
  17748. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17749. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17750. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17751. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17752. #region 页面操作权限验证
  17753. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17754. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17755. #endregion
  17756. #region 团组操作权限验证 76 酒店预定模块
  17757. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17758. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17759. #endregion
  17760. #endregion
  17761. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  17762. }
  17763. /// <summary>
  17764. /// 酒店预订
  17765. /// 创建 入住卷号码
  17766. /// </summary>
  17767. /// <param name="_dto"></param>
  17768. /// <returns></returns>
  17769. [HttpPost]
  17770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17771. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  17772. {
  17773. #region 参数验证
  17774. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17775. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17776. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17777. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17778. #region 页面操作权限验证
  17779. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17780. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17781. #endregion
  17782. #region 团组操作权限验证 76 酒店预定模块
  17783. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17784. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17785. #endregion
  17786. #endregion
  17787. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  17788. if (data.Code != 0)
  17789. {
  17790. return Ok(JsonView(false, data.Msg));
  17791. }
  17792. return Ok(JsonView(true, data.Msg, data.Data));
  17793. }
  17794. /// <summary>
  17795. /// 酒店预订
  17796. /// 详情
  17797. /// </summary>
  17798. /// <param name="_dto"></param>
  17799. /// <returns></returns>
  17800. [HttpPost]
  17801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17802. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  17803. {
  17804. #region 参数验证
  17805. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  17806. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17807. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  17808. #region 团组操作权限验证 76 酒店预定模块
  17809. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17810. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17811. #endregion
  17812. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17813. #region 页面操作权限验证
  17814. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17815. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17816. #endregion
  17817. #endregion
  17818. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  17819. }
  17820. /// <summary>
  17821. /// 酒店预订
  17822. /// Add Or Edit
  17823. /// </summary>
  17824. /// <param name="_dto"></param>
  17825. /// <returns></returns>
  17826. [HttpPost]
  17827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17828. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  17829. {
  17830. #region 参数验证
  17831. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17832. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17833. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17834. #region 团组操作权限验证 76 酒店预定模块
  17835. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17836. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17837. #endregion
  17838. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17839. #region 页面操作权限验证
  17840. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17841. if (_dto.Id == 0) // Add
  17842. {
  17843. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17844. }
  17845. else if (_dto.Id > 1) // Edit
  17846. {
  17847. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17848. }
  17849. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  17850. #endregion
  17851. #endregion
  17852. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17853. if (_view.Code != 200)
  17854. {
  17855. return Ok(_view);
  17856. }
  17857. #region 成本无酒店价格数据进入超支
  17858. _sqlSugar.BeginTran();
  17859. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17860. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17861. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17862. for (int i = 0; i < groupCost.Count; i++)
  17863. {
  17864. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17865. {
  17866. groupCost[i].Date = groupCost[i - 1].Date;
  17867. }
  17868. }
  17869. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17870. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17871. List<Fin_GroupExtraCostDto_OP>();
  17872. if (start_Bool && end_Bool)
  17873. {
  17874. while (start_Time < end_Time)
  17875. {
  17876. foreach (var item in groupCost_Grp)
  17877. {
  17878. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17879. {
  17880. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17881. {
  17882. extraCostList.Add(new
  17883. Fin_GroupExtraCostDto_OP
  17884. {
  17885. Area = _dto.AreaId,
  17886. coefficient = 1.5M,
  17887. createUser = _dto.UserId,
  17888. currency = _dto.CardPriceCurrency,
  17889. diId = _dto.DiId,
  17890. ManagerConfirm = 0,
  17891. SupervisorConfirm = 0,
  17892. SYsupervisorConfirm = 0,
  17893. editType = 1,
  17894. PortType = 1,
  17895. price = _dto.CardPrice,
  17896. PriceCount = 1,
  17897. priceType = 1027,
  17898. priceDetailType = 1044,
  17899. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17900. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17901. });
  17902. }
  17903. }
  17904. }
  17905. start_Time = start_Time.AddDays(1);
  17906. }
  17907. }
  17908. if (extraCostList.Any())
  17909. {
  17910. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17911. }
  17912. _sqlSugar.CommitTran();
  17913. #endregion
  17914. #region 应用推送
  17915. try
  17916. {
  17917. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17918. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17919. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17920. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17921. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17922. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17923. var diId = _dto.DiId;
  17924. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17925. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17926. #region 操作记录
  17927. var opInfo = new Crm_TableOperationRecord()
  17928. {
  17929. TableName = "Grp_HotelReservations",
  17930. PortType = _dto.PortType,
  17931. DataId = hotelId,
  17932. CreateUserId = _dto.UserId
  17933. };
  17934. //var opStatus = OperationEnum.NoOperation;
  17935. if (_dto.Id < 1) //添加操作
  17936. {
  17937. opInfo.OperationItem = OperationEnum.Add;
  17938. }
  17939. else if (_dto.Id > 0)
  17940. {
  17941. opInfo.OperationItem = OperationEnum.Edit;
  17942. }
  17943. string opRemark = string.Empty;
  17944. if (ccpInfo != null)
  17945. {
  17946. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17947. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17948. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17949. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17950. }
  17951. opInfo.Remark = opRemark;
  17952. await _tableorRep.AddAsync(opInfo);
  17953. #endregion
  17954. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17955. //2024-10-21 新增LZ UID
  17956. var userIds = new List<int>() { 21 };
  17957. string title = $"费用审核";
  17958. string content = "";
  17959. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17960. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17961. try
  17962. {
  17963. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17964. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17965. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17966. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17967. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17968. }
  17969. catch (Exception ex)
  17970. {
  17971. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17972. }
  17973. }
  17974. catch (Exception ex)
  17975. {
  17976. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17977. }
  17978. try
  17979. {
  17980. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17981. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17982. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17983. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17984. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17985. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17986. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17987. //自动审核
  17988. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17989. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17990. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17991. //2024-10-21 新增LZ UID
  17992. var userIds = new List<int>() { 21 };
  17993. string title = $"系统通知";
  17994. var diId = _dto.DiId;
  17995. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17996. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17997. string content = "";
  17998. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17999. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18000. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18001. }
  18002. catch (Exception ex)
  18003. {
  18004. }
  18005. #endregion
  18006. return Ok(_view);
  18007. }
  18008. /// <summary>
  18009. /// 酒店自动审核测试
  18010. /// Add Or Edit
  18011. /// </summary>
  18012. /// <param name="diid"></param>
  18013. /// <param name="dataId"></param>
  18014. /// <returns></returns>
  18015. [HttpPost]
  18016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18017. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  18018. {
  18019. #region 应用推送
  18020. try
  18021. {
  18022. //自动审核
  18023. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  18024. }
  18025. catch (Exception ex)
  18026. {
  18027. return Ok(JsonView(false, ex.Message));
  18028. }
  18029. #endregion
  18030. return Ok(JsonView(false, "操作成功"));
  18031. }
  18032. /// <summary>
  18033. /// 酒店预订
  18034. /// Del
  18035. /// </summary>
  18036. /// <param name="_dto"></param>
  18037. /// <returns></returns>
  18038. [HttpPost]
  18039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18040. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  18041. {
  18042. #region 参数验证
  18043. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18044. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18045. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18046. #region 团组操作权限验证 76 酒店预定模块
  18047. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18048. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18049. #endregion
  18050. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18051. #region 页面操作权限验证
  18052. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18053. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18054. #endregion
  18055. #endregion
  18056. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  18057. #region 操作记录
  18058. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  18059. {
  18060. TableName = "Grp_HotelReservations",
  18061. PortType = _dto.PortType,
  18062. OperationItem = OperationEnum.Del,
  18063. DataId = _dto.Id,
  18064. CreateUserId = _dto.UserId
  18065. });
  18066. #endregion
  18067. return Ok(data);
  18068. }
  18069. /// <summary>
  18070. /// 酒店预订
  18071. /// 生成VOUCHER
  18072. /// 2024.05.06 之前版本
  18073. /// </summary>
  18074. /// <param name="_dto"></param>
  18075. /// <returns></returns>
  18076. [HttpPost]
  18077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18078. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  18079. {
  18080. try
  18081. {
  18082. #region 参数验证
  18083. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18084. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18085. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18086. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  18087. #region 团组操作权限验证 76 酒店预定模块
  18088. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18089. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18090. #endregion
  18091. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18092. #region 页面操作权限验证
  18093. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18094. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18095. #endregion
  18096. #endregion
  18097. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  18098. //判断数据是否完整
  18099. if (hr != null)
  18100. {
  18101. if (!string.IsNullOrEmpty(hr.DetermineNo))
  18102. {
  18103. string strFileName = "HotelStatement/";
  18104. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18105. if (dele != null)
  18106. strFileName += dele.TourCode;
  18107. //载入模板
  18108. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  18109. Document doc = new Document(sss);
  18110. DocumentBuilder builder = new DocumentBuilder(doc);
  18111. #region 替换Word模板书签内容
  18112. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  18113. //入住卷预定号码
  18114. if (doc.Range.Bookmarks["VNO"] != null)
  18115. {
  18116. Bookmark mark = doc.Range.Bookmarks["VNO"];
  18117. mark.Text = hr.CheckNumber;
  18118. }
  18119. //酒店时间
  18120. if (doc.Range.Bookmarks["Date"] != null)
  18121. {
  18122. Bookmark mark = doc.Range.Bookmarks["Date"];
  18123. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18124. }
  18125. //团号
  18126. if (doc.Range.Bookmarks["TNo"] != null)
  18127. {
  18128. Bookmark mark = doc.Range.Bookmarks["TNo"];
  18129. mark.Text = dele.TourCode;
  18130. }
  18131. //预定号码
  18132. if (doc.Range.Bookmarks["BookingId"] != null)
  18133. {
  18134. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  18135. mark.Text = hr.ReservationsNo;
  18136. }
  18137. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  18138. {
  18139. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  18140. mark.Text = hr.DetermineNo;
  18141. }
  18142. //酒店城市
  18143. if (doc.Range.Bookmarks["City"] != null)
  18144. {
  18145. Bookmark mark = doc.Range.Bookmarks["City"];
  18146. mark.Text = hr.City;
  18147. }
  18148. //酒店名称
  18149. if (doc.Range.Bookmarks["HName"] != null)
  18150. {
  18151. Bookmark mark = doc.Range.Bookmarks["HName"];
  18152. mark.Text = hr.HotelName;
  18153. }
  18154. //酒店地址
  18155. if (doc.Range.Bookmarks["Address"] != null)
  18156. {
  18157. Bookmark mark = doc.Range.Bookmarks["Address"];
  18158. mark.Text = hr.HotelAddress;
  18159. }
  18160. //酒店电话
  18161. if (doc.Range.Bookmarks["Tel"] != null)
  18162. {
  18163. Bookmark mark = doc.Range.Bookmarks["Tel"];
  18164. mark.Text = hr.HotelTel;
  18165. }
  18166. //酒店传真
  18167. if (doc.Range.Bookmarks["Fax"] != null)
  18168. {
  18169. Bookmark mark = doc.Range.Bookmarks["Fax"];
  18170. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  18171. {
  18172. mark.Text = hr.HotelFax;
  18173. }
  18174. }
  18175. //入住时间
  18176. if (doc.Range.Bookmarks["CIn"] != null)
  18177. {
  18178. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18179. Bookmark mark = doc.Range.Bookmarks["CIn"];
  18180. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  18181. }
  18182. //退房时间
  18183. if (doc.Range.Bookmarks["COut"] != null)
  18184. {
  18185. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18186. Bookmark mark = doc.Range.Bookmarks["COut"];
  18187. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18188. }
  18189. //客户名称
  18190. if (doc.Range.Bookmarks["GName"] != null)
  18191. {
  18192. string guestName = "";
  18193. string[] clients = Array.Empty<string>();
  18194. if (hr.GuestName.Contains(","))
  18195. {
  18196. clients = hr.GuestName.Split(",");
  18197. }
  18198. else
  18199. {
  18200. clients = new string[] { hr.GuestName };
  18201. }
  18202. List<int> clientIds_int = new List<int>();
  18203. if (clients.Length > 0)
  18204. {
  18205. foreach (var item in clients)
  18206. {
  18207. if (item.IsNumeric())
  18208. {
  18209. clientIds_int.Add(int.Parse(item));
  18210. }
  18211. }
  18212. }
  18213. if (clientIds_int.Count > 0)
  18214. {
  18215. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  18216. foreach (var client in _clientDatas)
  18217. {
  18218. //男
  18219. if (client.Sex == 0) guestName += $"Mr.";
  18220. //女
  18221. else if (client.Sex == 1) guestName += $"Ms.";
  18222. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  18223. {
  18224. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  18225. }
  18226. //guestName += $"{client.Pinyin},";
  18227. }
  18228. if (guestName.Length > 0)
  18229. {
  18230. guestName = guestName.Substring(0, guestName.Length - 1);
  18231. }
  18232. }
  18233. else
  18234. {
  18235. guestName = hr.GuestName;
  18236. }
  18237. Bookmark mark = doc.Range.Bookmarks["GName"];
  18238. mark.Text = guestName;
  18239. }
  18240. //房间介绍
  18241. if (doc.Range.Bookmarks["ROOM"] != null)
  18242. {
  18243. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  18244. mark.Text = hr.RoomExplanation;
  18245. }
  18246. //报价描述
  18247. if (doc.Range.Bookmarks["NOTE"] != null)
  18248. {
  18249. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  18250. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  18251. if (ss != null)
  18252. mark.Text = ss.Name;
  18253. }
  18254. //入住时间
  18255. if (doc.Range.Bookmarks["CheckIn"] != null)
  18256. {
  18257. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18258. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  18259. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18260. }
  18261. //退房时间
  18262. if (doc.Range.Bookmarks["CheckOut"] != null)
  18263. {
  18264. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18265. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  18266. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18267. }
  18268. //日期
  18269. if (doc.Range.Bookmarks["DT"] != null)
  18270. {
  18271. Bookmark mark = doc.Range.Bookmarks["DT"];
  18272. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18273. }
  18274. //名称
  18275. if (doc.Range.Bookmarks["VName"] != null)
  18276. {
  18277. Bookmark mark = doc.Range.Bookmarks["VName"];
  18278. mark.Text = hr.HotelName;
  18279. }
  18280. //号码
  18281. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  18282. {
  18283. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  18284. mark.Text = hr.CheckNumber;
  18285. }
  18286. #endregion
  18287. strFileName += "VOUCHER.doc";
  18288. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18289. doc.Save(fileDir);
  18290. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18291. return Ok(JsonView(true, "操作成功!", Url));
  18292. }
  18293. else
  18294. {
  18295. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  18296. }
  18297. }
  18298. else
  18299. {
  18300. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  18301. }
  18302. }
  18303. catch (Exception ex)
  18304. {
  18305. return Ok(JsonView(false, ex.Message));
  18306. }
  18307. }
  18308. /// <summary>
  18309. /// 酒店预订
  18310. /// 生成VOUCHER
  18311. /// 2024.05.06 之后版本
  18312. /// </summary>
  18313. /// <param name="_dto"></param>
  18314. /// <returns></returns>
  18315. [HttpPost]
  18316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18317. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  18318. {
  18319. #region 参数验证
  18320. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18321. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18322. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18323. #region 团组操作权限验证 76 酒店预定模块
  18324. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18325. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18326. #endregion
  18327. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18328. #region 页面操作权限验证
  18329. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18330. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18331. #endregion
  18332. #endregion
  18333. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  18334. //判断数据是否完整
  18335. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18336. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18337. string strFileName = "HotelStatement/";
  18338. string guestNames = ""; //格式Mr.xxx Ms.xxx
  18339. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  18340. #region 数据处理
  18341. List<int> guestIds = new List<int>();
  18342. //int index = 0;
  18343. foreach (var item in hrDtas)
  18344. {
  18345. if (item.GuestName.Contains(","))
  18346. {
  18347. string[] guestIdArr = item.GuestName.Split(',');
  18348. foreach (var guestIdStr in guestIdArr)
  18349. {
  18350. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  18351. if (guestBool)
  18352. {
  18353. guestIds.Add(guestId);
  18354. }
  18355. }
  18356. }
  18357. else guestNames += item.GuestName;
  18358. var voucherInfo = new HotelVoucherInfoView()
  18359. {
  18360. HotelName = item.HotelName,
  18361. CheckInDate = item.CheckInDate,
  18362. CheckOutDate = item.CheckOutDate,
  18363. ConfirmationNumber = item.DetermineNo.Trim(),
  18364. RoomType = item.RoomExplanation
  18365. };
  18366. vouchers.Add(voucherInfo);
  18367. }
  18368. if (guestIds.Count > 0)
  18369. {
  18370. guestIds = guestIds.Distinct().ToList();
  18371. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  18372. if (guestDatas.Count > 0)
  18373. {
  18374. guestNames = "";
  18375. foreach (var guest in guestDatas)
  18376. {
  18377. string guestName = "";
  18378. if (guest.Sex == 0) guestName += @"MR.";
  18379. else if (guest.Sex == 1) guestName += @"MS.";
  18380. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18381. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18382. guestNames += @$"{guestName.Trim()}、";
  18383. }
  18384. if (guestNames.Length > 0)
  18385. {
  18386. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18387. }
  18388. }
  18389. }
  18390. #endregion
  18391. //载入模板
  18392. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  18393. Document doc = new Document(sss);
  18394. DocumentBuilder builder = new DocumentBuilder(doc);
  18395. if (doc.Range.Bookmarks["GuestName"] != null)
  18396. {
  18397. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  18398. mark.Text = guestNames;
  18399. }
  18400. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18401. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  18402. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  18403. for (int i = 1; i <= vouchers.Count; i++)
  18404. {
  18405. HotelVoucherInfoView hviv = vouchers[i - 1];
  18406. builder.MoveToCell(0, i, 0, 0);
  18407. builder.Write(hviv.HotelName);
  18408. builder.MoveToCell(0, i, 1, 0);
  18409. builder.Write(hviv.CheckInDate);
  18410. builder.MoveToCell(0, i, 2, 0);
  18411. builder.Write(hviv.CheckOutDate);
  18412. builder.MoveToCell(0, i, 3, 0);
  18413. builder.Write(hviv.RoomType);
  18414. builder.MoveToCell(0, i, 4, 0);
  18415. builder.Write(hviv.ConfirmationNumber);
  18416. }
  18417. //删除多余行
  18418. int currRowIndex = vouchers.Count + 1;
  18419. int delRows = 21 - currRowIndex;
  18420. if (delRows > 0)
  18421. {
  18422. for (int i = 0; i < delRows; i++)
  18423. {
  18424. table.Rows.RemoveAt(currRowIndex);
  18425. //cultivateRowIndex++;
  18426. }
  18427. }
  18428. strFileName += "VOUCHER.docx";
  18429. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18430. doc.Save(fileDir);
  18431. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18432. return Ok(JsonView(true, "操作成功!", Url));
  18433. }
  18434. /// <summary>
  18435. /// 酒店预订
  18436. /// 生成VOUCHER 批量生成
  18437. /// New
  18438. /// </summary>
  18439. /// <param name="_dto"></param>
  18440. /// <returns></returns>
  18441. [HttpPost]
  18442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18443. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  18444. {
  18445. #region 参数验证
  18446. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18447. if (_dto.PageId < 1) _dto.PageId = 28;
  18448. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18449. #region 团组操作权限验证 76 酒店预定模块
  18450. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18451. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18452. #endregion
  18453. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18454. #region 页面操作权限验证
  18455. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18456. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18457. #endregion
  18458. #endregion
  18459. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  18460. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  18461. .OrderBy(x => x.CheckInDate)
  18462. .ToListAsync();
  18463. //判断数据是否完整
  18464. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18465. string strFileName = "HotelStatement/";
  18466. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18467. if (dele != null)
  18468. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  18469. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  18470. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  18471. .Where(it => it.IsDel == 0)
  18472. .ToListAsync();
  18473. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  18474. for (int i = 0; i < hrDtas.Count; i++)
  18475. {
  18476. string guestNames = string.Empty;
  18477. List<int> guestIds = new List<int>();
  18478. var item = hrDtas[i];
  18479. //处理客户姓名
  18480. if (item.GuestName.Contains(","))
  18481. {
  18482. string[] guestIdArr = item.GuestName.Split(',');
  18483. foreach (var guestIdStr in guestIdArr)
  18484. if (int.TryParse(guestIdStr, out int guestId))
  18485. guestIds.Add(guestId);
  18486. }
  18487. else
  18488. {
  18489. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  18490. if (guestIdBool)
  18491. {
  18492. guestIds.Add(guestId);
  18493. }
  18494. //NaN
  18495. if (item.GuestName.Contains("NaN"))
  18496. {
  18497. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  18498. }
  18499. }
  18500. if (guestIds.Count > 0)
  18501. {
  18502. guestIds = guestIds.Distinct().ToList();
  18503. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  18504. if (guestDatas1.Count > 0)
  18505. {
  18506. guestNames = "";
  18507. foreach (var guest in guestDatas1)
  18508. {
  18509. string guestName = "";
  18510. if (guest.Sex == 0) guestName += @"MR.";
  18511. else if (guest.Sex == 1) guestName += @"MS.";
  18512. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18513. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18514. guestNames += @$"{guestName.Trim()}、";
  18515. }
  18516. if (guestNames.Length > 0)
  18517. {
  18518. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18519. }
  18520. }
  18521. }
  18522. //if (!string.IsNullOrEmpty(guestNames))
  18523. //{
  18524. hrDtas[i].GuestName = guestNames;
  18525. //}
  18526. }
  18527. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  18528. Document doc = new Document();
  18529. DocumentBuilder builder = new DocumentBuilder(doc);
  18530. try
  18531. {
  18532. builder.MoveToDocumentStart();
  18533. foreach (var item in hrDtas)
  18534. {
  18535. //标题
  18536. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18537. builder.ParagraphFormat.LineSpacing = 1;
  18538. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18539. builder.ParagraphFormat.Style.Font.Size = 9;
  18540. builder.ParagraphFormat.Style.Font.Bold = true;
  18541. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18542. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  18543. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18544. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18545. builder.ParagraphFormat.LineSpacing = 1;
  18546. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18547. builder.ParagraphFormat.Style.Font.Size = 9;
  18548. builder.ParagraphFormat.Style.Font.Bold = true;
  18549. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  18550. builder.StartTable();
  18551. // 设置边框颜色
  18552. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  18553. //设置边框样式
  18554. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  18555. //表格
  18556. #region 第一行
  18557. builder.InsertCell();
  18558. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18559. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18560. //builder.CellFormat.AllowAutoFit = false;
  18561. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18562. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18563. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18564. builder.CellFormat.WrapText = true; //自动换行
  18565. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18566. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  18567. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18568. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18569. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18570. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18571. builder.Write("TOUR NO:");
  18572. builder.InsertCell();
  18573. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18574. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18575. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18576. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18577. builder.ParagraphFormat.Style.Font.Bold = false;
  18578. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18579. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18580. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18581. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18582. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18583. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18584. builder.Write($"{dele?.TourCode ?? "-"}");
  18585. builder.InsertCell();
  18586. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18587. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18588. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18589. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18590. builder.ParagraphFormat.Style.Font.Bold = false;
  18591. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18592. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18593. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18594. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18595. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18596. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18597. builder.Write($"CITY:");
  18598. builder.InsertCell();
  18599. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18600. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18601. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18602. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18603. builder.ParagraphFormat.Style.Font.Bold = false;
  18604. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18605. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18606. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18607. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18608. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18609. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18610. builder.Write($"{item.City}");
  18611. builder.EndRow();
  18612. #endregion
  18613. #region 第二行
  18614. builder.InsertCell();
  18615. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18616. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18617. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18618. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18619. builder.ParagraphFormat.Style.Font.Bold = false;
  18620. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18621. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18622. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18623. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18624. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18625. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18626. builder.Write("CONFIRMATION NO:");
  18627. builder.InsertCell();
  18628. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18629. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18630. builder.ParagraphFormat.Style.Font.Size = 8;
  18631. builder.ParagraphFormat.Style.Font.Bold = false;
  18632. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18633. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18634. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18635. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18636. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18637. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18638. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18639. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18640. builder.Write($"{item.DetermineNo}");
  18641. builder.InsertCell();
  18642. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18643. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18644. builder.InsertCell();
  18645. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18646. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18647. builder.EndRow();
  18648. #endregion
  18649. #region 第三行
  18650. builder.InsertCell();
  18651. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18652. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18653. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18654. builder.ParagraphFormat.Style.Font.Bold = false;
  18655. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18656. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18657. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18658. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18659. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18660. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18661. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18662. builder.Write($"HOTEL NAME:");
  18663. builder.InsertCell();
  18664. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18665. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18666. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18667. builder.ParagraphFormat.Style.Font.Bold = false;
  18668. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18669. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18670. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18671. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18672. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18673. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18674. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18675. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18676. builder.Write($"{item.HotelName}");
  18677. builder.InsertCell();
  18678. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18679. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18680. builder.InsertCell();
  18681. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18682. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18683. builder.EndRow();
  18684. #endregion
  18685. #region 第四行
  18686. builder.InsertCell();
  18687. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18688. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18689. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18690. builder.ParagraphFormat.Style.Font.Bold = false;
  18691. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18692. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18693. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18694. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18695. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18696. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18697. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18698. builder.Write($"HOTEL ADDRESS:");
  18699. builder.InsertCell();
  18700. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18701. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18702. builder.ParagraphFormat.Style.Font.Size = 8;
  18703. builder.ParagraphFormat.Style.Font.Bold = false;
  18704. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18705. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18706. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18707. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18708. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18709. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18710. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18711. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18712. builder.Write($"{item.HotelAddress}");
  18713. builder.InsertCell();
  18714. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18715. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18716. builder.InsertCell();
  18717. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18718. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18719. builder.EndRow();
  18720. #endregion
  18721. #region 第五行
  18722. builder.InsertCell();
  18723. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18724. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18725. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18726. builder.ParagraphFormat.Style.Font.Bold = false;
  18727. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18728. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18729. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18730. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18731. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18732. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18733. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18734. builder.Write("TEL:");
  18735. builder.InsertCell();
  18736. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18737. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18738. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18739. builder.ParagraphFormat.Style.Font.Bold = false;
  18740. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18741. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18742. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18743. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18744. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18745. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18746. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18747. builder.Write($"{item.HotelTel}");
  18748. builder.InsertCell();
  18749. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18750. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18751. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18752. builder.ParagraphFormat.Style.Font.Bold = false;
  18753. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18754. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18755. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18756. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18757. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18758. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18759. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18760. builder.Write($"FAX:");
  18761. builder.InsertCell();
  18762. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18763. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18764. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18765. builder.ParagraphFormat.Style.Font.Bold = false;
  18766. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18767. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18768. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18769. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18770. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18771. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18772. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18773. builder.Write($"{item.HotelFax}");
  18774. builder.EndRow();
  18775. #endregion
  18776. #region 第六行
  18777. builder.InsertCell();
  18778. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18779. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18780. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18781. builder.ParagraphFormat.Style.Font.Bold = false;
  18782. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18783. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18784. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18785. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18786. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18787. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18788. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18789. builder.Write("CHECK IN:");
  18790. builder.InsertCell();
  18791. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18792. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18793. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18794. builder.ParagraphFormat.Style.Font.Bold = false;
  18795. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18796. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18797. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18798. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18799. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18800. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18801. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18802. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  18803. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18804. builder.Write($"{checkInStr}");
  18805. builder.InsertCell();
  18806. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18807. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18808. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18809. builder.ParagraphFormat.Style.Font.Bold = false;
  18810. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18811. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18812. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18813. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18814. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18815. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18816. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18817. builder.Write($"CHECK OUT:");
  18818. builder.InsertCell();
  18819. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18820. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18821. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18822. builder.ParagraphFormat.Style.Font.Bold = false;
  18823. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18824. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18825. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18826. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18827. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18828. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18829. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18830. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  18831. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  18832. builder.Write($"{checkOutStr}");
  18833. builder.EndRow();
  18834. #endregion
  18835. #region 第七行
  18836. builder.InsertCell();
  18837. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18838. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18839. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18840. builder.ParagraphFormat.Style.Font.Bold = false;
  18841. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18842. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18843. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18844. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18845. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18846. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18847. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18848. builder.Write($"GUEST NAME:");
  18849. builder.InsertCell();
  18850. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18851. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18852. builder.ParagraphFormat.Style.Font.Size = 8;
  18853. builder.ParagraphFormat.Style.Font.Bold = false;
  18854. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18855. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18856. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18857. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18858. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18859. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18860. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18861. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18862. builder.Write($"{item.GuestName.Trim()}");
  18863. builder.InsertCell();
  18864. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18865. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18866. builder.InsertCell();
  18867. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18868. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18869. builder.EndRow();
  18870. #endregion
  18871. #region 第八行
  18872. builder.InsertCell();
  18873. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18874. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18875. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18876. builder.ParagraphFormat.Style.Font.Bold = false;
  18877. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18878. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18879. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18880. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18881. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18882. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18883. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18884. builder.Write($"ROOM TYPE:");
  18885. builder.InsertCell();
  18886. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18887. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18888. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18889. builder.ParagraphFormat.Style.Font.Bold = false;
  18890. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18891. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18892. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18893. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18894. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18895. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18896. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18897. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18898. builder.Write($"{item.RoomExplanation}");
  18899. builder.InsertCell();
  18900. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18901. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18902. builder.InsertCell();
  18903. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18904. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18905. builder.EndRow();
  18906. #endregion
  18907. #region 第九行
  18908. builder.InsertCell();
  18909. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18910. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18911. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18912. builder.ParagraphFormat.Style.Font.Bold = false;
  18913. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18914. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18915. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18916. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18917. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18918. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18919. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18920. builder.Write($"NOTE:");
  18921. builder.InsertCell();
  18922. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18923. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18924. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18925. builder.ParagraphFormat.Style.Font.Bold = false;
  18926. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18927. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18928. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18929. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18930. 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.");
  18931. builder.InsertCell();
  18932. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18933. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18934. builder.InsertCell();
  18935. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18936. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18937. builder.EndRow();
  18938. #endregion
  18939. builder.EndTable();
  18940. //换行
  18941. builder.Writeln("");
  18942. builder.Writeln("");
  18943. }
  18944. #region 获取文档中的所有表格 设置文字自适应
  18945. // 获取文档中的所有表格。
  18946. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18947. {
  18948. // 遍历表格中的所有行。
  18949. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18950. {
  18951. foreach (Cell cell in row.Cells)
  18952. {
  18953. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18954. cellFormat.Width = 0;
  18955. }
  18956. }
  18957. }
  18958. #endregion
  18959. #region 设置页眉
  18960. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18961. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18962. if (System.IO.File.Exists(voucherHeaderPath))
  18963. {
  18964. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18965. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18966. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18967. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18968. // 调整图片位置
  18969. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18970. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18971. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18972. shape.Left = 0; // 将图片距离页面左边缘的距离
  18973. shape.Width = 81; // 设置图片宽度
  18974. shape.Height = 36; // 设置图片高度
  18975. }
  18976. //靠右
  18977. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18978. //// 设置页脚上下边距
  18979. //builder.PageSetup.HeaderDistance = 42;
  18980. // 添加页眉线
  18981. Aspose.Words.Border borderHeader = null;
  18982. try
  18983. {
  18984. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18985. }
  18986. catch (Exception e)
  18987. {
  18988. // TODO Auto-generated catch block
  18989. //e.printStackTrace();
  18990. }
  18991. borderHeader.Shadow = true;
  18992. borderHeader.DistanceFromText = 2;
  18993. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18994. #endregion
  18995. }
  18996. catch (Exception ex)
  18997. {
  18998. }
  18999. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19000. doc.Save(fileDir);
  19001. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19002. return Ok(JsonView(true, "操作成功!", Url));
  19003. }
  19004. /// <summary>
  19005. /// 酒店预订
  19006. /// 生成 预定成本 Excel
  19007. /// </summary>
  19008. /// <param name="_dto"></param>
  19009. /// <returns></returns>
  19010. [HttpPost]
  19011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19012. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  19013. {
  19014. #region 参数验证
  19015. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  19016. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  19017. if (!vadalitorRes.IsValid)
  19018. {
  19019. var errors = new StringBuilder();
  19020. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  19021. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  19022. }
  19023. #region 团组操作权限验证 76 酒店预定模块
  19024. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19025. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  19026. #endregion
  19027. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19028. #region 页面操作权限验证
  19029. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19030. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19031. #endregion
  19032. #endregion
  19033. decimal _rate = 1.00M;
  19034. string _currency = string.Empty;
  19035. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  19036. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19037. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  19038. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19039. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  19040. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  19041. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  19042. if (_GroupCostParameter == null)
  19043. {
  19044. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  19045. bool isIntType = int.TryParse(_currency, out int currId);
  19046. if (isIntType)
  19047. {
  19048. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19049. }
  19050. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19051. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19052. if (currInfo == null)
  19053. {
  19054. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19055. }
  19056. else _rate = currInfo.Rate;
  19057. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  19058. {
  19059. _rate = _GroupCostParameter.Rate;
  19060. }
  19061. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19062. //string strFileName = "HotelStatement/";
  19063. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19064. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19065. var rateDatas = new List<dynamic>();
  19066. #region 数据处理
  19067. foreach (var item in hrDtas)
  19068. {
  19069. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19070. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19071. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19072. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19073. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19074. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  19075. {
  19076. continue;
  19077. }
  19078. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19079. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  19080. string singleRoomFeeStr = string.Empty,
  19081. doubleRoomFeeStr = string.Empty,
  19082. suiteRoomFeeStr = string.Empty,
  19083. otherRoomFeeStr = string.Empty,
  19084. payMoneyStr = string.Empty,
  19085. cardPriceStr = string.Empty;
  19086. if (roomCurr.Equals("CNY"))
  19087. {
  19088. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  19089. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19090. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19091. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19092. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19093. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  19094. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  19095. }
  19096. else
  19097. {
  19098. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19099. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19100. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19101. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19102. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19103. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19104. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19105. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19106. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19107. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19108. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  19109. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  19110. if (ccpPaymentCurrency.Equals("CNY"))
  19111. {
  19112. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  19113. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19114. }
  19115. else
  19116. {
  19117. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  19118. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  19119. }
  19120. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  19121. if (hotelcardPriceCurrency.Equals("CNY"))
  19122. {
  19123. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19124. }
  19125. else
  19126. {
  19127. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  19128. }
  19129. }
  19130. string breakfastPriceStr = string.Empty,
  19131. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19132. governmentRentStr = string.Empty,
  19133. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19134. cityTaxStr = string.Empty,
  19135. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19136. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  19137. if (!string.IsNullOrEmpty(breakfastCurrency1))
  19138. {
  19139. if (breakfastCurrency1.Equals("CNY"))
  19140. {
  19141. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19142. }
  19143. else
  19144. {
  19145. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  19146. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  19147. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  19148. }
  19149. }
  19150. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19151. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  19152. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  19153. {
  19154. if (governmentRentCurrency.Equals("CNY"))
  19155. {
  19156. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19157. }
  19158. else
  19159. {
  19160. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  19161. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  19162. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  19163. }
  19164. }
  19165. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19166. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  19167. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  19168. {
  19169. if (cityTaxStrCurrency1.Equals("CNY"))
  19170. {
  19171. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19172. }
  19173. else
  19174. {
  19175. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  19176. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  19177. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  19178. }
  19179. }
  19180. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19181. int payDId = roomInfo?.PayDId ?? 0;
  19182. pcfds.Add(new HotelReservations_PCFD_View()
  19183. {
  19184. City = item.City,
  19185. HotelName = item.HotelName,
  19186. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19187. // SingleRoomCount = item.SingleRoomCount,
  19188. SingleRoomPrice = singleRoomFeeStr,
  19189. // DoubleRoomCount = item.DoubleRoomCount,
  19190. DoubleRoomPrice = doubleRoomFeeStr,
  19191. //SuiteRoomCount = item.SuiteRoomCount,
  19192. SuiteRoomPrice = suiteRoomFeeStr,
  19193. OtherRoomPrice = otherRoomFeeStr,
  19194. //OtherRoomCount = item.OtherRoomCount,
  19195. BreakfastPrice = breakfastPriceStr,
  19196. GovernmentRent = governmentRentStr,
  19197. CityTax = cityTaxStr,
  19198. RoomExplanation = item.RoomExplanation,
  19199. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19200. PayTime = roomInfo?.ConsumptionDate,
  19201. BankNo = roomInfo?.BankNo,
  19202. PayMoney = payMoneyStr,
  19203. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19204. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19205. CardPrice = cardPriceStr,
  19206. Remark = ccpInfo.Remark
  19207. });
  19208. }
  19209. #endregion
  19210. //载入模板
  19211. WorkbookDesigner designer = new WorkbookDesigner();
  19212. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19213. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19214. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19215. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19216. var rateDatas1 = rateDatas.Distinct();
  19217. var rateStr = string.Empty;
  19218. foreach (var item in rateDatas1)
  19219. {
  19220. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  19221. }
  19222. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  19223. designer.SetDataSource("Opertor", userInfo.CnName);
  19224. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19225. dt.TableName = "ViewMyHotelReservations";
  19226. designer.SetDataSource(dt);
  19227. designer.Process();
  19228. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19229. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19230. designer.Workbook.Save(serverPath);
  19231. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19232. #region 删除指定行
  19233. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19234. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19235. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19236. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19237. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19238. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19239. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19240. cssIndex = dt.Columns["CityTax"].Ordinal,
  19241. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19242. remarkIndex = dt.Columns["Remark"].Ordinal;
  19243. //删除指定列
  19244. foreach (DataRow item in dt.Rows)
  19245. {
  19246. string singleStr = item["SingleRoomPrice"].ToString();
  19247. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19248. if (containsDigitButNotZero1) singleDel = false;
  19249. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19250. string doubleStr = item["DoubleRoomPrice"].ToString();
  19251. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19252. if (containsDigitButNotZero2) doubleDel = false;
  19253. string suiteStr = item["SuiteRoomPrice"].ToString();
  19254. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19255. if (containsDigitButNotZero3) suiteDel = false;
  19256. string otherStr = item["OtherRoomPrice"].ToString();
  19257. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19258. if (containsDigitButNotZero4) otherDel = false;
  19259. string zcStr = item["BreakfastPrice"].ToString();
  19260. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19261. if (containsDigitButNotZero5) zcDel = false;
  19262. string dsStr = item["GovernmentRent"].ToString();
  19263. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19264. if (containsDigitButNotZero6) dsDel = false;
  19265. string cssStr = item["CityTax"].ToString();
  19266. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19267. if (containsDigitButNotZero7) cssDel = false;
  19268. string cpStr = item["ConsumptionPatterns"].ToString();
  19269. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19270. string remarkStr = item["Remark"].ToString();
  19271. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19272. }
  19273. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19274. DeleteColumn(serverPath, cpIndex, cpDel);
  19275. DeleteColumn(serverPath, dsIndex, dsDel);
  19276. DeleteColumn(serverPath, cssIndex, cssDel);
  19277. DeleteColumn(serverPath, zcIndex, zcDel);
  19278. DeleteColumn(serverPath, otherIndex, otherDel);
  19279. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19280. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19281. DeleteColumn(serverPath, singleIndex, singleDel);
  19282. #endregion
  19283. //只保留第一个表格
  19284. DeleteSheet(serverPath);
  19285. return Ok(JsonView(true, "操作成功", url = rst));
  19286. }
  19287. else
  19288. {
  19289. _currency = _GroupCostParameter.Currency;
  19290. bool isIntType = int.TryParse(_currency, out int currId);
  19291. if (isIntType)
  19292. {
  19293. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19294. }
  19295. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19296. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19297. if (currInfo == null)
  19298. {
  19299. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19300. }
  19301. if (!_currency.ToUpper().Equals("CNY"))
  19302. {
  19303. _rate = _GroupCostParameter.Rate;
  19304. }
  19305. _rate = currInfo.Rate;
  19306. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19307. //string strFileName = "HotelStatement/";
  19308. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19309. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19310. #region 数据处理
  19311. foreach (var item in hrDtas)
  19312. {
  19313. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19314. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19315. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19316. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19317. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19318. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19319. string singleRoomFeeStr = string.Empty,
  19320. doubleRoomFeeStr = string.Empty,
  19321. suiteRoomFeeStr = string.Empty,
  19322. otherRoomFeeStr = string.Empty,
  19323. payMoneyStr = string.Empty,
  19324. cardPriceStr = string.Empty;
  19325. if (roomCurr.Equals(_currency))
  19326. {
  19327. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  19328. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  19329. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  19330. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  19331. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  19332. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  19333. }
  19334. else
  19335. {
  19336. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19337. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19338. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19339. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19340. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19341. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19342. }
  19343. string breakfastPriceStr = string.Empty,
  19344. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19345. governmentRentStr = string.Empty,
  19346. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19347. cityTaxStrStr = string.Empty,
  19348. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19349. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  19350. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  19351. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  19352. int payDId = roomInfo?.PayDId ?? 0;
  19353. pcfds.Add(new HotelReservations_PCFD_View()
  19354. {
  19355. City = item.City,
  19356. HotelName = item.HotelName,
  19357. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19358. // SingleRoomCount = item.SingleRoomCount,
  19359. SingleRoomPrice = singleRoomFeeStr,
  19360. // DoubleRoomCount = item.DoubleRoomCount,
  19361. DoubleRoomPrice = doubleRoomFeeStr,
  19362. //SuiteRoomCount = item.SuiteRoomCount,
  19363. SuiteRoomPrice = suiteRoomFeeStr,
  19364. OtherRoomPrice = otherRoomFeeStr,
  19365. //OtherRoomCount = item.OtherRoomCount,
  19366. BreakfastPrice = breakfastPriceStr,
  19367. GovernmentRent = governmentRentStr,
  19368. CityTax = cityTaxStrStr,
  19369. RoomExplanation = item.RoomExplanation,
  19370. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19371. PayTime = roomInfo?.ConsumptionDate,
  19372. BankNo = roomInfo?.BankNo,
  19373. PayMoney = payMoneyStr,
  19374. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19375. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19376. CardPrice = cardPriceStr,
  19377. Remark = ccpInfo.Remark
  19378. });
  19379. }
  19380. #endregion
  19381. //载入模板
  19382. WorkbookDesigner designer = new WorkbookDesigner();
  19383. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19384. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19385. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19386. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19387. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  19388. designer.SetDataSource("Opertor", userInfo.CnName);
  19389. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19390. dt.TableName = "ViewMyHotelReservations";
  19391. designer.SetDataSource(dt);
  19392. designer.Process();
  19393. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19394. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19395. designer.Workbook.Save(serverPath);
  19396. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19397. #region 删除指定行
  19398. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19399. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19400. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19401. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19402. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19403. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19404. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19405. cssIndex = dt.Columns["CityTax"].Ordinal,
  19406. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19407. remarkIndex = dt.Columns["Remark"].Ordinal;
  19408. //删除指定列
  19409. foreach (DataRow item in dt.Rows)
  19410. {
  19411. string singleStr = item["SingleRoomPrice"].ToString();
  19412. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19413. if (containsDigitButNotZero1) singleDel = false;
  19414. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19415. string doubleStr = item["DoubleRoomPrice"].ToString();
  19416. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19417. if (containsDigitButNotZero2) doubleDel = false;
  19418. string suiteStr = item["SuiteRoomPrice"].ToString();
  19419. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19420. if (containsDigitButNotZero3) suiteDel = false;
  19421. string otherStr = item["OtherRoomPrice"].ToString();
  19422. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19423. if (containsDigitButNotZero4) otherDel = false;
  19424. string zcStr = item["BreakfastPrice"].ToString();
  19425. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19426. if (containsDigitButNotZero5) zcDel = false;
  19427. string dsStr = item["GovernmentRent"].ToString();
  19428. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19429. if (containsDigitButNotZero6) dsDel = false;
  19430. string cssStr = item["CityTax"].ToString();
  19431. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19432. if (containsDigitButNotZero7) cssDel = false;
  19433. string cpStr = item["ConsumptionPatterns"].ToString();
  19434. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19435. string remarkStr = item["Remark"].ToString();
  19436. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19437. }
  19438. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19439. DeleteColumn(serverPath, cpIndex, cpDel);
  19440. DeleteColumn(serverPath, dsIndex, dsDel);
  19441. DeleteColumn(serverPath, cssIndex, cssDel);
  19442. DeleteColumn(serverPath, zcIndex, zcDel);
  19443. DeleteColumn(serverPath, otherIndex, otherDel);
  19444. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19445. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19446. DeleteColumn(serverPath, singleIndex, singleDel);
  19447. #endregion
  19448. //只保留第一个表格
  19449. DeleteSheet(serverPath);
  19450. return Ok(JsonView(true, "操作成功", url = rst));
  19451. }
  19452. //return Ok(JsonView(false));
  19453. }
  19454. /// <summary>
  19455. /// 删除指定列
  19456. /// </summary>
  19457. /// <param name="file"></param>
  19458. /// <param name="columnIndex"></param>
  19459. /// <param name="isDel"></param>
  19460. private void DeleteColumn(string file, int columnIndex, bool isDel)
  19461. {
  19462. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19463. //wb.Save(file);
  19464. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  19465. if (sheet1 != null)
  19466. {
  19467. if (isDel)
  19468. {
  19469. Cells cells = sheet1.Cells;
  19470. cells.DeleteColumn(columnIndex);
  19471. }
  19472. }
  19473. wb.Save(file);
  19474. }
  19475. /// <summary>
  19476. /// 删除sheet
  19477. /// </summary>
  19478. /// <param name="file"></param>
  19479. private void DeleteSheet(string file)
  19480. {
  19481. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19482. //wb.Save(file);
  19483. List<string> sheets = new List<string>();
  19484. foreach (var item in wb.Worksheets)
  19485. {
  19486. sheets.Add(item.Name);
  19487. }
  19488. if (sheets.Count > 0)
  19489. {
  19490. sheets.RemoveAt(0);//不删除第一个sheet
  19491. foreach (var item in sheets)
  19492. {
  19493. wb.Worksheets.RemoveAt(item);
  19494. }
  19495. }
  19496. wb.Save(file);
  19497. }
  19498. /// <summary>
  19499. /// 酒店预订
  19500. /// 确认单
  19501. /// </summary>
  19502. /// <param name="_dto"></param>
  19503. /// <returns></returns>
  19504. [HttpPost]
  19505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19506. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  19507. {
  19508. try
  19509. {
  19510. #region 参数验证
  19511. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19512. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19513. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19514. #region 团组操作权限验证 76 酒店预定模块
  19515. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19516. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19517. #endregion
  19518. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19519. #region 页面操作权限验证
  19520. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19521. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19522. #endregion
  19523. #endregion
  19524. //团组信息
  19525. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  19526. //酒店数据
  19527. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  19528. if (listhoteldata.Count < 0)
  19529. {
  19530. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  19531. }
  19532. //利datatable存储
  19533. DataTable dt = new DataTable();
  19534. dt.Columns.Add("CheckInDate", typeof(string));
  19535. dt.Columns.Add("City", typeof(string));
  19536. dt.Columns.Add("Hotel", typeof(string));
  19537. dt.Columns.Add("Room", typeof(string));
  19538. for (int i = 0; i < listhoteldata.Count; i++)
  19539. {
  19540. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  19541. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  19542. while (dayStart < dayEnd)
  19543. {
  19544. string temp = "";
  19545. DataRow row = dt.NewRow();
  19546. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  19547. row["City"] = listhoteldata[i].City;
  19548. row["Hotel"] = listhoteldata[i].HotelName;
  19549. if (listhoteldata[i].SingleRoomCount > 0)
  19550. {
  19551. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  19552. }
  19553. if (listhoteldata[i].DoubleRoomCount > 0)
  19554. {
  19555. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  19556. }
  19557. if (listhoteldata[i].SuiteRoomCount > 0)
  19558. {
  19559. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  19560. }
  19561. if (listhoteldata[i].OtherRoomCount > 0)
  19562. {
  19563. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  19564. }
  19565. row["Room"] = temp;
  19566. dt.Rows.Add(row);
  19567. dayStart = dayStart.AddDays(1);
  19568. }
  19569. }
  19570. Dictionary<string, string> dic = new Dictionary<string, string>();
  19571. dic.Add("Dele", di.TeamName);
  19572. dic.Add("City", di.VisitCountry);
  19573. //模板路径
  19574. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  19575. //载入模板
  19576. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  19577. DocumentBuilder builder = new DocumentBuilder(doc);
  19578. foreach (var key in dic.Keys)
  19579. {
  19580. builder.MoveToBookmark(key);
  19581. builder.Write(dic[key]);
  19582. }
  19583. //获取word里所有表格
  19584. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19585. //获取所填表格的序数
  19586. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19587. var rowStart = tableOne.Rows[0]; //获取第1行
  19588. //循环赋值
  19589. for (int i = 0; i < dt.Rows.Count; i++)
  19590. {
  19591. builder.MoveToCell(0, i + 1, 0, 0);
  19592. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  19593. builder.MoveToCell(0, i + 1, 1, 0);
  19594. builder.Write(dt.Rows[i]["City"].ToString());
  19595. builder.MoveToCell(0, i + 1, 2, 0);
  19596. builder.Write(dt.Rows[i]["Hotel"].ToString());
  19597. builder.MoveToCell(0, i + 1, 3, 0);
  19598. builder.Write(dt.Rows[i]["Room"].ToString());
  19599. }
  19600. //删除多余行
  19601. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  19602. {
  19603. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  19604. }
  19605. string strFileName = di.TeamName + "酒店确认单.doc";
  19606. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  19607. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  19608. return Ok(JsonView(true, "成功", url));
  19609. }
  19610. catch (Exception ex)
  19611. {
  19612. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  19613. }
  19614. }
  19615. #endregion
  19616. #region 团组状态
  19617. /// <summary>
  19618. /// 团组状态列表 Page
  19619. /// </summary>
  19620. /// <param name="dto">团组列表请求dto</param>
  19621. /// <returns></returns>
  19622. [HttpPost]
  19623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19624. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  19625. {
  19626. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19627. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  19628. {
  19629. string sqlWhere = string.Empty;
  19630. if (dto.IsSure == 0) //未完成
  19631. {
  19632. sqlWhere += string.Format(@" And IsSure = 0");
  19633. }
  19634. else if (dto.IsSure == 1) //已完成
  19635. {
  19636. sqlWhere += string.Format(@" And IsSure = 1");
  19637. }
  19638. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  19639. {
  19640. string tj = dto.SearchCriteria;
  19641. 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}%')",
  19642. tj, tj, tj, tj, tj);
  19643. }
  19644. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  19645. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  19646. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  19647. From (
  19648. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  19649. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  19650. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  19651. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  19652. From Grp_DelegationInfo gdi
  19653. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  19654. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  19655. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  19656. Where gdi.IsDel = 0 {0}
  19657. ) temp ", sqlWhere);
  19658. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  19659. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  19660. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  19661. }
  19662. else
  19663. {
  19664. return Ok(JsonView(false, "查询失败"));
  19665. }
  19666. }
  19667. /// <summary>
  19668. /// 团组状态
  19669. /// 设置操作完成
  19670. /// </summary>
  19671. /// <param name="dto">团组列表请求dto</param>
  19672. /// <returns></returns>
  19673. [HttpPost]
  19674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19675. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  19676. {
  19677. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19678. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  19679. {
  19680. Id = dto.Id,
  19681. IsSure = 1
  19682. };
  19683. var result = await _sqlSugar.Updateable(_DelegationInfo)
  19684. .UpdateColumns(it => new { it.IsSure })
  19685. .WhereColumns(it => new { it.Id })
  19686. .ExecuteCommandAsync();
  19687. if (result > 0)
  19688. {
  19689. return Ok(JsonView(true, "操作完成!"));
  19690. }
  19691. return Ok(JsonView(false, "操作失败!"));
  19692. }
  19693. #endregion
  19694. #region 保险费用录入
  19695. /// <summary>
  19696. /// 根据团组Id查询保险费用列表
  19697. /// </summary>
  19698. /// <param name="dto"></param>
  19699. /// <returns></returns>
  19700. [HttpPost]
  19701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19702. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  19703. {
  19704. Result groupData = await _customersRep.CustomersByDiId(dto);
  19705. if (groupData.Code != 0)
  19706. {
  19707. return Ok(JsonView(false, groupData.Msg));
  19708. }
  19709. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19710. }
  19711. /// <summary>
  19712. /// 根据保险费用Id查询保险费用详细
  19713. /// </summary>
  19714. /// <param name="dto"></param>
  19715. /// <returns></returns>
  19716. [HttpPost]
  19717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19718. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  19719. {
  19720. try
  19721. {
  19722. Result groupData = await _customersRep.CustomersById(dto);
  19723. if (groupData.Code != 0)
  19724. {
  19725. return Ok(JsonView(false, groupData.Msg));
  19726. }
  19727. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19728. }
  19729. catch (Exception ex)
  19730. {
  19731. return Ok(JsonView(false, ex.Message));
  19732. }
  19733. }
  19734. /// <summary>
  19735. /// 保险费用录入页面初始化绑定
  19736. /// </summary>
  19737. /// <param name="dto"></param>
  19738. /// <returns></returns>
  19739. [HttpPost]
  19740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19741. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  19742. {
  19743. try
  19744. {
  19745. Result groupData = await _customersRep.CustomersInitialize(dto);
  19746. if (groupData.Code != 0)
  19747. {
  19748. return Ok(JsonView(false, groupData.Msg));
  19749. }
  19750. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19751. }
  19752. catch (Exception ex)
  19753. {
  19754. return Ok(JsonView(false, ex.Message));
  19755. }
  19756. }
  19757. /// <summary>
  19758. /// 保险费用操作(Status:1.新增,2.修改)
  19759. /// </summary>
  19760. /// <param name="dto"></param>
  19761. /// <returns></returns>
  19762. [HttpPost]
  19763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19764. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  19765. {
  19766. Result groupData = await _customersRep.OpCustomers(dto);
  19767. if (groupData.Code != 0)
  19768. {
  19769. return Ok(JsonView(false, groupData.Msg));
  19770. }
  19771. #region 应用推送
  19772. try
  19773. {
  19774. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  19775. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  19776. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  19777. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19778. //自动审核
  19779. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  19780. //2024-10-21 新增LZ UID
  19781. var userIds = new List<int>() { 21 };
  19782. string title = $"系统通知";
  19783. var diId = dto.DiId;
  19784. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19785. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19786. string content = "";
  19787. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19788. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19789. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19790. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  19791. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  19792. }
  19793. catch (Exception ex)
  19794. {
  19795. }
  19796. #endregion
  19797. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19798. }
  19799. /// <summary>
  19800. /// 保险文件上传
  19801. /// </summary>
  19802. /// <param name="file"></param>
  19803. /// <returns></returns>
  19804. [HttpPost]
  19805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19806. public async Task<IActionResult> UploadCus(IFormFile file)
  19807. {
  19808. try
  19809. {
  19810. if (file != null)
  19811. {
  19812. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19813. //文件名称
  19814. string projectFileName = file.FileName;
  19815. //上传的文件的路径
  19816. string filePath = "";
  19817. if (!Directory.Exists(fileDir))
  19818. {
  19819. Directory.CreateDirectory(fileDir);
  19820. }
  19821. //上传的文件的路径
  19822. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  19823. using (FileStream fs = System.IO.File.Create(filePath))
  19824. {
  19825. file.CopyTo(fs);
  19826. fs.Flush();
  19827. }
  19828. return Ok(JsonView(true, "上传成功!", projectFileName));
  19829. }
  19830. else
  19831. {
  19832. return Ok(JsonView(false, "上传失败!"));
  19833. }
  19834. }
  19835. catch (Exception ex)
  19836. {
  19837. return Ok(JsonView(false, ex.Message));
  19838. }
  19839. }
  19840. /// <summary>
  19841. /// 保险删除指定文件
  19842. /// </summary>
  19843. /// <param name="dto"></param>
  19844. /// <returns></returns>
  19845. [HttpPost]
  19846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19847. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  19848. {
  19849. try
  19850. {
  19851. string filePath = "";
  19852. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19853. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19854. //int id = 0;
  19855. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19856. // 删除该文件
  19857. try
  19858. {
  19859. System.IO.File.Delete(filePath);
  19860. 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()
  19861. {
  19862. Attachment = "",
  19863. }).ExecuteCommandAsync();
  19864. if (result != 0)
  19865. {
  19866. return Ok(JsonView(true, "成功!"));
  19867. }
  19868. else
  19869. {
  19870. return Ok(JsonView(false, "失败!"));
  19871. }
  19872. }
  19873. catch (Exception)
  19874. {
  19875. 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()
  19876. {
  19877. Attachment = "",
  19878. }).ExecuteCommandAsync();
  19879. if (result != 0)
  19880. {
  19881. return Ok(JsonView(true, "成功!"));
  19882. }
  19883. else
  19884. {
  19885. return Ok(JsonView(false, "失败!"));
  19886. }
  19887. }
  19888. }
  19889. catch (Exception ex)
  19890. {
  19891. return Ok(JsonView(false, "程序错误!"));
  19892. throw;
  19893. }
  19894. }
  19895. /// <summary>
  19896. /// 保险费用操作(删除)
  19897. /// </summary>
  19898. /// <param name="dto"></param>
  19899. /// <returns></returns>
  19900. [HttpPost]
  19901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19902. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19903. {
  19904. try
  19905. {
  19906. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19907. if (!res)
  19908. {
  19909. return Ok(JsonView(false, "删除失败"));
  19910. }
  19911. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19912. {
  19913. IsDel = 1,
  19914. DeleteUserId = dto.DeleteUserId,
  19915. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19916. }).ExecuteCommandAsync();
  19917. return Ok(JsonView(true, "删除成功!"));
  19918. }
  19919. catch (Exception ex)
  19920. {
  19921. return Ok(JsonView(false, "程序错误!"));
  19922. throw;
  19923. }
  19924. }
  19925. #endregion
  19926. #region 接团客户名单 PageId 104
  19927. /// <summary>
  19928. /// 接团客户名单
  19929. /// 迁移数据(慎用!)
  19930. /// </summary>
  19931. /// <returns></returns>
  19932. [HttpPost]
  19933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19934. public async Task<IActionResult> PostTourClientListChange()
  19935. {
  19936. try
  19937. {
  19938. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19939. //var groupClinetData1
  19940. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19941. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19942. int updateCount = 0;
  19943. if (oldOAClientList.Count > 0)
  19944. {
  19945. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19946. _sqlSugar.BeginTran();
  19947. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19948. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19949. foreach (var item in oldOAClientList)
  19950. {
  19951. int comId = 0;
  19952. string format = "yyyy-MM-dd HH:mm:ss";
  19953. string data11 = "1990-01-01 00:00";
  19954. var data1 = IsValidDate(item.OPdate, format);
  19955. if (data1) data11 = item.OPdate;
  19956. //客户公司验证
  19957. if (!string.IsNullOrEmpty(item.Company))
  19958. {
  19959. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19960. if (clientComInfo == null) // add
  19961. {
  19962. var addInfo = new Crm_CustomerCompany()
  19963. {
  19964. CompanyAbbreviation = "",
  19965. CompanyFullName = item.Company,
  19966. Address = "",
  19967. PostCodes = "",
  19968. LastedOpUserId = item.OPer,
  19969. LastedOpDt = Convert.ToDateTime(data11),
  19970. CreateUserId = item.OPer,
  19971. CreateTime = Convert.ToDateTime(data11),
  19972. IsDel = 0
  19973. };
  19974. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19975. if (comId1 > 0) comId = comId1;
  19976. }
  19977. else comId = clientComInfo.Id;
  19978. }
  19979. //客户人员验证
  19980. int clientId = 0;
  19981. string name = item.LastName + item.Name;
  19982. if (!string.IsNullOrEmpty(name))
  19983. {
  19984. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19985. if (clientInfo == null)
  19986. {
  19987. DateTime? dateTime = null;
  19988. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19989. if (isDt) dateTime = birthDayDt;
  19990. var addInfo1 = new Crm_DeleClient()
  19991. {
  19992. CrmCompanyId = comId,
  19993. DiId = -1,
  19994. LastName = item.LastName,
  19995. FirstName = item.Name,
  19996. OldName = "",
  19997. Pinyin = item.Pinyin,
  19998. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19999. Marriage = 0,
  20000. Phone = item.Phone,
  20001. Job = item.Job,
  20002. BirthDay = dateTime
  20003. };
  20004. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  20005. if (clientId1 > 0) clientId = clientId1;
  20006. }
  20007. else clientId = clientInfo.Id;
  20008. }
  20009. if (clientId < 1)
  20010. {
  20011. continue;
  20012. }
  20013. int airType = 0;
  20014. if (item.AirType == "超经舱") airType = 459;
  20015. else if (item.AirType == "公务舱") airType = 458;
  20016. else if (item.AirType == "经济舱") airType = 460;
  20017. else if (item.AirType == "其他") airType = 565;
  20018. else if (item.AirType == "头等舱") airType = 457;
  20019. var _TourClientListEntity = new Grp_TourClientList()
  20020. {
  20021. DiId = item.Diid,
  20022. ClientId = clientId,
  20023. CreateUserId = item.OPer,
  20024. CreateTime = Convert.ToDateTime(data11),
  20025. Remark = item.Remark,
  20026. IsDel = item.Isdel,
  20027. ShippingSpaceTypeId = airType,
  20028. ShippingSpaceSpecialNeeds = item.AirRemark,
  20029. HotelSpecialNeeds = item.RoomType
  20030. };
  20031. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  20032. if (_TourClientList > 0)
  20033. {
  20034. updateCount++;
  20035. }
  20036. }
  20037. _sqlSugar.CommitTran();
  20038. }
  20039. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  20040. }
  20041. catch (Exception ex)
  20042. {
  20043. _sqlSugar.RollbackTran();
  20044. return Ok(JsonView(false, ex.Message));
  20045. }
  20046. //return Ok(JsonView(true));
  20047. }
  20048. private bool IsValidDate(string dateString, string format)
  20049. {
  20050. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  20051. }
  20052. /// <summary>
  20053. /// 接团客户名单
  20054. /// 根据团组Id查询List
  20055. /// </summary>
  20056. /// <param name="_dto"></param>
  20057. /// <returns></returns>
  20058. [HttpPost]
  20059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20060. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  20061. {
  20062. #region 参数验证
  20063. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  20064. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  20065. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  20066. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20067. #region 页面操作权限验证
  20068. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20069. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20070. #endregion
  20071. #endregion
  20072. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  20073. if (viewData.Code != 0)
  20074. {
  20075. return Ok(JsonView(false, viewData.Msg));
  20076. }
  20077. return Ok(JsonView(viewData.Data));
  20078. }
  20079. /// <summary>
  20080. /// 接团客户名单
  20081. /// 基础数据 Init
  20082. /// </summary>
  20083. /// <param name="_dto"></param>
  20084. /// <returns></returns>
  20085. [HttpPost]
  20086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20087. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  20088. {
  20089. #region 参数验证
  20090. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20091. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20092. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20093. #region 页面操作权限验证
  20094. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20095. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20096. #endregion
  20097. #endregion
  20098. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  20099. }
  20100. /// <summary>
  20101. /// 接团客户名单
  20102. /// 根据 Id查询 Details
  20103. /// </summary>
  20104. /// <param name="_dto"></param>
  20105. /// <returns></returns>
  20106. [HttpPost]
  20107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20108. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  20109. {
  20110. #region 参数验证
  20111. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20112. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20113. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20114. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20115. #region 页面操作权限验证
  20116. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20117. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20118. #endregion
  20119. #endregion
  20120. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  20121. if (viewData.Code != 0)
  20122. {
  20123. return Ok(JsonView(false, viewData.Msg));
  20124. }
  20125. return Ok(JsonView(viewData.Data));
  20126. }
  20127. /// <summary>
  20128. /// 接团客户名单
  20129. /// Add Or Edit
  20130. /// </summary>
  20131. /// <param name="_dto"></param>
  20132. /// <returns></returns>
  20133. [HttpPost]
  20134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20135. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  20136. {
  20137. #region 参数验证
  20138. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20139. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20140. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20141. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20142. #region 页面操作权限验证
  20143. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20144. if (_dto.Id == 0) //添加
  20145. {
  20146. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20147. }
  20148. else if (_dto.Id >= 0) //修改
  20149. {
  20150. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  20151. }
  20152. #endregion
  20153. #endregion
  20154. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  20155. if (viewData.Code != 0)
  20156. {
  20157. return Ok(JsonView(false, viewData.Msg));
  20158. }
  20159. return Ok(JsonView(true));
  20160. }
  20161. /// <summary>
  20162. /// 接团客户名单
  20163. /// json字符串 AddMultiple(添加多个)
  20164. /// </summary>
  20165. /// <param name="_dto"></param>
  20166. /// <returns></returns>
  20167. [HttpPost]
  20168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20169. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  20170. {
  20171. #region 参数验证
  20172. string jsonLabel = _dto.JsonLabel;
  20173. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20174. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20175. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20176. #region 页面操作权限验证
  20177. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20178. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20179. #endregion
  20180. #endregion
  20181. var request = new TourClientListAddMultipleDto();
  20182. request.DiId = _dto.DiId;
  20183. request.UserId = _dto.UserId;
  20184. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  20185. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  20186. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  20187. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  20188. var infos = new List<TourClientListInfo>();
  20189. foreach (var data in datas)
  20190. {
  20191. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  20192. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  20193. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  20194. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  20195. {
  20196. continue;
  20197. }
  20198. infos.Add(new TourClientListInfo()
  20199. {
  20200. IsAccompany = 1,
  20201. LastName = lastName,
  20202. FirstName = firstName,
  20203. Pinyin = lastNameEn + @"/" + firstNameEn,
  20204. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  20205. CompanyFullName = data.CompanyFullName,
  20206. Job = data.Job
  20207. });
  20208. }
  20209. if (infos.Any())
  20210. {
  20211. var viewData = await _tourClientListRep._AddMultiple(request);
  20212. if (viewData.Code != 0)
  20213. {
  20214. return Ok(JsonView(false, viewData.Msg));
  20215. }
  20216. return Ok(JsonView(true));
  20217. }
  20218. return Ok(JsonView(false));
  20219. }
  20220. /// <summary>
  20221. /// 接团客户名单
  20222. /// AddMultiple(添加多个)
  20223. /// </summary>
  20224. /// <param name="_dto"></param>
  20225. /// <returns></returns>
  20226. [HttpPost]
  20227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20228. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  20229. {
  20230. #region 参数验证
  20231. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20232. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20233. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20234. #region 页面操作权限验证
  20235. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20236. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20237. #endregion
  20238. #endregion
  20239. var viewData = await _tourClientListRep._AddMultiple(_dto);
  20240. if (viewData.Code != 0)
  20241. {
  20242. return Ok(JsonView(false, viewData.Msg));
  20243. }
  20244. return Ok(JsonView(true));
  20245. }
  20246. /// <summary>
  20247. /// 接团客户名单
  20248. /// Del
  20249. /// </summary>
  20250. /// <param name="_dto"></param>
  20251. /// <returns></returns>
  20252. [HttpPost]
  20253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20254. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  20255. {
  20256. #region 参数验证
  20257. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20258. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20259. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20260. #region 页面操作权限验证
  20261. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20262. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20263. #endregion
  20264. #endregion
  20265. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  20266. if (viewData.Code != 0)
  20267. {
  20268. return Ok(JsonView(false, viewData.Msg));
  20269. }
  20270. return Ok(JsonView(true));
  20271. }
  20272. /// <summary>
  20273. /// 接团客户名单
  20274. /// 文件下载 客户名单
  20275. /// </summary>
  20276. /// <param name="_dto"></param>
  20277. /// <returns></returns>
  20278. [HttpPost]
  20279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20280. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  20281. {
  20282. #region 参数验证
  20283. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20284. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20285. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  20286. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20287. #region 页面操作权限验证
  20288. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20289. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20290. #endregion
  20291. #endregion
  20292. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  20293. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  20294. From Grp_TourClientList tcl
  20295. Left Join
  20296. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  20297. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  20298. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  20299. From Crm_DeleClient dc
  20300. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  20301. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  20302. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  20303. Where dc.IsDel = 0) temp
  20304. On temp.DcId =tcl.ClientId
  20305. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  20306. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  20307. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  20308. //载入模板
  20309. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  20310. if (_dto.Language == 1)
  20311. {
  20312. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  20313. }
  20314. //载入模板
  20315. var doc = new Document(tempPath);
  20316. DocumentBuilder builder = new DocumentBuilder(doc);
  20317. //获取word里所有表格
  20318. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20319. //获取所填表格的序数
  20320. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20321. var rowStart = tableOne.Rows[0]; //获取第1行
  20322. if (_dto.Language == 0)
  20323. {
  20324. //循环赋值
  20325. for (int i = 0; i < DcList.Count; i++)
  20326. {
  20327. EncryptionProcessor.DecryptProperties(DcList[i]);
  20328. builder.MoveToCell(0, i + 1, 0, 0);
  20329. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  20330. builder.MoveToCell(0, i + 1, 1, 0);
  20331. int sex = DcList[i].Sex;
  20332. string sexStr = string.Empty;
  20333. if (sex == 0) sexStr = "男";
  20334. else if (sex == 1) sexStr = "女";
  20335. else sexStr = "未设置";
  20336. builder.Write(sexStr);
  20337. builder.MoveToCell(0, i + 1, 2, 0);
  20338. string birthDay = DcList[i].BirthDay;
  20339. string birthDayStr = string.Empty;
  20340. if (!string.IsNullOrEmpty(birthDay))
  20341. {
  20342. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  20343. }
  20344. builder.Write(birthDayStr);
  20345. builder.MoveToCell(0, i + 1, 3, 0);
  20346. string company = "";
  20347. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20348. {
  20349. company = DcList[i].CompanyFullName.ToString();
  20350. }
  20351. builder.Write(company);
  20352. builder.MoveToCell(0, i + 1, 4, 0);
  20353. builder.Write(DcList[i].Job);
  20354. }
  20355. }
  20356. else if (_dto.Language == 1)
  20357. {
  20358. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  20359. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  20360. List<string> transArrayStr = new List<string>();
  20361. string transStrRes1 = "";
  20362. for (int i = 0; i < DcList.Count; i++)
  20363. {
  20364. var dc = DcList[i];
  20365. EncryptionProcessor.DecryptProperties(dc);
  20366. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  20367. if (dc.Job.Equals("暂无")) dc.Job = "-";
  20368. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  20369. if (DcList.Count - 1 == i) transStrRes1 += str1;
  20370. else transStrRes1 += $"{str1}|";
  20371. }
  20372. #region AI转英文
  20373. string jsonValue = JsonConvert.SerializeObject(DcList);
  20374. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  20375. List<SeedMessages> messages = new List<SeedMessages>()
  20376. {
  20377. new SeedMessages
  20378. {
  20379. Role = KimiRole.user,
  20380. Content = jsonValue + text
  20381. }
  20382. };
  20383. KiMiApiClient client = new KiMiApiClient();
  20384. var kimiApiResult = await client.SeedMessage(messages);
  20385. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20386. string clients = kimiApiResult_JObject["content"].ToString();
  20387. string startStr = "```json", endStr = "```";
  20388. // 判断并清除开头部分
  20389. if (clients.StartsWith(startStr))
  20390. {
  20391. clients = clients.Remove(0, startStr.Length);
  20392. }
  20393. // 判断并清除结尾部分
  20394. if (clients.EndsWith(endStr))
  20395. {
  20396. clients = clients.Remove(clients.Length - endStr.Length);
  20397. }
  20398. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  20399. //循环赋值
  20400. for (int i = 0; i < en_Json.Count; i++)
  20401. {
  20402. var dc = en_Json[i];
  20403. var dc1 = DcList.Find(x => x.Id == dc.Id);
  20404. string PYName = dc.FirstName + " " + dc.LastName;
  20405. builder.MoveToCell(0, i + 1, 0, 0);
  20406. builder.Write(PYName);
  20407. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  20408. builder.MoveToCell(0, i + 1, 1, 0);
  20409. builder.Write(sex);
  20410. DateTime birthDt;
  20411. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  20412. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20413. builder.MoveToCell(0, i + 1, 2, 0);
  20414. builder.Write(birthday);
  20415. string company = string.Empty, job = string.Empty;
  20416. company = dc.CompanyFullName;
  20417. job = dc.Job;
  20418. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  20419. {
  20420. //查询对照表
  20421. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  20422. if (tempCec != null)
  20423. {
  20424. company = tempCec.enName;
  20425. }
  20426. }
  20427. builder.MoveToCell(0, i + 1, 3, 0);
  20428. builder.Write(company);
  20429. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  20430. {
  20431. //查询对照表
  20432. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  20433. if (tempPec != null)
  20434. {
  20435. job = tempPec.enName;
  20436. }
  20437. }
  20438. builder.MoveToCell(0, i + 1, 4, 0);
  20439. builder.Write(job);
  20440. }
  20441. #endregion
  20442. #region 旧翻译英文处理
  20443. ////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";
  20444. //string transStrRes = "";
  20445. //if (transStrRes1.Length > 0)
  20446. //{
  20447. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  20448. //}
  20449. ////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
  20450. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  20451. ////List<string> transArray = new List<string> { };
  20452. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  20453. //if (transStrRes.Contains("|"))
  20454. //{
  20455. // string[] transArray1 = transStrRes.Split('|');
  20456. // if (transArray1.Length > 0)
  20457. // {
  20458. // foreach (var item in transArray1)
  20459. // {
  20460. // if (item.Contains("&"))
  20461. // {
  20462. // string[] transArray2 = item.Split('&');
  20463. // int index = 0;
  20464. // string companyName = "", job = "";
  20465. // if (transArray2.Length > 0)
  20466. // {
  20467. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  20468. // if (1 < transArray2.Length) companyName = transArray2[1];
  20469. // if (2 < transArray2.Length) job = transArray2[2];
  20470. // }
  20471. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  20472. // }
  20473. // }
  20474. // }
  20475. //}
  20476. ////循环赋值
  20477. //for (int i = 0; i < DcList.Count; i++)
  20478. //{
  20479. // string PYName = "";
  20480. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  20481. // {
  20482. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  20483. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  20484. // PYName = PY_First + " " + PY_Last;
  20485. // }
  20486. // else
  20487. // {
  20488. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  20489. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  20490. // PYName = PY_First + " " + PY_Last;
  20491. // }
  20492. // builder.MoveToCell(0, i + 1, 0, 0);
  20493. // builder.Write(PYName);
  20494. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  20495. // builder.MoveToCell(0, i + 1, 1, 0);
  20496. // builder.Write(sex);
  20497. // DateTime birthDt;
  20498. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  20499. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20500. // builder.MoveToCell(0, i + 1, 2, 0);
  20501. // builder.Write(birthday);
  20502. // string company = string.Empty, job = string.Empty;
  20503. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  20504. // if (dcTransInfo != null)
  20505. // {
  20506. // company = dcTransInfo.CompanyName;
  20507. // job = dcTransInfo.Job;
  20508. // }
  20509. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20510. // {
  20511. // //查询对照表
  20512. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  20513. // if (tempCec != null)
  20514. // {
  20515. // company = tempCec.enName;
  20516. // }
  20517. // //翻译
  20518. // else
  20519. // {
  20520. // }
  20521. // }
  20522. // builder.MoveToCell(0, i + 1, 3, 0);
  20523. // builder.Write(company);
  20524. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  20525. // {
  20526. // //查询对照表
  20527. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  20528. // if (tempPec != null)
  20529. // {
  20530. // job = tempPec.enName;
  20531. // }
  20532. // //翻译
  20533. // else
  20534. // {
  20535. // }
  20536. // }
  20537. // builder.MoveToCell(0, i + 1, 4, 0);
  20538. // builder.Write(job);
  20539. //}
  20540. #endregion
  20541. }
  20542. //删除多余行
  20543. while (tableOne.Rows.Count > DcList.Count + 1)
  20544. {
  20545. tableOne.Rows.RemoveAt(DcList.Count + 1);
  20546. }
  20547. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  20548. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  20549. doc.Save(fileDir);
  20550. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  20551. return Ok(JsonView(true, "操作成功!", Url));
  20552. }
  20553. private class TranslateInfo
  20554. {
  20555. public int Index { get; set; }
  20556. public string CompanyName { get; set; }
  20557. public string Job { get; set; }
  20558. }
  20559. [HttpPost]
  20560. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  20561. {
  20562. if (files.Count == 0)
  20563. {
  20564. return Ok(JsonView(false, "文件为空"));
  20565. }
  20566. KiMiApiClient KiMiApi = new KiMiApiClient();
  20567. var seedConter = await KiMiApi.UploadFilesAsync(files);
  20568. if (seedConter.Count == 0)
  20569. {
  20570. return Ok(JsonView(false, "上传结果为空!"));
  20571. }
  20572. var messages = new List<SeedMessages>
  20573. {
  20574. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  20575. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  20576. };
  20577. messages.InsertRange(1, seedConter);
  20578. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  20579. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20580. string clients = kimiApiResult_JObject["content"].ToString();
  20581. string startStr = "```json", endStr = "```";
  20582. // 判断并清除开头部分
  20583. if (clients.StartsWith(startStr))
  20584. {
  20585. clients = clients.Remove(0, startStr.Length);
  20586. }
  20587. // 判断并清除结尾部分
  20588. if (clients.EndsWith(endStr))
  20589. {
  20590. clients = clients.Remove(clients.Length - endStr.Length);
  20591. }
  20592. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  20593. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  20594. {
  20595. {"姓", "LastName" },
  20596. {"名", "FirstName" },
  20597. {"姓名拼音", "Pinyin" },
  20598. {"性别", "Sex" },
  20599. {"单位", "CompanyFullName" },
  20600. {"职务", "Job" },
  20601. {"出生日期", "Birthday" },
  20602. };
  20603. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  20604. foreach (var item in clients_JObject)
  20605. {
  20606. BaiduClientOCRView cdc = new BaiduClientOCRView();
  20607. foreach (var field in clientFieldMap.Keys)
  20608. {
  20609. if (item.TryGetValue(field, out JToken value))
  20610. {
  20611. var getValue = value.ToString();
  20612. System.Type type = cdc.GetType();
  20613. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  20614. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  20615. propertyInfo.SetValue(cdc, propertyValue);
  20616. }
  20617. }
  20618. crmClients.Add(cdc);
  20619. }
  20620. return Ok(JsonView(new
  20621. {
  20622. fileCount = files.Count,
  20623. UploadCount = seedConter.Count,
  20624. ApiResult = clients,
  20625. CrmClients = crmClients
  20626. }));
  20627. }
  20628. #endregion
  20629. #region 团组倒推表
  20630. /// <summary>
  20631. /// 倒推表基础数据
  20632. /// Init
  20633. /// </summary>
  20634. /// <returns></returns>
  20635. [HttpPost]
  20636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20637. public async Task<IActionResult> PostInvertedListInit()
  20638. {
  20639. var viewData = await _invertedListRep._Init();
  20640. if (viewData.Code != 0)
  20641. {
  20642. return Ok(JsonView(false, viewData.Msg));
  20643. }
  20644. return Ok(JsonView(viewData.Data));
  20645. }
  20646. /// <summary>
  20647. /// 倒推表
  20648. /// Info
  20649. /// </summary>
  20650. /// <param name="dto"></param>
  20651. /// <returns></returns>
  20652. [HttpPost]
  20653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20654. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  20655. {
  20656. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  20657. if (viewData.Code != 0)
  20658. {
  20659. return Ok(JsonView(false, viewData.Msg));
  20660. }
  20661. return Ok(JsonView(viewData.Data));
  20662. }
  20663. /// <summary>
  20664. /// 倒推表
  20665. /// Create
  20666. /// </summary>
  20667. /// <param name="dto"></param>
  20668. /// <returns></returns>
  20669. [HttpPost]
  20670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20671. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  20672. {
  20673. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  20674. if (viewData.Code != 0)
  20675. {
  20676. return Ok(JsonView(false, viewData.Msg));
  20677. }
  20678. return Ok(JsonView(viewData.Data));
  20679. }
  20680. /// <summary>
  20681. /// 倒推表
  20682. /// Update
  20683. /// </summary>
  20684. /// <param name="dto"></param>
  20685. /// <returns></returns>
  20686. [HttpPost]
  20687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20688. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  20689. {
  20690. var viewData = await _invertedListRep._Update(dto);
  20691. if (viewData.Code != 0)
  20692. {
  20693. return Ok(JsonView(false, viewData.Msg));
  20694. }
  20695. return Ok(JsonView(viewData.Data));
  20696. }
  20697. /// <summary>
  20698. /// 倒推表
  20699. /// File Download
  20700. /// </summary>
  20701. /// <param name="dto"></param>
  20702. /// <returns></returns>
  20703. [HttpPost]
  20704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20705. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  20706. {
  20707. var info2 = await _invertedListRep._Info(1, dto.DiId);
  20708. if (info2.Code != 0)
  20709. {
  20710. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  20711. }
  20712. var info1 = info2.Data as InvertedListInfoView;
  20713. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  20714. string teamName = "";
  20715. if (info != null) teamName = info.TeamName;
  20716. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  20717. var doc = new Document();
  20718. var builder = new DocumentBuilder(doc);
  20719. #region old insert
  20720. ////载入模板
  20721. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  20722. //Document doc = new Document(tempPath);
  20723. //DocumentBuilder builder = new DocumentBuilder(doc);
  20724. //利用键值对存放数据
  20725. //Dictionary<string, string> dic = new Dictionary<string, string>();
  20726. //dic.Add("TeamName", teamName);
  20727. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  20728. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  20729. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  20730. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  20731. //dic.Add("SQRemark", info1.ApprovalRemark);
  20732. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  20733. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  20734. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  20735. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  20736. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  20737. //dic.Add("QZRemark", info1.VisaInformationRemark);
  20738. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  20739. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  20740. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  20741. //dic.Add("CQRemark", info1.IssueVisaRemark);
  20742. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  20743. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  20744. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  20745. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  20746. //#region 填充word模板书签内容
  20747. //foreach (var key in dic.Keys)
  20748. //{
  20749. // builder.MoveToBookmark(key);
  20750. // builder.Write(dic[key]);
  20751. //}
  20752. //#endregion
  20753. #endregion
  20754. #region New Insert
  20755. string titleFont = $"仿宋",
  20756. contentFont = $"仿宋";
  20757. var fontColor = Color.FromArgb(64, 64, 64);
  20758. //设置标题 团组名称
  20759. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20760. builder.Font.Name = titleFont;
  20761. builder.Font.Color = fontColor;
  20762. builder.Font.Size = 12;
  20763. builder.Font.Bold = true;
  20764. builder.Writeln(teamName);
  20765. //设置副标题 团组出访时间
  20766. builder.Font.Size = 12;
  20767. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  20768. builder.Writeln();
  20769. var backgroundColor = Color.FromArgb(199, 199, 199);
  20770. var table = builder.StartTable();
  20771. builder.InsertCell();
  20772. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  20773. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  20774. builder.CellFormat.Borders.LineWidth = 1;
  20775. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  20776. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  20777. builder.RowFormat.Height = 40;
  20778. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20779. builder.Font.Name = contentFont;
  20780. builder.Font.Size = 12;
  20781. builder.Font.Bold = true;
  20782. builder.Font.Color = fontColor;
  20783. builder.Write("时间");
  20784. builder.InsertCell();
  20785. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  20786. builder.Write("流程");
  20787. builder.InsertCell();
  20788. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  20789. builder.Write("说明");
  20790. builder.EndRow();
  20791. //报批资料准备
  20792. if (info1.IsSelectedAirportd)
  20793. {
  20794. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  20795. }
  20796. //报批/提供送签资料
  20797. if (info1.IsSelectedApprovalData)
  20798. {
  20799. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  20800. }
  20801. //出批件护照办理
  20802. if (info1.IsSelectedIssueApproval)
  20803. {
  20804. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  20805. }
  20806. //签证资料准备
  20807. if (info1.IsSelectedVisaInfo)
  20808. {
  20809. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  20810. }
  20811. //送签
  20812. if (info1.IsSelectedSendVisa)
  20813. {
  20814. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  20815. }
  20816. //出签
  20817. if (info1.IsSelectedIssueVisa)
  20818. {
  20819. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  20820. }
  20821. //机票
  20822. if (info1.IsSelectedAirTicket)
  20823. {
  20824. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  20825. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  20826. }
  20827. //酒店
  20828. if (info1.IsSelectedHotel)
  20829. {
  20830. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  20831. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  20832. }
  20833. //开行前会
  20834. if (info1.IsSelectedPreTripMeeting)
  20835. {
  20836. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  20837. }
  20838. //送机
  20839. if (info1.IsSelectedAirportdDropOff)
  20840. {
  20841. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  20842. }
  20843. builder.EndTable();
  20844. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  20845. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  20846. for (int i = 0; i < table.Rows.Count; i++)
  20847. {
  20848. var row = table.Rows[i];
  20849. //设置宽度
  20850. row.Cells[0].CellFormat.Width = 20.00;
  20851. row.Cells[1].CellFormat.Width = 30.00;
  20852. row.Cells[2].CellFormat.Width = 50.00;
  20853. if (i != 0)
  20854. {
  20855. //边框设置
  20856. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20857. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20858. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20859. }
  20860. }
  20861. #region 页脚插入图片
  20862. // 创建页脚
  20863. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20864. doc.FirstSection.HeadersFooters.Add(footer);
  20865. Paragraph para = new Paragraph(doc);
  20866. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20867. footer.AppendChild(para);
  20868. builder.MoveTo(para);
  20869. string imagePath = "./Images/FMGJ_Log.png";
  20870. builder.InsertImage(imagePath);
  20871. #endregion
  20872. #endregion
  20873. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20874. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20875. string filePath = fileDir + $@"InvertedList/{fileName}";
  20876. doc.Save(filePath);
  20877. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20878. return Ok(JsonView(true, "操作成功!", Url));
  20879. }
  20880. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20881. {
  20882. var fontColor = Color.FromArgb(64, 64, 64);
  20883. builder.InsertCell();
  20884. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20885. builder.RowFormat.Height = 40;
  20886. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20887. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20888. builder.Font.Name = fontName;
  20889. builder.Font.Size = 8;
  20890. builder.Font.Bold = true;
  20891. builder.Font.Color = fontColor;
  20892. builder.Write(dateTime);
  20893. builder.InsertCell();
  20894. builder.Font.Size = 9;
  20895. builder.Font.Bold = true;
  20896. builder.Font.Color = fontColor;
  20897. builder.Write(content);
  20898. builder.InsertCell();
  20899. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20900. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20901. builder.Font.Size = 9;
  20902. builder.Font.Bold = false;
  20903. builder.Font.Color = fontColor;
  20904. builder.Write(reamrk);
  20905. builder.EndRow();
  20906. }
  20907. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20908. {
  20909. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20910. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20911. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20912. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20913. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20914. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20915. }
  20916. #endregion
  20917. #region 会务倒推表
  20918. /// <summary>
  20919. /// 会务倒推表
  20920. /// Init
  20921. /// </summary>
  20922. /// <returns></returns>
  20923. [HttpPost]
  20924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20925. public async Task<IActionResult> InforRetrogressTableInit()
  20926. {
  20927. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20928. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20929. return Ok(JsonView(false, groupData.Msg));
  20930. }
  20931. /// <summary>
  20932. /// 会务倒推表
  20933. /// ExcelDownload
  20934. /// </summary>
  20935. /// <param name="dto"></param>
  20936. /// <returns></returns>
  20937. [HttpPost]
  20938. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20940. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20941. {
  20942. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20943. var validatorRes = await validator.ValidateAsync(dto);
  20944. if (!validatorRes.IsValid)
  20945. {
  20946. StringBuilder sb = new StringBuilder();
  20947. foreach (var item in validatorRes.Errors)
  20948. {
  20949. sb.AppendLine(item.ErrorMessage);
  20950. }
  20951. return Ok(JsonView(false, sb.ToString()));
  20952. }
  20953. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20954. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20955. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20956. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20957. #region Excel
  20958. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20959. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20960. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20961. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20962. var fileNamePrefix = string.Empty;
  20963. if (days >= 30)
  20964. {
  20965. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20966. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20967. }
  20968. else if (days < 30 && days > 7)
  20969. {
  20970. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20971. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20972. }
  20973. else if (days <= 7)
  20974. {
  20975. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20976. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20977. }
  20978. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20979. fileName = CommonFun.ValidFileName(fileName);
  20980. //载入模板
  20981. WorkbookDesigner designer = new WorkbookDesigner();
  20982. designer.Workbook = new Workbook(tempPath);
  20983. designer.Process();
  20984. if (!Directory.Exists(savePath))
  20985. {
  20986. Directory.CreateDirectory(savePath);
  20987. }
  20988. string serverPath = $"{savePath}{fileName}";
  20989. designer.Workbook.Save(serverPath);
  20990. string rst = $"{servicePath}{ftpPath}{fileName}";
  20991. #endregion
  20992. return Ok(JsonView(new { url = rst }));
  20993. }
  20994. #endregion
  20995. #region 三公签证费用(签证费、代办费)
  20996. /// <summary>
  20997. /// 三公签证费用(签证费、代办费)
  20998. /// List
  20999. /// </summary>
  21000. /// <returns></returns>
  21001. [HttpPost]
  21002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21003. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  21004. {
  21005. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  21006. }
  21007. /// <summary>
  21008. /// 三公签证费用(签证费、代办费)
  21009. /// Add Or Update
  21010. /// </summary>
  21011. /// <returns></returns>
  21012. [HttpPost]
  21013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21014. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  21015. {
  21016. var _view = await _visaFeeInfoRep.Update(_dto);
  21017. if (_view.Code != 0)
  21018. {
  21019. return Ok(JsonView(false, _view.Msg));
  21020. }
  21021. return Ok(JsonView(true, _view.Msg));
  21022. }
  21023. #endregion
  21024. #region 酒店询价
  21025. /// <summary>
  21026. /// 酒店询价
  21027. /// Init
  21028. /// </summary>
  21029. /// <returns></returns>
  21030. [HttpPost]
  21031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21032. public async Task<IActionResult> PostHotelInquiryInit()
  21033. {
  21034. var res = await _hotelInquiryRep._Init();
  21035. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21036. return Ok(JsonView(true, res.Msg, res.Data));
  21037. }
  21038. /// <summary>
  21039. /// 酒店询价
  21040. /// page Item
  21041. /// </summary>
  21042. /// <param name="_dto"></param>
  21043. /// <returns></returns>
  21044. [HttpPost]
  21045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21046. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  21047. {
  21048. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  21049. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21050. var view = res.Data as PageDataViewBase;
  21051. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  21052. }
  21053. /// <summary>
  21054. /// 酒店询价
  21055. /// info
  21056. /// </summary>
  21057. /// <param name="_dto"></param>
  21058. /// <returns></returns>
  21059. [HttpPost]
  21060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21061. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  21062. {
  21063. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  21064. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21065. return Ok(JsonView(true, res.Msg, res.Data));
  21066. }
  21067. /// <summary>
  21068. /// 酒店询价
  21069. /// Add Or Edit
  21070. /// </summary>
  21071. /// <param name="_dto"></param>
  21072. /// <returns></returns>
  21073. [HttpPost]
  21074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21075. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  21076. {
  21077. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  21078. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21079. return Ok(JsonView(true, res.Msg, res.Data));
  21080. }
  21081. /// <summary>
  21082. /// 酒店询价
  21083. /// Del
  21084. /// </summary>
  21085. /// <param name="_dto"></param>
  21086. /// <returns></returns>
  21087. [HttpPost]
  21088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21089. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  21090. {
  21091. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  21092. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21093. return Ok(JsonView(true, res.Msg, res.Data));
  21094. }
  21095. #endregion
  21096. #region 下载匹配op行程单
  21097. /// <summary>
  21098. /// 匹配op行程单
  21099. /// Init
  21100. /// </summary>
  21101. /// <param name="dto">团组列表请求dto</param>
  21102. /// <returns></returns>
  21103. [HttpPost]
  21104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21105. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  21106. {
  21107. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21108. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21109. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  21110. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  21111. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  21112. .Where(it => it.IsDel == 0)
  21113. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  21114. .OrderByDescending(it => it.VisitStartDate)
  21115. .ToList();
  21116. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  21117. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21118. var diids = groupInfos.Select(it => it.Id).ToList();
  21119. List<string> countrys = new List<string>();
  21120. foreach (var item in country)
  21121. {
  21122. var data = _groupRepository.FormartTeamName(item);
  21123. var dataArray = _groupRepository.GroupSplitCountry(data);
  21124. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21125. }
  21126. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  21127. List<string> areaArray = new List<string>(); //GetGroupCityLine
  21128. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  21129. foreach (var item in areaItem)
  21130. {
  21131. string areaStr = item.Value;
  21132. if (!string.IsNullOrEmpty(areaStr))
  21133. {
  21134. string[] str1 = areaStr.Split("-");
  21135. if (str1.Length > 0)
  21136. {
  21137. areaArray.AddRange(str1);
  21138. }
  21139. }
  21140. }
  21141. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  21142. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  21143. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  21144. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  21145. .ToList();
  21146. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  21147. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  21148. .Where(it => countriesIds.Contains(it.Id))
  21149. .Select(it => new { it.Id, Name = it.Name_CN })
  21150. .ToList();
  21151. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  21152. .Select(it => it.TeamName).ToList();
  21153. stopwatch.Stop();
  21154. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  21155. }
  21156. ///// <summary>
  21157. ///// 匹配op行程单
  21158. ///// Init 查询区域数据
  21159. ///// </summary>
  21160. ///// <param name="dto">团组列表请求dto</param>
  21161. ///// <returns></returns>
  21162. //[HttpPost]
  21163. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21164. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  21165. //{
  21166. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21167. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  21168. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  21169. // if (string.IsNullOrEmpty(countriesDataStr))
  21170. // {
  21171. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  21172. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  21173. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  21174. // }
  21175. // else
  21176. // {
  21177. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  21178. // }
  21179. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  21180. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  21181. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  21182. // List<dynamic> childList = new List<dynamic>();
  21183. // int parentId = dto.CountriesId;
  21184. // if (provinceData.Count > 1)
  21185. // {
  21186. // foreach (var item1 in provinceData)
  21187. // {
  21188. // List<dynamic> childList1 = new List<dynamic>();
  21189. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  21190. // foreach (var item2 in citiesData1)
  21191. // {
  21192. // List<dynamic> childList2 = new List<dynamic>();
  21193. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21194. // foreach (var item3 in countiesData1)
  21195. // {
  21196. // childList2.Add(new
  21197. // {
  21198. // id = item3.Id,
  21199. // parentId = item2.Id,
  21200. // level = "district",
  21201. // name = item3.Name_CN,
  21202. // });
  21203. // }
  21204. // childList1.Add(new
  21205. // {
  21206. // id = item2.Id,
  21207. // parentId = item1.Id,
  21208. // level = "city",
  21209. // name = item2.Name_CN,
  21210. // childList = childList2
  21211. // });
  21212. // }
  21213. // childList.Add(new
  21214. // {
  21215. // id = item1.Id,
  21216. // parentId = parentId,
  21217. // level = "province",
  21218. // name = item1.Name_CN,
  21219. // childList = childList1
  21220. // });
  21221. // }
  21222. // //城市
  21223. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  21224. // foreach (var item2 in citiesData2)
  21225. // {
  21226. // List<dynamic> childList22 = new List<dynamic>();
  21227. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21228. // foreach (var item3 in countiesData1)
  21229. // {
  21230. // childList22.Add(new
  21231. // {
  21232. // id = item3.Id,
  21233. // parentId = item2.Id,
  21234. // level = "district",
  21235. // name = item3.Name_CN,
  21236. // });
  21237. // }
  21238. // childList.Add(new
  21239. // {
  21240. // id = item2.Id,
  21241. // parentId = parentId,
  21242. // level = "city",
  21243. // name = item2.Name_CN,
  21244. // childList = childList22
  21245. // });
  21246. // }
  21247. // }
  21248. // else
  21249. // {
  21250. // foreach (var item2 in citiesData)
  21251. // {
  21252. // string cname = item2.Name_CN;
  21253. // List<dynamic> childList1 = new List<dynamic>();
  21254. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21255. // foreach (var item3 in countiesData1)
  21256. // {
  21257. // childList1.Add(new
  21258. // {
  21259. // Id = item3.Id,
  21260. // parentId = item2.Id,
  21261. // level = "district",
  21262. // name = item3.Name_CN
  21263. // });
  21264. // }
  21265. // childList.Add(new
  21266. // {
  21267. // id = item2.Id,
  21268. // parentId = parentId,
  21269. // level = "city",
  21270. // name = item2.Name_CN,
  21271. // childList = childList1
  21272. // });
  21273. // }
  21274. // }
  21275. // stopwatch.Stop();
  21276. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  21277. //}
  21278. /// <summary>
  21279. /// 匹配op行程单
  21280. /// 接团信息列表 Page
  21281. /// </summary>
  21282. /// <param name="dto">团组列表请求dto</param>
  21283. /// <returns></returns>
  21284. [HttpPost]
  21285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21286. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  21287. {
  21288. var swatch = new Stopwatch();
  21289. swatch.Start();
  21290. #region 参数验证
  21291. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21292. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21293. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21294. #region 页面操作权限验证
  21295. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21296. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  21297. #endregion
  21298. #endregion
  21299. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21300. {
  21301. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  21302. //string sqlWhere = "";
  21303. if (!string.IsNullOrEmpty(dto.Country))
  21304. {
  21305. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  21306. }
  21307. if (!string.IsNullOrEmpty(dto.Area))
  21308. {
  21309. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  21310. }
  21311. if (!string.IsNullOrEmpty(dto.TeamName))
  21312. {
  21313. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  21314. }
  21315. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  21316. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  21317. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  21318. swatch.Stop();
  21319. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  21320. }
  21321. else
  21322. {
  21323. return Ok(JsonView(false, "查询失败"));
  21324. }
  21325. }
  21326. /// <summary>
  21327. /// 匹配op行程单
  21328. /// 行程单下载
  21329. /// </summary>
  21330. /// <param name="dto">团组列表请求dto</param>
  21331. /// <returns></returns>
  21332. [HttpPost]
  21333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21334. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  21335. {
  21336. #region 参数验证
  21337. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21338. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21339. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21340. #region 页面操作权限验证
  21341. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21342. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  21343. #endregion
  21344. #endregion
  21345. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21346. {
  21347. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  21348. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  21349. }
  21350. else
  21351. {
  21352. return Ok(JsonView(false, "下载失败!"));
  21353. }
  21354. }
  21355. #endregion
  21356. #region 国家信息 数据 注释
  21357. //[HttpPost]
  21358. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  21359. //{
  21360. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  21361. // foreach (var item in dto)
  21362. // {
  21363. // infos.Add(new Grp_GroupsTaskAssignment()
  21364. // {
  21365. // DIId = item,
  21366. // CTId = 82,
  21367. // UId = 248,
  21368. // IsEnable = 1,
  21369. // CreateUserId = 233,
  21370. // CreateTime = DateTime.Now,
  21371. // IsDel = 0
  21372. // });
  21373. // infos.Add(new Grp_GroupsTaskAssignment()
  21374. // {
  21375. // DIId = item,
  21376. // CTId = 82,
  21377. // UId = 286,
  21378. // IsEnable = 1,
  21379. // CreateUserId = 233,
  21380. // CreateTime = DateTime.Now,
  21381. // IsDel = 0
  21382. // });
  21383. // }
  21384. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  21385. // return Ok("操作成功");
  21386. //}
  21387. //public class paramJsonDto
  21388. //{
  21389. // public List<CountriesInfo> str { get; set; }
  21390. //}
  21391. //[HttpPost]
  21392. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  21393. //{
  21394. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  21395. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  21396. // List<Sys_Cities> cities = new List<Sys_Cities>();
  21397. // List<Sys_Cities> districts = new List<Sys_Cities>();
  21398. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21399. // _sqlSugar.BeginTran();
  21400. // int countitiesIndex = 0;
  21401. // foreach (var item in dto.str)
  21402. // {
  21403. // dynamic data = item.c;
  21404. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  21405. // if (data != null)
  21406. // {
  21407. // countitiesIndex++;
  21408. // foreach (var item1 in data)
  21409. // {
  21410. // string cnname = item1.cn;
  21411. // string enname = item1.en;
  21412. // Sys_Cities provinceInfo = new Sys_Cities()
  21413. // {
  21414. // CountriesId = countriesId,
  21415. // Name_CN = cnname,
  21416. // Name_EN = enname,
  21417. // ParentId = 0,
  21418. // IsCapital = 1,
  21419. // CreateUserId = 208,
  21420. // CreateTime = DateTime.Now,
  21421. // IsDel = 0
  21422. // };
  21423. // if (item1.lv == "province") //省份
  21424. // {
  21425. // provinceInfo.Level = 1;
  21426. // int provinceId = 0;
  21427. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  21428. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  21429. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21430. // var data1 = item1.c;
  21431. // foreach (var item2 in data1)
  21432. // {
  21433. // if (item2.lv == "city")
  21434. // {
  21435. // string citycnname = item2.cn;
  21436. // string cityenname = item2.en;
  21437. // Sys_Cities cityInfo = new Sys_Cities()
  21438. // {
  21439. // CountriesId = countriesId,
  21440. // ParentId = provinceId,
  21441. // Level = 2,
  21442. // Name_CN = citycnname,
  21443. // Name_EN = cityenname,
  21444. // IsCapital = 1,
  21445. // CreateUserId = 208,
  21446. // CreateTime = DateTime.Now,
  21447. // IsDel = 0
  21448. // };
  21449. // if (item2.c != null)
  21450. // {
  21451. // int cityId = 0;
  21452. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  21453. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21454. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  21455. // foreach (var item3 in item2.c)
  21456. // {
  21457. // if (item3.lv == "district")
  21458. // {
  21459. // var districtInfo = new Sys_Cities()
  21460. // {
  21461. // CountriesId = countriesId,
  21462. // Name_CN = item3.cn,
  21463. // Name_EN = item3.en,
  21464. // Level = 3,
  21465. // ParentId = cityId,
  21466. // IsCapital = 1,
  21467. // CreateUserId = 208,
  21468. // CreateTime = DateTime.Now,
  21469. // IsDel = 0
  21470. // };
  21471. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21472. // //{
  21473. // districts.Add(districtInfo);
  21474. // //}
  21475. // }
  21476. // }
  21477. // }
  21478. // else
  21479. // {
  21480. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  21481. // //{
  21482. // cities.Add(cityInfo);
  21483. // //}
  21484. // }
  21485. // }
  21486. // }
  21487. // }
  21488. // else if (item1.lv == "city")//城市
  21489. // {
  21490. // provinceInfo.Level = 2;
  21491. // if (item1.c != null)
  21492. // {
  21493. // int cityId = 0;
  21494. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  21495. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21496. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21497. // foreach (var item3 in item1.c)
  21498. // {
  21499. // if (item3.lv == "district")
  21500. // {
  21501. // var districtInfo = new Sys_Cities()
  21502. // {
  21503. // CountriesId = countriesId,
  21504. // Name_CN = item3.cn,
  21505. // Name_EN = item3.en,
  21506. // Level = 3,
  21507. // ParentId = cityId,
  21508. // IsCapital = 1,
  21509. // CreateUserId = 208,
  21510. // CreateTime = DateTime.Now,
  21511. // IsDel = 0
  21512. // };
  21513. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21514. // //{
  21515. // districts.Add(districtInfo);
  21516. // //}
  21517. // }
  21518. // }
  21519. // }
  21520. // else
  21521. // {
  21522. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  21523. // //{
  21524. // cities.Add(provinceInfo);
  21525. // //}
  21526. // }
  21527. // }
  21528. // }
  21529. // }
  21530. // }
  21531. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  21532. // cities = cities.Distinct().ToList();
  21533. // districts = districts.Distinct().ToList();
  21534. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  21535. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  21536. // cities.AddRange(districts);
  21537. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  21538. // //_sqlSugar.RollbackTran();
  21539. // _sqlSugar.CommitTran();
  21540. // return Ok(JsonView(false, "操作成功!"));
  21541. //}
  21542. //[HttpPost]
  21543. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  21544. //{
  21545. // List<CountitiesInfo> infos = dto.MyProperty;
  21546. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  21547. // _sqlSugar.BeginTran();
  21548. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21549. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  21550. // foreach (var item in infos)
  21551. // {
  21552. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  21553. // if (countryInfo != null)
  21554. // {
  21555. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  21556. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  21557. // if (cityInfo1 != null)
  21558. // {
  21559. // cityInfo1.IsCapital = 0;
  21560. // cityInfos.Add(cityInfo1);
  21561. // }
  21562. // }
  21563. // }
  21564. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  21565. // .UpdateColumns(it => it.IsCapital)
  21566. // .WhereColumns(it => it.Id)
  21567. // .ExecuteCommand();
  21568. // //_sqlSugar.RollbackTran();
  21569. // _sqlSugar.CommitTran();
  21570. // return Ok(JsonView(false, "操作成功!"));
  21571. //}
  21572. //public class CounrtiesDto
  21573. //{
  21574. // public List<CountitiesInfo> MyProperty { get; set; }
  21575. //}
  21576. //public class CountitiesInfo
  21577. //{
  21578. // /// <summary>
  21579. // /// 圣约翰
  21580. // /// </summary>
  21581. // public string capital_name_chinese { get; set; }
  21582. // /// <summary>
  21583. // ///
  21584. // /// </summary>
  21585. // public string capital_name { get; set; }
  21586. // /// <summary>
  21587. // ///
  21588. // /// </summary>
  21589. // public string country_type { get; set; }
  21590. // /// <summary>
  21591. // /// 安提瓜和巴布达
  21592. // /// </summary>
  21593. // public string country_name_chinese { get; set; }
  21594. // /// <summary>
  21595. // /// 安提瓜和巴布达
  21596. // /// </summary>
  21597. // public string country_name_chinese_short { get; set; }
  21598. // /// <summary>
  21599. // /// 安提瓜和巴布达
  21600. // /// </summary>
  21601. // public string country_name_chinese_UN { get; set; }
  21602. // /// <summary>
  21603. // ///
  21604. // /// </summary>
  21605. // public string country_name_english_abbreviation { get; set; }
  21606. // /// <summary>
  21607. // ///
  21608. // /// </summary>
  21609. // public string country_name_english_formal { get; set; }
  21610. // /// <summary>
  21611. // ///
  21612. // /// </summary>
  21613. // public string country_name_english_UN { get; set; }
  21614. // /// <summary>
  21615. // ///
  21616. // /// </summary>
  21617. // public string continent_name { get; set; }
  21618. // /// <summary>
  21619. // ///
  21620. // /// </summary>
  21621. // public string subregion_name { get; set; }
  21622. // /// <summary>
  21623. // ///
  21624. // /// </summary>
  21625. // public string country_code2 { get; set; }
  21626. // /// <summary>
  21627. // ///
  21628. // /// </summary>
  21629. // public string country_code3 { get; set; }
  21630. // /// <summary>
  21631. // ///
  21632. // /// </summary>
  21633. // public string phone_code { get; set; }
  21634. //}
  21635. //public class CountriesInfo : BasicInfo
  21636. //{
  21637. // public List<CitiesInfo> c { get; set; }
  21638. //}
  21639. //public class CitiesInfo : BasicInfo
  21640. //{
  21641. // public List<AreaInfo> c { get; set; }
  21642. //}
  21643. //public class AreaInfo : BasicInfo
  21644. //{
  21645. // public List<AreaInfo> c { get; set; }
  21646. //}
  21647. //public class BasicInfo
  21648. //{
  21649. // public string code { get; set; }
  21650. // public string cn { get; set; }
  21651. // public string lv { get; set; }
  21652. // public string en { get; set; }
  21653. //}
  21654. #endregion
  21655. #region 查看邀请方
  21656. /// <summary>
  21657. /// 查看邀请方
  21658. /// 邀请方信息 Init
  21659. /// </summary>
  21660. /// <param name="dto"></param>
  21661. /// <returns></returns>
  21662. [HttpPost]
  21663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21664. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  21665. {
  21666. string sqlWhere = string.Empty;
  21667. if (!string.IsNullOrEmpty(dto.Search))
  21668. {
  21669. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  21670. }
  21671. string sql = string.Format($@"Select
  21672. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  21673. Id,
  21674. UnitName
  21675. From Res_InvitationOfficialActivityData
  21676. Where IsDel = 0
  21677. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  21678. RefAsync<int> total = 0;
  21679. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21680. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  21681. }
  21682. /// <summary>
  21683. /// 查看邀请方
  21684. /// 国家信息 Init
  21685. /// </summary>
  21686. /// <param name="dto"></param>
  21687. /// <returns></returns>
  21688. [HttpPost]
  21689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21690. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  21691. {
  21692. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  21693. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21694. var diids = groupInfos.Select(it => it.Id).ToList();
  21695. List<string> countrys = new List<string>();
  21696. foreach (var item in country)
  21697. {
  21698. var data = _groupRepository.FormartTeamName(item);
  21699. var dataArray = _groupRepository.GroupSplitCountry(data);
  21700. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21701. }
  21702. countrys = countrys.Distinct().ToList();
  21703. for (int i = 0; i < countrys.Count; i++)
  21704. {
  21705. string item = countrys[i];
  21706. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  21707. {
  21708. countrys.Remove(item);
  21709. i--;
  21710. }
  21711. }
  21712. RefAsync<int> total = 0;
  21713. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  21714. .Where(it => countrys.Contains(it.Name_CN))
  21715. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21716. .Select(it => new { id = it.Id, name = it.Name_CN })
  21717. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21718. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21719. }
  21720. /// <summary>
  21721. /// 查看邀请方
  21722. /// 城市信息 Init
  21723. /// </summary>
  21724. /// <param name="dto"></param>
  21725. /// <returns></returns>
  21726. [HttpPost]
  21727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21728. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  21729. {
  21730. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  21731. RefAsync<int> total = 0;
  21732. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  21733. .Where(it => it.CountriesId == dto.CountiesId)
  21734. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21735. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  21736. .Select(it => new { id = it.Id, name = it.Name_CN })
  21737. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21738. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21739. }
  21740. /// <summary>
  21741. /// 查看邀请方
  21742. /// 团组名称 Init
  21743. /// </summary>
  21744. /// <param name="dto"></param>
  21745. /// <returns></returns>
  21746. [HttpPost]
  21747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21748. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  21749. {
  21750. var watch = new Stopwatch();
  21751. watch.Start();
  21752. RefAsync<int> total = 0;
  21753. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  21754. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  21755. .Where((oa, di) => oa.IsDel == 0)
  21756. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  21757. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  21758. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  21759. .Distinct()
  21760. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21761. watch.Stop();
  21762. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  21763. }
  21764. /// <summary>
  21765. /// 查看邀请方
  21766. /// 团组 & 邀请方信息
  21767. /// </summary>
  21768. /// <param name="dto"></param>
  21769. /// <returns></returns>
  21770. [HttpPost]
  21771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21772. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  21773. {
  21774. var watch = new Stopwatch();
  21775. watch.Start();
  21776. RefAsync<int> total = 0;
  21777. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  21778. .AS("Grp_DelegationInfo")
  21779. .Includes(x => x.InvitingInfos)
  21780. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  21781. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  21782. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  21783. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  21784. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  21785. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  21786. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21787. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  21788. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  21789. infos.ForEach(x =>
  21790. {
  21791. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  21792. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  21793. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  21794. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  21795. });
  21796. watch.Stop();
  21797. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  21798. }
  21799. #endregion
  21800. #region 报批行程
  21801. /// <summary>
  21802. /// 报批行程初始化
  21803. /// </summary>
  21804. /// <param name="dto"></param>
  21805. /// <returns></returns>
  21806. [HttpPost]
  21807. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  21808. {
  21809. const int chiNumber = 5;
  21810. var jw = JsonView(false);
  21811. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  21812. var group = groupList.First();
  21813. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  21814. group = groupList.First(x => x.Id == diid);
  21815. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21816. .Where(x => x.DiId == diid && x.IsDel == 0)
  21817. .ToArray();
  21818. var count = 1;
  21819. foreach (var item in blackCodeList)
  21820. {
  21821. if (string.IsNullOrWhiteSpace(item.Title))
  21822. {
  21823. item.Title = "未设置名称数据" + count;
  21824. }
  21825. count++;
  21826. }
  21827. ;
  21828. if (group == null)
  21829. {
  21830. jw.Msg = "暂无团组!";
  21831. return Ok(jw);
  21832. }
  21833. var data = new
  21834. {
  21835. groupList = groupList.Select(x => new
  21836. {
  21837. x.TeamName,
  21838. x.Id
  21839. }),
  21840. content = new ArrayList(),
  21841. groupInfo = new
  21842. {
  21843. group.VisitDays,
  21844. group.TourCode,
  21845. group.VisitPNumber,
  21846. group.TeamName,
  21847. group.Id,
  21848. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21849. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21850. group.ClientUnit
  21851. },
  21852. blackCodeList = blackCodeList.Select(x => new
  21853. {
  21854. x.Title,
  21855. x.Id
  21856. }),
  21857. FileTempList = new ArrayList()
  21858. {
  21859. new { Index = 1,FileName = "旧模板" },
  21860. new { Index = 2,FileName = "省外办" },
  21861. new { Index = 3,FileName = "市外办" },
  21862. }
  21863. };
  21864. var resultArr = new ArrayList();
  21865. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21866. #region 默认不生成行程
  21867. //if (content.Count == 0)
  21868. //{
  21869. // var stay = "-";
  21870. // var cityPath = "-";
  21871. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21872. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21873. // .ToList();
  21874. // //添加城市路径以及住宿地
  21875. // //黑屏代码数据
  21876. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21877. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21878. // {
  21879. // jw = JsonView(true, "黑屏代码有误!", data);
  21880. // return Ok(jw);
  21881. // }
  21882. // data = data with
  21883. // {
  21884. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21885. // {
  21886. // x.Title,
  21887. // x.Id,
  21888. // }).ToArray())
  21889. // };
  21890. // foreach (DataRow row in dtBlack.Rows)
  21891. // {
  21892. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21893. // {
  21894. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21895. // return Ok(jw);
  21896. // }
  21897. // }
  21898. // //黑屏代码获取时间区间
  21899. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21900. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21901. // _sqlSugar.BeginTran();
  21902. // for (int i = 0; i < timeArr.Count; i++)
  21903. // {
  21904. // stay = "-";
  21905. // cityPath = "-";
  21906. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21907. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21908. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21909. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21910. // if (tbSelect.Length > 0)
  21911. // {
  21912. // List<string> threeCodeStr = new List<string>();
  21913. // foreach (var item in tbSelect)
  21914. // {
  21915. // var threeCode = item["Three"].ToString() ?? "";
  21916. // if (threeCode.Length == 6)
  21917. // {
  21918. // var start = threeCode.Substring(0, 3);
  21919. // var end = threeCode.Substring(3, 3);
  21920. // if (threeCodeStr.Count == 0)
  21921. // {
  21922. // threeCodeStr.Add(start);
  21923. // threeCodeStr.Add(end);
  21924. // }
  21925. // else
  21926. // {
  21927. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21928. // {
  21929. // threeCodeStr.Add(end);
  21930. // }
  21931. // else
  21932. // {
  21933. // threeCodeStr.Add(start);
  21934. // threeCodeStr.Add(end);
  21935. // }
  21936. // }
  21937. // }
  21938. // }
  21939. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21940. // var last = threeCodeStr.Last();
  21941. // foreach (var item in threeCodeStr)
  21942. // {
  21943. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21944. // if (item.Equals(last))
  21945. // {
  21946. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21947. // }
  21948. // }
  21949. // cityPath = cityPath.Trim('-');
  21950. // }
  21951. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21952. // appro.Diid = diid ?? -1;
  21953. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21954. // appro.Id = thisId;
  21955. // appro.CreateUserId = dto.UserId;
  21956. // appro.CreateTime = DateTime.Now;
  21957. // content.Add(appro);
  21958. // }
  21959. // _sqlSugar.CommitTran();
  21960. //}
  21961. #endregion
  21962. foreach (var x in content)
  21963. {
  21964. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21965. if (chiList.Count < chiNumber)
  21966. {
  21967. for (int i = chiList.Count; i < chiNumber; i++)
  21968. {
  21969. chiList.Add(new Grp_ApprovalTravelDetails());
  21970. }
  21971. }
  21972. resultArr.Add(new
  21973. {
  21974. x.Id,
  21975. x.Date,
  21976. x.Diid,
  21977. chiList = chiList.Select(x1 => new
  21978. {
  21979. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21980. x1.Details,
  21981. x1.ParentId,
  21982. x1.Id
  21983. })
  21984. });
  21985. }
  21986. data = data with
  21987. {
  21988. content = resultArr,
  21989. };
  21990. jw = JsonView(true, "获取成功!", data);
  21991. return Ok(jw);
  21992. }
  21993. /// <summary>
  21994. /// 报批行程删除
  21995. /// </summary>
  21996. /// <param name="dto"></param>
  21997. /// <returns></returns>
  21998. [HttpPost]
  21999. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  22000. {
  22001. var jw = JsonView(false);
  22002. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22003. if (group == null)
  22004. {
  22005. jw.Msg = "团组参数有误!";
  22006. return Ok(jw);
  22007. }
  22008. try
  22009. {
  22010. _sqlSugar.BeginTran();
  22011. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  22012. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  22013. {
  22014. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22015. DeleteUserId = dto.uesrId,
  22016. IsDel = 1
  22017. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  22018. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  22019. {
  22020. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22021. DeleteUserId = dto.uesrId,
  22022. IsDel = 1
  22023. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  22024. _sqlSugar.CommitTran();
  22025. jw = JsonView(true, "删除成功");
  22026. }
  22027. catch (Exception ex)
  22028. {
  22029. jw = JsonView(false, ex.Message);
  22030. }
  22031. return Ok(jw);
  22032. }
  22033. /// <summary>
  22034. /// 报批行程保存
  22035. /// </summary>
  22036. /// <param name="dto"></param>
  22037. /// <returns></returns>
  22038. [HttpPost]
  22039. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  22040. {
  22041. var jw = JsonView(false);
  22042. var Find = dto.Arr.Find(x => x.id == 0);
  22043. if (Find != null)
  22044. {
  22045. jw.Msg = "生成的ID为0!";
  22046. return Ok(jw);
  22047. }
  22048. foreach (var item in dto.Arr)
  22049. {
  22050. foreach (var chi in item.chiList)
  22051. {
  22052. if (chi.parentId == 0)
  22053. {
  22054. chi.parentId = item.id;
  22055. }
  22056. }
  22057. }
  22058. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  22059. _sqlSugar.BeginTran();
  22060. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  22061. {
  22062. var parentIds = dto.Arr.Select(x => x.id).ToList();
  22063. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  22064. {
  22065. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22066. DeleteUserId = dto.UserId,
  22067. IsDel = 1
  22068. }).ExecuteCommand();
  22069. }
  22070. try
  22071. {
  22072. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  22073. {
  22074. CreateTime = DateTime.Now,
  22075. CreateUserId = dto.UserId,
  22076. Details = x.details,
  22077. ParentId = x.parentId,
  22078. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22079. Remark = "",
  22080. IsDel = 0
  22081. }).ToList()).ExecuteCommand();
  22082. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  22083. {
  22084. Id = x.id,
  22085. Details = x.details,
  22086. ParentId = x.parentId,
  22087. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22088. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  22089. {
  22090. Details = x.Details,
  22091. ParentId = x.ParentId,
  22092. Time = x.Time
  22093. }).ExecuteCommand();
  22094. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  22095. {
  22096. Id = x.id,
  22097. Date = x.date,
  22098. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  22099. {
  22100. Date = x.Date
  22101. }).ExecuteCommand();
  22102. _sqlSugar.CommitTran();
  22103. jw = JsonView(true, "保存成功!");
  22104. }
  22105. catch (Exception ex)
  22106. {
  22107. _sqlSugar.RollbackTran();
  22108. jw = JsonView(false, "保存失败!" + ex.Message);
  22109. }
  22110. return Ok(jw);
  22111. }
  22112. /// <summary>
  22113. /// 报批行程生成
  22114. /// </summary>
  22115. /// <param name="dto"></param>
  22116. /// <returns></returns>
  22117. [HttpPost]
  22118. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  22119. {
  22120. var jw = JsonView(false);
  22121. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22122. if (group == null)
  22123. {
  22124. jw.Msg = "暂无该团组!";
  22125. return Ok(jw);
  22126. }
  22127. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  22128. //黑屏代码数据
  22129. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  22130. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22131. {
  22132. jw.Msg = "黑屏代码有误!";
  22133. return Ok(jw);
  22134. }
  22135. foreach (DataRow row in dtBlack.Rows)
  22136. {
  22137. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22138. {
  22139. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  22140. return Ok(jw);
  22141. }
  22142. }
  22143. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  22144. var resultArr = new ArrayList();
  22145. //if (officialActivitiesArr.Count == 0)
  22146. //{
  22147. // jw.Msg = "暂无公务出访信息!";
  22148. // return Ok(jw);
  22149. //}
  22150. try
  22151. {
  22152. _sqlSugar.BeginTran();
  22153. DeleteApprovalJourney(new
  22154. Domain.Dtos.Groups.DeleteApprovalJourney
  22155. {
  22156. Diid = dto.Diid,
  22157. uesrId = dto.Userid
  22158. });
  22159. var stay = "-";
  22160. var cityPath = "-";
  22161. var arriveCountry = string.Empty;
  22162. //添加城市路径以及住宿地
  22163. //黑屏代码获取时间区间
  22164. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22165. var empty = "【未收入该三字码!请机票同事录入】";
  22166. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22167. #region 配置公务活动时间
  22168. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  22169. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  22170. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  22171. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  22172. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  22173. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22174. {
  22175. 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" }),
  22176. 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"}),
  22177. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22178. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  22179. };
  22180. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22181. {
  22182. 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" }),
  22183. 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"}),
  22184. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22185. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  22186. };
  22187. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  22188. {
  22189. 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" }),
  22190. 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"}),
  22191. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  22192. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  22193. };
  22194. #endregion
  22195. var nextDayNum = 0;
  22196. for (int i = 0; i < timeArr.Count; i++)
  22197. {
  22198. stay = "-";
  22199. cityPath = "-";
  22200. var chiarr = new List<Grp_ApprovalTravelDetails>();
  22201. DateTime NewData = DateTime.Parse(timeArr[i]);
  22202. //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();
  22203. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22204. if (nextDayNum > 0)
  22205. {
  22206. nextDayNum--;
  22207. }
  22208. if (tbSelect.Length > 0)
  22209. {
  22210. List<string> threeCodeStr = new List<string>();
  22211. bool isTrade = false;
  22212. string trip = string.Empty;
  22213. foreach (var item in tbSelect)
  22214. {
  22215. if (nextDayNum == 0)
  22216. {
  22217. nextDayNum = Convert.ToInt32(item["Sign"]);
  22218. }
  22219. var airStartTime = item["StartTime"].ToString() ?? "0000";
  22220. var airEndTime = item["EndTime"].ToString() ?? "0000";
  22221. var takeOffTime = DateTime.Parse(timeArr[i]);
  22222. var fallToTime = DateTime.Parse(timeArr[i]);
  22223. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  22224. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  22225. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  22226. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  22227. if (nextDayNum > 0)
  22228. {
  22229. fallToTime = fallToTime.AddDays(nextDayNum);
  22230. }
  22231. trip = string.Empty;
  22232. var start = string.Empty;
  22233. var end = string.Empty;
  22234. var threeCode = item["Three"].ToString() ?? "";
  22235. if (threeCode.Length == 6)
  22236. {
  22237. start = threeCode.Substring(0, 3);
  22238. end = threeCode.Substring(3, 3);
  22239. if (threeCodeStr.Count == 0)
  22240. {
  22241. threeCodeStr.Add(start);
  22242. threeCodeStr.Add(end);
  22243. }
  22244. else
  22245. {
  22246. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22247. {
  22248. threeCodeStr.Add(end);
  22249. }
  22250. else
  22251. {
  22252. threeCodeStr.Add(start);
  22253. threeCodeStr.Add(end);
  22254. }
  22255. }
  22256. }
  22257. //处理机票信息
  22258. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  22259. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  22260. if (start_Object == null)
  22261. {
  22262. start_Object = new Res_ThreeCode()
  22263. {
  22264. AirPort = empty,
  22265. AirPort_En = empty,
  22266. City = empty,
  22267. Country = empty,
  22268. Four = empty,
  22269. Three = empty,
  22270. };
  22271. }
  22272. if (end_Object == null)
  22273. {
  22274. end_Object = new Res_ThreeCode()
  22275. {
  22276. AirPort = empty,
  22277. AirPort_En = empty,
  22278. City = empty,
  22279. Country = empty,
  22280. Four = empty,
  22281. Three = empty,
  22282. };
  22283. }
  22284. //机型判断
  22285. string airModel = item["AirModel"].ToString();
  22286. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  22287. string flightTime = item["FlightTime"].ToString();
  22288. flightTime = ParseBlackTime(flightTime);
  22289. //航班号
  22290. string flightcode = item["Fliagtcode"].ToString();
  22291. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  22292. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  22293. if (aircompany == null)
  22294. {
  22295. aircompany = new Res_AirCompany
  22296. {
  22297. CnName = hsEmpty,
  22298. EnName = hsEmpty,
  22299. ShortCode = hsEmpty,
  22300. };
  22301. }
  22302. //航班前公务安排
  22303. if (tbSelect.First().Equals(item) && i != 0)
  22304. {
  22305. foreach (var takeoff in takeoffTimes)
  22306. {
  22307. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  22308. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  22309. {
  22310. foreach (var addTime in takeoff.Item2)
  22311. {
  22312. chiarr.Add(new Grp_ApprovalTravelDetails
  22313. {
  22314. Time = addTime,
  22315. CreateTime = DateTime.Now,
  22316. CreateUserId = dto.Userid,
  22317. ParentId = 0,
  22318. Details = "公务活动"
  22319. });
  22320. }
  22321. break;
  22322. }
  22323. }
  22324. }
  22325. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  22326. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  22327. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  22328. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  22329. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  22330. if (isTrade)
  22331. {
  22332. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  22333. trip += "(转机不出机场)。";
  22334. }
  22335. //else
  22336. //{
  22337. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  22338. //}
  22339. chiarr.Add(new Grp_ApprovalTravelDetails
  22340. {
  22341. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  22342. CreateTime = DateTime.Now,
  22343. CreateUserId = dto.Userid,
  22344. ParentId = 0,
  22345. Details = trip
  22346. });
  22347. //最后一条到达的时间安排公务
  22348. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  22349. {
  22350. bool isCheckCountry = false;
  22351. if (end_Object.Country != arriveCountry)
  22352. {
  22353. arriveCountry = end_Object.Country;
  22354. isCheckCountry = true;
  22355. }
  22356. if (nextDayNum == 0)
  22357. {
  22358. //需要入境的情况
  22359. if (isCheckCountry)
  22360. {
  22361. foreach (var fallTime in fallTimesCheckCountry)
  22362. {
  22363. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22364. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22365. {
  22366. foreach (var addTime in fallTime.Item2)
  22367. {
  22368. chiarr.Add(new Grp_ApprovalTravelDetails
  22369. {
  22370. Time = addTime,
  22371. CreateTime = DateTime.Now,
  22372. CreateUserId = dto.Userid,
  22373. ParentId = 0,
  22374. Details = "公务活动"
  22375. });
  22376. }
  22377. break;
  22378. }
  22379. }
  22380. }
  22381. else
  22382. {
  22383. foreach (var fallTime in fallTimesNotCheckCountry)
  22384. {
  22385. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22386. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22387. {
  22388. foreach (var addTime in fallTime.Item2)
  22389. {
  22390. chiarr.Add(new Grp_ApprovalTravelDetails
  22391. {
  22392. Time = addTime,
  22393. CreateTime = DateTime.Now,
  22394. CreateUserId = dto.Userid,
  22395. ParentId = 0,
  22396. Details = "公务活动"
  22397. });
  22398. }
  22399. break;
  22400. }
  22401. }
  22402. }
  22403. }
  22404. }
  22405. }
  22406. //添加乘车语句
  22407. //chiarr.Add(new Grp_ApprovalTravelDetails
  22408. //{
  22409. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  22410. // CreateTime = DateTime.Now,
  22411. // CreateUserId = dto.Userid,
  22412. // ParentId = 0,
  22413. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  22414. //});
  22415. //if (i != timeArr.Count - 1)
  22416. //{
  22417. // fallToTime = fallToTime.AddHours(2.5);
  22418. // foreach (var item in Times)
  22419. // {
  22420. // //排列公务时间
  22421. // if (fallToTime.Hour < item.Item1)
  22422. // {
  22423. // chiarr.Add(new Grp_ApprovalTravelDetails
  22424. // {
  22425. // Time = $"{item.Item2} - {item.Item3}",
  22426. // CreateTime = DateTime.Now,
  22427. // CreateUserId = dto.Userid,
  22428. // ParentId = 0,
  22429. // Details = "公务活动"
  22430. // });
  22431. // }
  22432. // }
  22433. //}
  22434. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22435. var last = threeCodeStr.Last();
  22436. foreach (var item in threeCodeStr)
  22437. {
  22438. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22439. if (item.Equals(last))
  22440. {
  22441. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22442. }
  22443. }
  22444. cityPath = cityPath.Trim('-');
  22445. }
  22446. else
  22447. {
  22448. foreach (var item in Times)
  22449. {
  22450. chiarr.Add(new Grp_ApprovalTravelDetails
  22451. {
  22452. Time = $"{item.Item2} - {item.Item3}",
  22453. CreateTime = DateTime.Now,
  22454. CreateUserId = dto.Userid,
  22455. ParentId = 0,
  22456. Details = "公务活动"
  22457. });
  22458. }
  22459. }
  22460. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22461. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22462. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  22463. appro.Diid = dto.Diid;
  22464. appro.CreateUserId = dto.Userid;
  22465. appro.CreateTime = DateTime.Now;
  22466. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22467. appro.Id = thisId;
  22468. //foreach (var item in gwinfo)
  22469. //{
  22470. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  22471. // chi.Details = "拜访" + item.Client;
  22472. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  22473. // {
  22474. // chi.Details += "," + item.ReqSample;
  22475. // }
  22476. // chi.ParentId = thisId;
  22477. // chi.Time = item.Time;
  22478. // chiarr.Add(chi);
  22479. //}
  22480. if (chiarr.Count < 6)
  22481. {
  22482. for (int j = chiarr.Count; j < 6; j++)
  22483. {
  22484. chiarr.Add(new
  22485. Grp_ApprovalTravelDetails());
  22486. }
  22487. }
  22488. resultArr.Add(new
  22489. {
  22490. appro.Id,
  22491. appro.Date,
  22492. appro.Diid,
  22493. chiList = chiarr.Select(x1 => new
  22494. {
  22495. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22496. x1.Details,
  22497. x1.ParentId,
  22498. x1.Id
  22499. })
  22500. });
  22501. }
  22502. _sqlSugar.CommitTran();
  22503. jw = JsonView(true, "生成成功!", resultArr);
  22504. }
  22505. catch (Exception ex)
  22506. {
  22507. jw.Code = 400;
  22508. jw.Msg = "生成失败!" + ex.Message;
  22509. }
  22510. return Ok(jw);
  22511. }
  22512. /// <summary>
  22513. /// 报批行程word导出
  22514. /// </summary>
  22515. /// <param name="dto"></param>
  22516. /// <returns></returns>
  22517. [HttpPost]
  22518. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  22519. {
  22520. var jw = JsonView(false);
  22521. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22522. if (group == null)
  22523. {
  22524. jw.Msg = "暂无该团组!";
  22525. return Ok(jw);
  22526. }
  22527. //模板路径
  22528. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  22529. var fileName = string.Empty;
  22530. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  22531. bool bold = false;
  22532. if (dto.FileIndex == 1)
  22533. {
  22534. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  22535. }
  22536. else if (dto.FileIndex == 2)
  22537. {
  22538. fileName = "省外办-报批.docx";
  22539. bold = false;
  22540. titleFont = "方正黑体简体";
  22541. timeFont = "Times New Roman";
  22542. contentFont = "方正仿宋_GBK";
  22543. }
  22544. else if (dto.FileIndex == 3)
  22545. {
  22546. fileName = "市外办-报批.docx";
  22547. titleFont = "方正黑体简体";
  22548. timeFont = "Times New Roman";
  22549. contentFont = "方正仿宋简体";
  22550. }
  22551. tempPath = tempPath + fileName;
  22552. //载入模板
  22553. Document doc = new Document(tempPath);
  22554. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  22555. //获取所填表格的序数
  22556. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  22557. Aspose.Words.Tables.Row titleRowClone = null;
  22558. Aspose.Words.Tables.Row CenterRowClone = null;
  22559. int index = 0;
  22560. int indexChi = 0;
  22561. int SetIndex = 0;
  22562. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  22563. //获取数据,放到datatable
  22564. foreach (var item in ApprovalTravelArr)
  22565. {
  22566. if (index > 0)
  22567. {
  22568. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  22569. tableOne.AppendChild(titleRowClone);
  22570. }
  22571. var textTime = item.Date;
  22572. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  22573. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  22574. SetIndex++;
  22575. if (ChiRep.Count > 0)
  22576. {
  22577. foreach (var itemChi in ChiRep)
  22578. {
  22579. var txtTime = itemChi.Time;
  22580. var txtDetail = itemChi.Details;
  22581. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  22582. {
  22583. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  22584. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22585. //indexChi++;
  22586. //SetIndex++;
  22587. break;
  22588. }
  22589. if (indexChi > 0)
  22590. {
  22591. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22592. tableOne.AppendChild(CenterRowClone);
  22593. }
  22594. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  22595. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  22596. indexChi++;
  22597. SetIndex++;
  22598. }
  22599. }
  22600. //else
  22601. //{
  22602. // if (indexChi > 0)
  22603. // {
  22604. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22605. // tableOne.AppendChild(CenterRowClone);
  22606. // }
  22607. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  22608. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22609. // indexChi++;
  22610. // SetIndex++;
  22611. //}
  22612. index++;
  22613. }
  22614. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  22615. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22616. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22617. jw.Code = 200;
  22618. jw.Msg = "";
  22619. return Ok(jw);
  22620. }
  22621. private string ParseBlackTime(string time)
  22622. {
  22623. // 匹配可能只有分钟的情况
  22624. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  22625. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  22626. if (match.Success)
  22627. {
  22628. string hours = match.Groups[1].Value;
  22629. string minutes = match.Groups[2].Value;
  22630. // 如果小时部分为空,则只显示分钟
  22631. if (string.IsNullOrEmpty(hours))
  22632. {
  22633. return $"{minutes}分钟";
  22634. }
  22635. // 如果分钟部分为空,则只显示小时
  22636. else if (string.IsNullOrEmpty(minutes))
  22637. {
  22638. return $"{hours}小时";
  22639. }
  22640. // 否则显示完整格式
  22641. else
  22642. {
  22643. return $"{hours}小时{minutes}分钟";
  22644. }
  22645. }
  22646. else
  22647. {
  22648. return "未知时长";
  22649. }
  22650. }
  22651. private string intToString(int numberVal)
  22652. {
  22653. string numberval = numberVal.ToString();
  22654. Dictionary<char, string> Number = new Dictionary<char, string>();
  22655. Number.Add('1', "一");
  22656. Number.Add('2', "二");
  22657. Number.Add('3', "三");
  22658. Number.Add('4', "四");
  22659. Number.Add('5', "五");
  22660. Number.Add('6', "六");
  22661. Number.Add('7', "七");
  22662. Number.Add('8', "八");
  22663. Number.Add('9', "九");
  22664. string stringNumberVal = string.Empty;
  22665. for (int i = 0; i < numberval.Length; i++)
  22666. {
  22667. if (i == 0)
  22668. {
  22669. stringNumberVal += Number[numberval[i]];
  22670. }
  22671. else if (i >= 1)
  22672. {
  22673. if (numberval[i] == '0')
  22674. {
  22675. stringNumberVal = "十";
  22676. }
  22677. else
  22678. {
  22679. stringNumberVal += "十" + Number[numberval[i]];
  22680. }
  22681. }
  22682. }
  22683. return stringNumberVal;
  22684. }
  22685. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  22686. {
  22687. //获取table中的某个单元格,从0开始
  22688. Cell lshCell = table.Rows[rows].Cells[cells];
  22689. //将单元格中段落移除
  22690. foreach (Paragraph item in lshCell.Paragraphs)
  22691. {
  22692. lshCell.Paragraphs.Remove(item);
  22693. }
  22694. if (val.Contains("\r\n"))
  22695. {
  22696. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  22697. foreach (var item in spArr)
  22698. {
  22699. //新建一个段落
  22700. Paragraph p = new Paragraph(doc);
  22701. var r = new Run(doc, item);
  22702. //设置字体
  22703. if (!string.IsNullOrEmpty(font))
  22704. {
  22705. r.Font.Name = font;
  22706. }
  22707. r.Font.Bold = bold;
  22708. //把设置的值赋给之前新建的段落
  22709. p.AppendChild(r);
  22710. //将此段落加到单元格内
  22711. lshCell.AppendChild(p);
  22712. }
  22713. }
  22714. else
  22715. {
  22716. //新建一个段落
  22717. Paragraph p = new Paragraph(doc);
  22718. var r = new Run(doc, val);
  22719. //设置字体
  22720. if (!string.IsNullOrEmpty(font))
  22721. {
  22722. r.Font.Name = font;
  22723. }
  22724. r.Font.Bold = bold;
  22725. //把设置的值赋给之前新建的段落
  22726. p.AppendChild(r);
  22727. //将此段落加到单元格内
  22728. lshCell.AppendChild(p);
  22729. }
  22730. }
  22731. /// <summary>
  22732. /// 报批行程AI续写
  22733. /// </summary>
  22734. /// <returns></returns>
  22735. [HttpPost]
  22736. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  22737. {
  22738. var jw = JsonView(false);
  22739. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  22740. {
  22741. jw.Msg = "参数有误!";
  22742. return Ok(jw);
  22743. }
  22744. KiMiApiClient kiMi = new KiMiApiClient();
  22745. List<SeedMessages> messages = new List<SeedMessages>() {
  22746. new SeedMessages
  22747. {
  22748. Role = KimiRole.system,
  22749. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  22750. },
  22751. new SeedMessages
  22752. {
  22753. Role = KimiRole.user,
  22754. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  22755. }
  22756. };
  22757. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  22758. string data = kimi_result.Choices[0]?.Message.Content;
  22759. if (string.IsNullOrWhiteSpace(data))
  22760. {
  22761. jw.Data = "Ai续写失败!";
  22762. }
  22763. else
  22764. {
  22765. jw = JsonView(true, "success!", data);
  22766. }
  22767. return Ok(jw);
  22768. }
  22769. #endregion
  22770. #region 团组接待意见调查
  22771. /// <summary>
  22772. /// 团组接待意见调查 - 信息管理
  22773. /// 基础数据(团组)
  22774. /// </summary>
  22775. /// <returns></returns>
  22776. [HttpGet]
  22777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22778. public async Task<IActionResult> OpinionaireInit()
  22779. {
  22780. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  22781. .Select(x => new
  22782. {
  22783. x.Id,
  22784. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  22785. })
  22786. .OrderByDescending(x => x.Id)
  22787. .ToListAsync();
  22788. return Ok(JsonView(groupData, groupData.Count));
  22789. }
  22790. /// <summary>
  22791. /// 团组接待意见调查 - 信息管理
  22792. /// 列表
  22793. /// </summary>
  22794. /// <param name="groupId"></param>
  22795. /// <returns></returns>
  22796. [HttpGet("{groupId}")]
  22797. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22798. public async Task<IActionResult> OpinionaireManageList(int groupId)
  22799. {
  22800. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22801. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  22802. .Select(x => new
  22803. {
  22804. x.Id,
  22805. x.TourGuideName,
  22806. x.CityName,
  22807. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  22808. x.CreateTime
  22809. })
  22810. .OrderBy(x => x.Id)
  22811. .ToListAsync();
  22812. return Ok(JsonView(data));
  22813. }
  22814. /// <summary>
  22815. /// 团组接待意见调查 - 信息管理
  22816. /// 保存
  22817. /// </summary>
  22818. /// <param name="dto"></param>
  22819. /// <returns></returns>
  22820. [HttpPost]
  22821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22822. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  22823. {
  22824. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22825. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22826. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22827. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  22828. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  22829. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  22830. _opinionaireRep.BeginTran();
  22831. if (addData != null && addData.Count > 0)
  22832. {
  22833. foreach (var item in addData)
  22834. {
  22835. item.CreateUserId = currUserInfo.UserId;
  22836. item.DiId = dto.DiId;
  22837. }
  22838. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  22839. }
  22840. if (updData != null && updData.Count > 0)
  22841. {
  22842. var upd = await _opinionaireRep._sqlSugar
  22843. .Updateable(updData)
  22844. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  22845. .WhereColumns(x => new { x.Id })
  22846. .ExecuteCommandAsync();
  22847. }
  22848. _opinionaireRep.CommitTran();
  22849. return Ok(JsonView("操作成功!"));
  22850. }
  22851. /// <summary>
  22852. /// 团组接待意见调查 - 信息管理
  22853. /// 删除
  22854. /// </summary>
  22855. /// <param name="id"></param>
  22856. /// <returns></returns>
  22857. [HttpDelete("{id}")]
  22858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22859. public async Task<IActionResult> OpinionaireManageDel(int id)
  22860. {
  22861. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22862. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22863. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22864. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22865. if (!del) return Ok(JsonView("操作失败!"));
  22866. return Ok(JsonView("操作成功!"));
  22867. }
  22868. /// <summary>
  22869. /// 团组接待意见调查 - 用户
  22870. /// 列表
  22871. /// </summary>
  22872. /// <param name="diId"></param>
  22873. /// <returns></returns>
  22874. [HttpGet("{diId}")]
  22875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22876. public async Task<IActionResult> OpinionaireUserList(int diId)
  22877. {
  22878. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22879. var sql = string.Format(@"
  22880. SELECT
  22881. o.Id,
  22882. o.DiId,
  22883. di.TeamName AS 'GroupName',
  22884. di.VisitPNumber AS 'PeopleNumber',
  22885. di.ClientName AS 'LeadGroup',
  22886. di.VisitCountry AS 'Travel',
  22887. di.VisitDays AS 'Days',
  22888. o.CityName,
  22889. o.TourGuideName,
  22890. o.Catering,
  22891. o.CateringReason,
  22892. o.Stay,
  22893. o.StayReason,
  22894. o.[Route],
  22895. o.RouteReason,
  22896. o.OfficialActivity,
  22897. o.OfficialActivityReason,
  22898. o.TourGuide,
  22899. o.TourGuideReason,
  22900. o.[Translate],
  22901. o.TranslateReason,
  22902. o.Trip,
  22903. o.TripReason,
  22904. o.ESFileName,
  22905. o.SignatureDate,
  22906. o.Remark
  22907. FROM
  22908. Grp_Opinionaire o
  22909. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22910. WHERE
  22911. o.IsDel = 0
  22912. AND o.DiId = {0}
  22913. ORDER BY
  22914. o.Id ASC", diId);
  22915. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22916. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22917. return Ok(JsonView(data));
  22918. }
  22919. /// <summary>
  22920. /// 团组接待意见调查 - 用户
  22921. /// 保存
  22922. /// </summary>
  22923. /// <param name="dto"></param>
  22924. /// <returns></returns>
  22925. [HttpPost]
  22926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22927. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22928. {
  22929. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22930. foreach (var item in dto)
  22931. {
  22932. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22933. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22934. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22935. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22936. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22937. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22938. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22939. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22940. }
  22941. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22942. if (!Directory.Exists(filePathBase))
  22943. {
  22944. Directory.CreateDirectory(filePathBase);
  22945. }
  22946. #region 上传文件
  22947. var filePaths = new List<string>();
  22948. foreach (var item in dto)
  22949. {
  22950. var file = item.File;
  22951. // 将文件保存到指定位置
  22952. var filePath = Path.Combine(filePathBase, file.FileName);
  22953. using (var stream = new FileStream(filePath, FileMode.Create))
  22954. {
  22955. await file.CopyToAsync(stream);
  22956. }
  22957. //验证文件是否上传成功
  22958. if (!System.IO.File.Exists(filePath))
  22959. {
  22960. foreach (var filePathStr in filePaths)
  22961. {
  22962. System.IO.File.Delete(filePathStr);
  22963. }
  22964. return Ok(JsonView(false, "文件上传失败!"));
  22965. }
  22966. item.ESFileName = file.FileName;
  22967. }
  22968. #endregion
  22969. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22970. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22971. .UpdateColumns(x => new
  22972. {
  22973. x.Catering,
  22974. x.CateringReason,
  22975. x.Stay,
  22976. x.StayReason,
  22977. x.Route,
  22978. x.RouteReason,
  22979. x.OfficialActivity,
  22980. x.OfficialActivityReason,
  22981. x.TourGuide,
  22982. x.TourGuideReason,
  22983. x.Translate,
  22984. x.TranslateReason,
  22985. x.Trip,
  22986. x.TripReason,
  22987. x.ESFileName,
  22988. x.SignatureDate,
  22989. x.Remark
  22990. })
  22991. .WhereColumns(x => new { x.Id })
  22992. .ExecuteCommandAsync();
  22993. if (upd < 1)
  22994. {
  22995. foreach (var filePathStr in filePaths)
  22996. {
  22997. System.IO.File.Delete(filePathStr);
  22998. }
  22999. return Ok(JsonView(false));
  23000. }
  23001. return Ok(JsonView(true));
  23002. }
  23003. #endregion
  23004. #region 团组餐厅相关信息
  23005. /// <summary>
  23006. /// 团组相关餐厅信息
  23007. /// 基础数据(团组)
  23008. /// </summary>
  23009. /// <returns></returns>
  23010. [HttpGet]
  23011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23012. public async Task<IActionResult> RestaurantInit()
  23013. {
  23014. return Ok(await _restaurantRep.InitAsync());
  23015. }
  23016. /// <summary>
  23017. /// 团组相关餐厅信息
  23018. /// Item
  23019. /// </summary>
  23020. /// <param name="dto"></param>
  23021. /// <returns></returns>
  23022. [HttpPost]
  23023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23024. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  23025. {
  23026. int portType = dto.PortType,
  23027. groupId = dto.GroupId;
  23028. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23029. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23030. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  23031. }
  23032. /// <summary>
  23033. /// 团组相关餐厅信息
  23034. /// List
  23035. /// </summary>
  23036. /// <param name="dto"></param>
  23037. /// <returns></returns>
  23038. [HttpPost]
  23039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23040. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  23041. {
  23042. int portType = dto.PortType,
  23043. groupId = dto.GroupId;
  23044. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23045. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23046. var sql = string.Format(@" SELECT
  23047. ri.Id,
  23048. ri.GroupId,
  23049. ri.Date,
  23050. ri.StartTime,
  23051. ri.EndTime,
  23052. CASE WHEN ri.Type = 1 THEN '早餐'
  23053. WHEN ri.Type = 2 THEN '午餐'
  23054. WHEN ri.Type = 3 THEN '晚餐'
  23055. ELSE '其他'
  23056. END AS 'Type',
  23057. ri.Name,
  23058. ri.Address,
  23059. ri.Tel,
  23060. ri.Remark,
  23061. ri.CreateTime,
  23062. u.CnName AS CreateUserName
  23063. FROM
  23064. Grp_RestaurantInfo ri
  23065. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  23066. WHERE
  23067. ri.IsDel = 0
  23068. AND ri.GroupId = {0}
  23069. ORDER BY
  23070. ri.Date ASC
  23071. ", groupId);
  23072. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  23073. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  23074. return Ok(JsonView(infos));
  23075. }
  23076. /// <summary>
  23077. /// 团组相关餐厅信息
  23078. /// Info
  23079. /// </summary>
  23080. /// <param name="dto"></param>
  23081. /// <returns></returns>
  23082. [HttpPost]
  23083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23084. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  23085. {
  23086. int portType = dto.PortType,
  23087. id = dto.Id;
  23088. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23089. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23090. return Ok(await _restaurantRep.InfoAsync(portType, id));
  23091. }
  23092. /// <summary>
  23093. /// 团组相关餐厅信息
  23094. /// Op
  23095. /// </summary>
  23096. /// <param name="dto"></param>
  23097. /// <returns></returns>
  23098. [HttpPost]
  23099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23100. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  23101. {
  23102. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23103. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23104. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  23105. return Ok(await _restaurantRep.OpAsync(dto));
  23106. }
  23107. /// <summary>
  23108. /// 团组相关餐厅信息
  23109. /// Del
  23110. /// </summary>
  23111. /// <param name="dto"></param>
  23112. /// <returns></returns>
  23113. [HttpPost]
  23114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23115. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  23116. {
  23117. int userId = dto.DeleteUserId;
  23118. var id = dto.Id;
  23119. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23120. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23121. return Ok(await _restaurantRep.DelAsync(dto));
  23122. }
  23123. #endregion
  23124. #region 团组会务成本
  23125. /// <summary>
  23126. /// 团组会务成本数据初始化
  23127. /// </summary>
  23128. /// <returns></returns>
  23129. [HttpPost]
  23130. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  23131. {
  23132. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23133. .OrderByDescending(x => x.CreateTime)
  23134. .Where(x => x.IsDel == 0)
  23135. .Select<DelegationEasyView>();
  23136. DelegationEasyView di = Dto.GroupId == 0 ?
  23137. expr.First() :
  23138. expr.First(x => x.Id == Dto.GroupId);
  23139. if (di == null)
  23140. {
  23141. return Ok(JsonView(false, "团组信息不存在!"));
  23142. }
  23143. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  23144. .Where(x => x.IsDel == 0 && x.STid == 21)
  23145. .Select(x => new { x.Id, Text = x.Name })
  23146. .ToListAsync();
  23147. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  23148. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  23149. .Select(x => x.Id)
  23150. .ToList();
  23151. //仅检索会务团组
  23152. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  23153. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  23154. .OrderByDescending(x => x.VisitDate)
  23155. .Select(x => new { x.Id, x.TeamName })
  23156. .ToListAsync();
  23157. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  23158. var userList = await _sqlSugar.Queryable<Sys_Users>()
  23159. .Where(x => x.IsDel == 0)
  23160. .Select(x => new { x.Id, x.CnName })
  23161. .ToListAsync();
  23162. var units = await _sqlSugar.Queryable<Sys_SetData>()
  23163. .Where(x => x.IsDel == 0 && x.STid == 119)
  23164. .Select(x => new { x.Id, Text = x.Name })
  23165. .ToListAsync();
  23166. var FileType = new[]
  23167. {
  23168. new { Id = 0 , Name = "成本下载" },
  23169. new { Id = 1 , Name = "报价下载" },
  23170. new { Id = 2 , Name = "总表下载" },
  23171. };
  23172. var GM = new List<int>();
  23173. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  23174. try
  23175. {
  23176. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  23177. }
  23178. catch (Exception ex)
  23179. {
  23180. GM = new List<int>() { 21 };
  23181. }
  23182. var isReview = Dto.UserId == 21;
  23183. var isGM = GM.Contains(Dto.UserId);
  23184. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23185. .Where(x => x.IsDel == 0)
  23186. .Select<ConferenceAffairsCostView>()
  23187. .First(x => x.Diid == di.Id);
  23188. if (ConferenceAffairsCost == null)
  23189. {
  23190. ConferenceAffairsCost = new ConferenceAffairsCostView();
  23191. ConferenceAffairsCost.Diid = di.Id;
  23192. }
  23193. #region 权限校验
  23194. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  23195. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  23196. .Select(x => x.UserId)
  23197. .Distinct()
  23198. .ToList();
  23199. if (!ids.Contains(Dto.UserId) && !isGM)
  23200. {
  23201. return Ok(JsonView(201, "暂无权限!", new
  23202. {
  23203. typeData,
  23204. groupList,
  23205. currenyList,
  23206. isGM,
  23207. userList,
  23208. units,
  23209. isReview,
  23210. operatorUser = ids,
  23211. di,
  23212. FileType
  23213. }));
  23214. }
  23215. #endregion
  23216. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  23217. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  23218. .Select<ConferenceAffairsCostChildView>()
  23219. .OrderBy(x => x.Index)
  23220. .ToList();
  23221. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  23222. {
  23223. ConferenceAffairsCostChi[i - 1].Index = i;
  23224. }
  23225. var backData = new
  23226. {
  23227. ConferenceAffairsCost,
  23228. ConferenceAffairsCostChi,
  23229. typeData,
  23230. groupList,
  23231. currenyList,
  23232. isGM,
  23233. userList,
  23234. units,
  23235. isReview,
  23236. operatorUser = ids,
  23237. di,
  23238. FileType
  23239. };
  23240. return Ok(JsonView(true, "SUCCESS", backData));
  23241. }
  23242. /// <summary>
  23243. /// 会务成本保存
  23244. /// </summary>
  23245. /// <returns></returns>
  23246. [HttpPost]
  23247. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  23248. {
  23249. _sqlSugar.BeginTran();
  23250. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  23251. var childResult = new
  23252. {
  23253. success = 0,
  23254. error = 0
  23255. };
  23256. try
  23257. {
  23258. if (data.Id == 0)
  23259. {
  23260. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23261. .Where(x => x.Diid == Dto.GroupId)
  23262. .SetColumns(x => new Grp_ConferenceAffairsCost
  23263. {
  23264. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23265. DeleteUserId = Dto.UserId
  23266. })
  23267. .ExecuteCommand();
  23268. data.Diid = Dto.GroupId;
  23269. data.CreateTime = DateTime.Now;
  23270. data.CreateUserId = Dto.UserId;
  23271. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  23272. .ExecuteReturnIdentity();
  23273. }
  23274. else
  23275. {
  23276. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  23277. .ExecuteCommand();
  23278. data.Id = data.Id;
  23279. }
  23280. if (Dto.ConferenceAffairsCostChild.Any())
  23281. {
  23282. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  23283. var insertArr = datas.Where(x => x.Id == 0).ToList();
  23284. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  23285. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  23286. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  23287. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  23288. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  23289. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  23290. .ExecuteCommand() : 0;
  23291. childResult = childResult with
  23292. {
  23293. error = notUpdateArr.Count(),
  23294. success = inrsetCount + updateCount
  23295. };
  23296. }
  23297. _sqlSugar.CommitTran();
  23298. }
  23299. catch (Exception ex)
  23300. {
  23301. _sqlSugar.RollbackTran();
  23302. return Ok(JsonView(false, "失败!" + ex.Message));
  23303. }
  23304. return Ok(JsonView(true, "操作成功!", childResult));
  23305. }
  23306. [HttpPost]
  23307. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  23308. {
  23309. var count = 0;
  23310. if (Dto.ConferenceAffairsCostChildids.Any())
  23311. {
  23312. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  23313. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  23314. SetColumns(x => new Grp_ConferenceAffairsCostChild
  23315. {
  23316. ReviewStatus = Dto.ReviewStatus
  23317. }).
  23318. ExecuteCommand();
  23319. }
  23320. return Ok(JsonView(true, "操作成功!", count));
  23321. }
  23322. /// <summary>
  23323. /// 会务成本所有数据清除
  23324. /// </summary>
  23325. /// <param name="Dto"></param>
  23326. /// <returns></returns>
  23327. [HttpPost]
  23328. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  23329. {
  23330. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23331. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  23332. _sqlSugar.BeginTran();
  23333. try
  23334. {
  23335. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23336. .Where(x => x.Diid == Dto.GroupId)
  23337. .SetColumns(x => new Grp_ConferenceAffairsCost
  23338. {
  23339. IsDel = 1,
  23340. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23341. DeleteUserId = Dto.UserId
  23342. })
  23343. .ExecuteCommand();
  23344. if (delCount > 0)
  23345. {
  23346. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23347. .Where(x => x.Diid == Dto.GroupId)
  23348. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23349. {
  23350. IsDel = 1,
  23351. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23352. DeleteUserId = Dto.UserId
  23353. })
  23354. .ExecuteCommand();
  23355. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23356. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23357. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23358. {
  23359. IsDel = 1,
  23360. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23361. DeleteUserId = Dto.UserId
  23362. })
  23363. .ExecuteCommand();
  23364. }
  23365. _sqlSugar.CommitTran();
  23366. }
  23367. catch (Exception ex)
  23368. {
  23369. _sqlSugar.RollbackTran();
  23370. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23371. }
  23372. return Ok(JsonView(true, "操作成功!"));
  23373. }
  23374. /// <summary>
  23375. /// 子项数据删除
  23376. /// </summary>
  23377. /// <param name="Dto"></param>
  23378. /// <returns></returns>
  23379. [HttpPost]
  23380. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  23381. {
  23382. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  23383. .Any(x => x.ReviewStatus == 1);
  23384. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  23385. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23386. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  23387. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23388. {
  23389. IsDel = 1,
  23390. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23391. DeleteUserId = Dto.UserId
  23392. })
  23393. .ExecuteCommand();
  23394. return Ok(JsonView(true, "SUCCESS!", count));
  23395. }
  23396. /// <summary>
  23397. /// 会务成本权限分配
  23398. /// </summary>
  23399. /// <param name="Dto"></param>
  23400. /// <returns></returns>
  23401. [HttpPost]
  23402. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  23403. {
  23404. _sqlSugar.BeginTran();
  23405. var count = 0;
  23406. try
  23407. {
  23408. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23409. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23410. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23411. {
  23412. IsDel = 1,
  23413. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23414. DeleteUserId = Dto.CreateUserId
  23415. })
  23416. .ExecuteCommand();
  23417. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  23418. {
  23419. CreateTime = DateTime.Now,
  23420. CreateUserId = Dto.CreateUserId,
  23421. UserId = x,
  23422. Diid = Dto.GroupId,
  23423. }).ToList()).ExecuteCommand();
  23424. _sqlSugar.CommitTran();
  23425. }
  23426. catch (Exception ex)
  23427. {
  23428. _sqlSugar.RollbackTran();
  23429. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23430. }
  23431. return Ok(JsonView(true, "操作成功!", count));
  23432. }
  23433. /// <summary>
  23434. /// 团组会务成本文件下载
  23435. /// </summary>
  23436. /// <returns></returns>
  23437. [HttpPost]
  23438. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  23439. {
  23440. var FileType = new[]
  23441. {
  23442. new { Id = 0 , Name = "成本下载" },
  23443. new { Id = 1 , Name = "报价下载" },
  23444. new { Id = 2 , Name = "总表下载" },
  23445. };
  23446. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23447. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  23448. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23449. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  23450. .Select<DelegationEasyView>()
  23451. .First();
  23452. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23453. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  23454. if (main == null)
  23455. {
  23456. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  23457. }
  23458. JsonView jw = JsonView(false);
  23459. //总表下载
  23460. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  23461. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  23462. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  23463. var field = string.Empty;
  23464. var fileTypeName = string.Empty;
  23465. field = @$"
  23466. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  23467. b.Name as PriceTypeStr ,
  23468. c.Name as CurrencyStr ,
  23469. d.Name as UnitStr ,
  23470. case a.ReviewStatus
  23471. WHEN 1 THEN '已通过'
  23472. WHEN 0 THEN '未审核'
  23473. WHEN -1 THEN '未通过'
  23474. ELSE '未审核'
  23475. END AS ReviewStatusStr
  23476. ";
  23477. if (Dto.FileTypeId == 0)
  23478. {
  23479. fileTypeName = "会务成本成本表";
  23480. loadPath += $"{fileTypeName}.xlsx";
  23481. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23482. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23483. }
  23484. else if (Dto.FileTypeId == 1)
  23485. {
  23486. fileTypeName = "会务成本报价表";
  23487. loadPath += $"{fileTypeName}.xlsx";
  23488. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23489. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23490. }
  23491. else if (Dto.FileTypeId == 2)
  23492. {
  23493. fileTypeName = "会务成本总表";
  23494. loadPath += $"{fileTypeName}.xlsx";
  23495. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23496. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23497. }
  23498. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  23499. SELECT
  23500. {field}
  23501. FROM Grp_ConferenceAffairsCostChild a
  23502. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  23503. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  23504. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  23505. WHERE a.isdel = 0
  23506. AND a.Diid = {main.Diid}
  23507. AND a.ConferenceAffairsCostId = {main.Id}
  23508. ").ToList();
  23509. var currLists = chiExcelContent.Select(x => new CurrList
  23510. {
  23511. CurrName = x.CurrencyStr,
  23512. CurrRate = x.Rate
  23513. })
  23514. .Distinct()
  23515. .ToList();
  23516. var designer = new WorkbookDesigner
  23517. {
  23518. Workbook = new Workbook(loadPath)
  23519. };
  23520. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  23521. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  23522. designer.SetDataSource("TeamName", di.TeamName);
  23523. designer.SetDataSource("City", main.City);
  23524. designer.SetDataSource("AllCost", main.CostAll);
  23525. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  23526. designer.SetDataSource("Curr", MostCurr.Name);
  23527. designer.SetDataSource("Curr1", MostCurr.Name);
  23528. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  23529. dt.TableName = "TB";
  23530. designer.SetDataSource(dt);
  23531. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  23532. dt1.TableName = "currTb";
  23533. designer.SetDataSource(dt1);
  23534. designer.Process();
  23535. designer.Workbook.Save(outputPath);
  23536. jw = JsonView(true, "操作成功!", new
  23537. {
  23538. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  23539. FilePath = networkPath
  23540. });
  23541. return Ok(jw);
  23542. }
  23543. [HttpPost]
  23544. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  23545. {
  23546. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  23547. .Select(x => x.PriceName).ToList()));
  23548. }
  23549. #endregion
  23550. #region 团组签证流程
  23551. #endregion
  23552. /// <summary>
  23553. /// 123132123
  23554. /// </summary>
  23555. /// <param name="_dto"></param>
  23556. /// <returns></returns>
  23557. [HttpPost]
  23558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23559. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  23560. {
  23561. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  23562. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  23563. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  23564. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  23565. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  23566. dicDetail.Add(789, 1034);
  23567. dicDetail.Add(790, 1035);
  23568. dicDetail.Add(791, 1036);
  23569. dicDetail.Add(792, 1037);
  23570. dicDetail.Add(793, 1038);
  23571. dicDetail.Add(794, 1039);
  23572. dicDetail.Add(795, 1040);
  23573. dicDetail.Add(796, 1041);
  23574. dicDetail.Add(797, 1042);
  23575. dicDetail.Add(798, 1043);
  23576. dicDetail.Add(801, 1044);
  23577. dicDetail.Add(802, 1045);
  23578. dicDetail.Add(803, 1046);
  23579. Dictionary<int, int> dic = new Dictionary<int, int>();
  23580. dic.Add(806, 1027);
  23581. dic.Add(807, 1028);
  23582. dic.Add(808, 1029);
  23583. dic.Add(809, 1030);
  23584. dic.Add(810, 1031);
  23585. dic.Add(811, 1032);
  23586. dic.Add(812, 1033);
  23587. foreach (var item in list_visa)
  23588. {
  23589. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  23590. temp.Coefficient = item.coefficient;
  23591. DateTime dtCrt;
  23592. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  23593. if (b1)
  23594. {
  23595. temp.CreateTime = dtCrt;
  23596. }
  23597. else
  23598. {
  23599. temp.CreateTime = DateTime.Now;
  23600. }
  23601. temp.CreateUserId = item.Operators;
  23602. temp.DeleteTime = "";
  23603. temp.DeleteUserId = 0;
  23604. temp.DiId = int.Parse(item.DIID);
  23605. temp.FilePath = item.FilePath;
  23606. temp.IsDel = item.IsDel;
  23607. temp.Price = item.Price;
  23608. temp.PriceCount = 1;
  23609. temp.PriceCurrency = item.Currency;
  23610. int detailId = 0;
  23611. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  23612. {
  23613. detailId = dicDetail[item.PriceTypeDetail];
  23614. }
  23615. temp.PriceDetailType = detailId;
  23616. temp.PriceDt = DateTime.Now;
  23617. temp.PriceName = item.PriceName;
  23618. temp.PriceSum = item.Price;
  23619. int tid = 0;
  23620. if (dic.ContainsKey(item.PriceType))
  23621. {
  23622. tid = dic[item.PriceType];
  23623. }
  23624. temp.PriceType = tid;
  23625. temp.Remark = item.Remark;
  23626. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  23627. }
  23628. return Ok(JsonView(true, "操作成功!"));
  23629. }
  23630. [HttpPost]
  23631. public IActionResult TimeTest()
  23632. {
  23633. var jw = JsonView(false, "error");
  23634. _sqlSugar.BeginTran();
  23635. try
  23636. {
  23637. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  23638. .Select(x => new Crm_NewClientData
  23639. {
  23640. Id = x.Id,
  23641. Client = x.Client,
  23642. Contact = x.Contact,
  23643. Location = x.Location,
  23644. })
  23645. .ToList();
  23646. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  23647. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  23648. Stopwatch stopwatch = new Stopwatch();
  23649. // 开始计时
  23650. stopwatch.Start();
  23651. foreach (var item in clientList)
  23652. {
  23653. EncryptionProcessor.DecryptProperties(item);
  23654. }
  23655. stopwatch.Stop();
  23656. jw.Code = 200;
  23657. jw.Data = stopwatch.ElapsedMilliseconds;
  23658. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  23659. }
  23660. catch (Exception ex)
  23661. {
  23662. jw.Code = 400;
  23663. jw.Msg = ex.Message;
  23664. }
  23665. return Ok(jw);
  23666. }
  23667. }
  23668. }