GroupsController.cs 1.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595
  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 VisaProcessRepository _visaProcessRep;
  114. private readonly IDeepSeekService _deepSeekService;
  115. /// <summary>
  116. /// 构造函数
  117. /// </summary>
  118. /// <param name="logger"></param>
  119. /// <param name="eec_textLogger"></param>
  120. /// <param name="groupTextLogger"></param>
  121. /// <param name="mapper"></param>
  122. /// <param name="hubContext"></param>
  123. /// <param name="sqlSugar"></param>
  124. /// <param name="grpScheduleRep"></param>
  125. /// <param name="groupRepository"></param>
  126. /// <param name="taskAssignmentRep"></param>
  127. /// <param name="airTicketResRep"></param>
  128. /// <param name="decreasePaymentsRep"></param>
  129. /// <param name="InvitationOfficialActivitiesRep"></param>
  130. /// <param name="delegationEnDataRep"></param>
  131. /// <param name="enterExitCostRep"></param>
  132. /// <param name="delegationVisaRep"></param>
  133. /// <param name="message"></param>
  134. /// <param name="visaPriceRep"></param>
  135. /// <param name="carTouristGuideGroundRep"></param>
  136. /// <param name="checkBoxs"></param>
  137. /// <param name="GroupCostRepository"></param>
  138. /// <param name="CostTypeHotelNumberRepository"></param>
  139. /// <param name="GroupCostParameterRepository"></param>
  140. /// <param name="hotelPriceRep"></param>
  141. /// <param name="customersRep"></param>
  142. /// <param name="setDataRep"></param>
  143. /// <param name="tourClientListRep"></param>
  144. /// <param name="teamRateRep"></param>
  145. /// <param name="usersRep"></param>
  146. /// <param name="juHeApi"></param>
  147. /// <param name="invertedListRep"></param>
  148. /// <param name="visaFeeInfoRep"></param>
  149. /// <param name="ticketBlackCodeRep"></param>
  150. /// <param name="hotelInquiryRep"></param>
  151. /// <param name="threeCodeRepository"></param>
  152. /// <param name="feeAuditRep"></param>
  153. /// <param name="visaCommissionRep"></param>
  154. /// <param name="ffrRep"></param>
  155. /// <param name="opinionaireRep"></param>
  156. /// <param name="tableorRep"></param>
  157. /// <param name="enterExitCostDraftRep"></param>
  158. /// <param name="restaurantRep"></param>
  159. /// <param name="enterExitCostQuoteRep"></param>
  160. /// <param name="grpOrderPreInfoRep"></param>
  161. /// <param name="visaProcessRep"></param>
  162. public GroupsController(
  163. ILogger<GroupsController> logger,
  164. ITextFileLogger eec_textLogger,
  165. IGroupTextFileLogger groupTextLogger,
  166. IMapper mapper,
  167. IHubContext<ChatHub, IChatClient> hubContext,
  168. SqlSugarClient sqlSugar,
  169. GrpScheduleRepository grpScheduleRep,
  170. DelegationInfoRepository groupRepository,
  171. TaskAssignmentRepository taskAssignmentRep,
  172. AirTicketResRepository airTicketResRep,
  173. DecreasePaymentsRepository decreasePaymentsRep,
  174. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  175. DelegationEnDataRepository delegationEnDataRep,
  176. EnterExitCostRepository enterExitCostRep,
  177. DelegationVisaRepository delegationVisaRep,
  178. MessageRepository message,
  179. VisaPriceRepository visaPriceRep,
  180. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  181. CheckBoxsRepository checkBoxs,
  182. GroupCostRepository GroupCostRepository,
  183. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  184. GroupCostParameterRepository GroupCostParameterRepository,
  185. HotelPriceRepository hotelPriceRep,
  186. CustomersRepository customersRep,
  187. SetDataRepository setDataRep,
  188. TourClientListRepository tourClientListRep,
  189. TeamRateRepository teamRateRep,
  190. UsersRepository usersRep,
  191. IJuHeApiService juHeApi,
  192. InvertedListRepository invertedListRep,
  193. VisaFeeInfoRepository visaFeeInfoRep,
  194. TicketBlackCodeRepository ticketBlackCodeRep,
  195. HotelInquiryRepository hotelInquiryRep,
  196. ThreeCodeRepository threeCodeRepository,
  197. FeeAuditRepository feeAuditRep,
  198. VisaCommissionRepository visaCommissionRep,
  199. ForeignReceivablesRepository ffrRep,
  200. OpinionaireRepository opinionaireRep,
  201. TableOperationRecordRepository tableorRep,
  202. EnterExitCostDraftRepository enterExitCostDraftRep,
  203. RestaurantRepository restaurantRep,
  204. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  205. GroupOrderPreInfoRepository grpOrderPreInfoRep,
  206. VisaProcessRepository visaProcessRep,
  207. IDeepSeekService deepSeekService
  208. )
  209. {
  210. _logger = logger;
  211. _eec_textLogger = eec_textLogger;
  212. _groupTextLogger = groupTextLogger;
  213. _mapper = mapper;
  214. _grpScheduleRep = grpScheduleRep;
  215. _groupRepository = groupRepository;
  216. _taskAssignmentRep = taskAssignmentRep;
  217. _airTicketResRep = airTicketResRep;
  218. _sqlSugar = sqlSugar;
  219. url = AppSettingsHelper.Get("ExcelBaseUrl");
  220. path = AppSettingsHelper.Get("ExcelBasePath");
  221. if (!System.IO.Directory.Exists(path))
  222. {
  223. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  224. }
  225. _decreasePaymentsRep = decreasePaymentsRep;
  226. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  227. _delegationEnDataRep = delegationEnDataRep;
  228. _enterExitCostRep = enterExitCostRep;
  229. _delegationVisaRep = delegationVisaRep;
  230. _message = message;
  231. _visaPriceRep = visaPriceRep;
  232. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  233. _checkBoxs = checkBoxs;
  234. _GroupCostRepository = GroupCostRepository;
  235. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  236. _GroupCostParameterRepository = GroupCostParameterRepository;
  237. _hotelPriceRep = hotelPriceRep;
  238. _customersRep = customersRep;
  239. _setDataRep = setDataRep;
  240. _tourClientListRep = tourClientListRep;
  241. _teamRateRep = teamRateRep;
  242. _hubContext = hubContext;
  243. _usersRep = usersRep;
  244. _juHeApi = juHeApi;
  245. _invertedListRep = invertedListRep;
  246. _visaFeeInfoRep = visaFeeInfoRep;
  247. _ticketBlackCodeRep = ticketBlackCodeRep;
  248. _hotelInquiryRep = hotelInquiryRep;
  249. _threeCodeRepository = threeCodeRepository;
  250. _feeAuditRep = feeAuditRep;
  251. _visaCommissionRep = visaCommissionRep;
  252. _ffrRep = ffrRep;
  253. _opinionaireRep = opinionaireRep;
  254. _currencyInit = new List<CurrencyInfo>()
  255. {
  256. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  257. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  258. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  259. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  260. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  261. };
  262. _portTypeData = new List<int>() { 2, 3 };
  263. _tableorRep = tableorRep;
  264. _enterExitCostDraftRep = enterExitCostDraftRep;
  265. _restaurantRep = restaurantRep;
  266. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  267. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  268. _deepSeekService = deepSeekService;
  269. _visaProcessRep = visaProcessRep;
  270. }
  271. #region 流程管控
  272. /// <summary>
  273. /// 获取团组流程管控信息
  274. /// </summary>
  275. /// <param name="_jsonDto">查询参数</param>
  276. /// <returns></returns>
  277. [HttpPost]
  278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  279. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  280. {
  281. if (string.IsNullOrEmpty(_jsonDto.Paras))
  282. {
  283. return Ok(JsonView(false, "参数为空"));
  284. }
  285. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  286. if (_ScheduleDto != null)
  287. {
  288. if (_ScheduleDto.SearchType == 2)//获取列表
  289. {
  290. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  291. return Ok(JsonView(_grpScheduleViewList));
  292. }
  293. else//获取对象
  294. {
  295. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  296. if (_grpScheduleView != null)
  297. {
  298. return Ok(JsonView(_grpScheduleView));
  299. }
  300. }
  301. }
  302. else
  303. {
  304. return Ok(JsonView(false, "参数反序列化失败"));
  305. }
  306. return Ok(JsonView(false, "暂无数据!"));
  307. }
  308. /// <summary>
  309. /// 修改团组流程管控详细表数据
  310. /// </summary>
  311. /// <param name="dto"></param>
  312. /// <returns></returns>
  313. [HttpPost]
  314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  315. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  316. {
  317. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  318. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  319. .SetColumns(it => it.Duty == _detail.Duty)
  320. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  321. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  322. .SetColumns(it => it.JobContent == _detail.JobContent)
  323. .SetColumns(it => it.Remark == _detail.Remark)
  324. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  325. .Where(s => s.Id == dto.Id)
  326. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  327. .ExecuteCommandAsync();
  328. if (result > 0)
  329. {
  330. return Ok(JsonView(true, "保存成功!"));
  331. }
  332. return Ok(JsonView(false, "保存失败!"));
  333. }
  334. /// <summary>
  335. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  336. /// </summary>
  337. /// <param name="dto"></param>
  338. /// <returns></returns>
  339. [HttpPost]
  340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  341. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  342. {
  343. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  344. _detail.IsDel = 1;
  345. _detail.DeleteUserId = dto.Duty;
  346. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  347. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  348. .SetColumns(it => it.IsDel == _detail.IsDel)
  349. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  350. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  351. .Where(it => it.Id == dto.Id)
  352. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  353. //.WhereColumns(s => s.Id == dto.Id)
  354. .ExecuteCommandAsync();
  355. if (result > 0)
  356. {
  357. return Ok(JsonView(true, "删除成功!"));
  358. }
  359. return Ok(JsonView(false, "删除失败!"));
  360. }
  361. /// <summary>
  362. /// 增加团组流程管控详细表数据
  363. /// </summary>
  364. /// <param name="dto"></param>
  365. /// <returns></returns>
  366. [HttpPost]
  367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  368. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  369. {
  370. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  371. if (DateTime.Now < _detail.ExpectBeginDt)
  372. {
  373. _detail.StepStatus = 0;
  374. }
  375. else
  376. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  377. _detail.StepStatus = 1;
  378. }
  379. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  380. if (result > 0)
  381. {
  382. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  383. return Ok(JsonView(true, "添加成功!", _result));
  384. }
  385. return Ok(JsonView(false, "添加失败!"));
  386. }
  387. #endregion
  388. #region 团组前期信息
  389. /// <summary>
  390. /// 团组前期信息H5-URL(员工对应地址)
  391. /// </summary>
  392. /// <param name="name">用户名称</param>
  393. /// <returns></returns>
  394. [HttpGet]
  395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  396. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  397. {
  398. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  399. .Where(x => x.IsDel == 0)
  400. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  401. .OrderBy(x => x.Id)
  402. .Select(x => new
  403. {
  404. name = x.CnName,
  405. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  406. })
  407. .ToListAsync();
  408. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  409. }
  410. /// <summary>
  411. /// 团组前期信息 List
  412. /// </summary>
  413. /// <returns></returns>
  414. [HttpPost]
  415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  416. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  417. {
  418. var search = dto.Search;
  419. int[] nameTempIds = new int[] { 1, 12, 28 },
  420. countryTempIds = new int[] { 2, 13, 29 },
  421. daysTempIds = new int[] { 4, 15, 31 },
  422. ppNumTempIds = new int[] { 6 };
  423. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  424. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  425. .Where((opi, u) => opi.IsDel == 0)
  426. .OrderByDescending((opi, u) => opi.CreateTime)
  427. .Select((opi, u) => new GroupOrderPreInfoListView()
  428. {
  429. Id = opi.Id,
  430. Name = opi.Name,
  431. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  432. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  433. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  434. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  435. Operator = u.CnName,
  436. OperationTime = opi.CreateTime
  437. })
  438. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  439. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  440. .ToListAsync();
  441. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  442. int total = list.Count;
  443. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  444. var listPageData1 = listPageData
  445. .Skip((dto.PageIndex - 1) * dto.PageSize)
  446. .Take(dto.PageSize)
  447. .ToList();
  448. var infoIds = listPageData1.Select(x => x.Id).ToList();
  449. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  450. .Where(x => x.IsDel == 0 && x.STid == 109)
  451. .ToArrayAsync();
  452. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  453. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  454. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  455. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  456. .ToListAsync();
  457. foreach (var item in listPageData1)
  458. {
  459. var typeDatas1 = typeDatas.Select(x => new
  460. {
  461. x.Id,
  462. x.Name,
  463. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  464. }).ToArray();
  465. item.VersionDetails = typeDatas1;
  466. }
  467. return Ok(JsonView(listPageData1, listPageData1.Count));
  468. }
  469. /// <summary>
  470. /// 团组前期信息 Init
  471. /// </summary>
  472. /// <returns></returns>
  473. [HttpGet("{userId}")]
  474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  475. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  476. {
  477. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  478. }
  479. /// <summary>
  480. /// 国家数据源
  481. /// </summary>
  482. /// <param name="pageIndex">当前页码</param>
  483. /// <param name="pageSize">每页条数</param>
  484. /// <param name="search">查询条件</param>
  485. /// <returns></returns>
  486. [HttpGet]
  487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  488. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  489. {
  490. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  491. if (pageIndex == 0 && pageSize == 0)
  492. {
  493. //所有数据
  494. return Ok(JsonView(countrys, countrys.Count));
  495. }
  496. //分页
  497. int skip = (pageIndex - 1) * pageSize;
  498. int take = pageSize;
  499. if (!string.IsNullOrEmpty(search))
  500. {
  501. IEnumerable<char> charSequence = search.Select(c => c);
  502. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  503. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  504. return Ok(JsonView(pageData, pageResult1.Count));
  505. }
  506. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  507. return Ok(JsonView(pageResult2, countrys.Count));
  508. }
  509. /// <summary>
  510. /// 城市数据源
  511. /// </summary>
  512. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  513. /// <param name="pageIndex">当前页码</param>
  514. /// <param name="pageSize">每页条数</param>
  515. /// <param name="search">查询条件</param>
  516. /// <returns></returns>
  517. [HttpGet("{countryLabel}")]
  518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  519. public async Task<IActionResult> CityByCountry(
  520. string countryLabel,
  521. [FromQuery] int pageIndex,
  522. [FromQuery] int pageSize,
  523. [FromQuery] string search)
  524. {
  525. countryLabel = HttpUtility.UrlDecode(countryLabel);
  526. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  527. var citys = Array.Empty<string?>();
  528. if (countryList.Any())
  529. {
  530. var cityDatas = await _sqlSugar
  531. .Queryable<Grp_NationalTravelFee>()
  532. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  533. .ToArrayAsync();
  534. foreach (var item in cityDatas)
  535. {
  536. if (item.City.Contains("城市"))
  537. {
  538. item.City = item.Country + "-所有城市";
  539. }
  540. }
  541. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  542. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  543. }
  544. if (pageIndex == 0 && pageSize == 0)
  545. {
  546. //所有数据
  547. return Ok(JsonView(citys, citys?.Length ?? 0));
  548. }
  549. //分页
  550. int skip = (pageIndex - 1) * pageSize;
  551. int take = pageSize;
  552. if (!string.IsNullOrEmpty(search))
  553. {
  554. IEnumerable<char> charSequence = search.Select(c => c);
  555. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  556. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  557. return Ok(JsonView(pageData, pageResult1.Count));
  558. }
  559. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  560. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  561. }
  562. /// <summary>
  563. /// 团组前期信息 Info
  564. /// </summary>
  565. /// <param name="dto">Id</param>
  566. /// <returns></returns>
  567. [HttpGet("{Id}/{TempId}")]
  568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  569. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  570. {
  571. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  572. }
  573. /// <summary>
  574. /// 团组前期信息 移动端 Info
  575. /// </summary>
  576. /// <param name="dto">Id</param>
  577. /// <returns></returns>
  578. [HttpGet("{Id}/{TempId}")]
  579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  580. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  581. {
  582. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  583. }
  584. /// <summary>
  585. /// 团组前期信息 Save
  586. /// </summary>
  587. /// <param name="dto">Id</param>
  588. /// <returns></returns>
  589. [HttpPost]
  590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  591. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  592. {
  593. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  594. }
  595. /// <summary>
  596. /// 团组前期信息 Del
  597. /// </summary>
  598. /// <param name="dto">Id</param>
  599. /// <returns></returns>
  600. [HttpPost]
  601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  602. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  603. {
  604. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  605. }
  606. /// <summary>
  607. /// 团组前期信息 文件下载
  608. /// </summary>
  609. /// <param name="dto">Id</param>
  610. /// <returns></returns>
  611. [HttpGet("{Id}/{TempId}")]
  612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  613. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  614. {
  615. int id = dto.Id, tempId = dto.TempId;
  616. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  617. var data = view.Data as GrpOrderPreInfoView;
  618. #region Excel
  619. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  620. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  621. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  622. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  623. var fileNamePrefix = string.Empty;
  624. if (tempId == 1405)
  625. {
  626. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  627. fileNamePrefix = $"{data.Name}_无商邀版";
  628. }
  629. else if (tempId == 1406)
  630. {
  631. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  632. fileNamePrefix = $"{data.Name}_有商邀版";
  633. }
  634. else
  635. {
  636. //tempId == 1404 默认下载
  637. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  638. fileNamePrefix = $"{data.Name}_单接送机";
  639. }
  640. foreach (var item in data.Items)
  641. {
  642. var obj = item.NewValue;
  643. if (obj == null) item.OriginVal = "";
  644. else if (obj.Equals("有") || obj.Equals("无"))
  645. {
  646. item.OriginVal = obj.ToString();
  647. }
  648. else if (obj is object[] objArray)
  649. {
  650. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  651. item.OriginVal = string.Join("、", stringArray);
  652. }
  653. else if (obj is string[] stringArray)
  654. {
  655. item.OriginVal = string.Join("、", stringArray);
  656. }
  657. else if (obj.Equals("-"))
  658. {
  659. item.OriginVal = "";
  660. }
  661. }
  662. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  663. fileName = CommonFun.ValidFileName(fileName);
  664. //载入模板
  665. var designer = new WorkbookDesigner
  666. {
  667. Workbook = new Workbook(tempPath)
  668. };
  669. if (tempId == 1406)
  670. {
  671. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  672. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  673. for (int i = 1; i <= view2.Length; i++)
  674. {
  675. view2[i - 1].Index = i;
  676. }
  677. designer.SetDataSource("View1", view1);
  678. designer.SetDataSource("View2", view2);
  679. }
  680. else
  681. {
  682. designer.SetDataSource("View", data.Items);
  683. }
  684. designer.Process();
  685. if (!Directory.Exists(savePath))
  686. {
  687. Directory.CreateDirectory(savePath);
  688. }
  689. string serverPath = $"{savePath}{fileName}";
  690. designer.Workbook.Save(serverPath);
  691. string rst = $"{servicePath}{ftpPath}{fileName}";
  692. #endregion
  693. return Ok(JsonView(new { url = rst }));
  694. }
  695. #endregion
  696. #region 团组基本信息
  697. /// <summary>
  698. /// 接团信息列表
  699. /// </summary>
  700. /// <param name="dto">团组列表请求dto</param>
  701. /// <returns></returns>
  702. [HttpPost]
  703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  704. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  705. {
  706. var groupData = await _groupRepository.GetGroupList(dto);
  707. if (groupData.Code != 0)
  708. {
  709. return Ok(JsonView(false, groupData.Msg));
  710. }
  711. return Ok(JsonView(groupData.Data));
  712. }
  713. /// <summary>
  714. /// 分页查询团组列表
  715. /// </summary>
  716. /// <param name="dto"></param>
  717. /// <returns></returns>
  718. [HttpPost]
  719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  720. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  721. {
  722. var watch = new Stopwatch();
  723. watch.Start();
  724. RefAsync<int> total = 0;
  725. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  726. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  727. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  728. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  729. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  730. .Distinct()
  731. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  732. watch.Stop();
  733. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  734. }
  735. /// <summary>
  736. /// 接团信息列表 Page Init
  737. /// </summary>
  738. /// <returns></returns>
  739. [HttpPost]
  740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  741. public async Task<IActionResult> PostGroupPageListInit()
  742. {
  743. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  744. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  745. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  746. var _view = new
  747. {
  748. depData = depDatas,
  749. rankData = rankDatas
  750. };
  751. return Ok(JsonView(true, "查询成功!", _view));
  752. }
  753. /// <summary>
  754. /// 接团信息列表 Page
  755. /// </summary>
  756. /// <param name="dto">团组列表请求dto</param>
  757. /// <returns></returns>
  758. [HttpPost]
  759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  760. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  761. {
  762. #region 参数验证
  763. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  764. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  765. #region 页面操作权限验证
  766. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  767. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  768. #endregion
  769. #endregion
  770. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  771. {
  772. string sqlWhere = string.Empty;
  773. if (dto.IsSure == 0) //未完成
  774. {
  775. sqlWhere += string.Format(@" And IsSure = 0");
  776. }
  777. else if (dto.IsSure == 1) //已完成
  778. {
  779. sqlWhere += string.Format(@" And IsSure = 1");
  780. }
  781. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  782. {
  783. string tj = dto.SearchCriteria;
  784. 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}%')",
  785. tj, tj, tj, tj, tj);
  786. }
  787. if (int.TryParse(dto.Rank, out int rankId))
  788. {
  789. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  790. }
  791. string sqlWhere1 = string.Empty;
  792. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  793. {
  794. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  795. }
  796. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  797. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  798. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  799. JietuanOperator,IsSure,CreateTime,IsBid,Step
  800. From (
  801. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  802. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  803. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  804. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,gdi.Step,
  805. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  806. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  807. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  808. From Grp_DelegationInfo gdi
  809. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  810. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  811. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  812. Where gdi.IsDel = 0 {0}
  813. ) temp {1}", sqlWhere, sqlWhere1);
  814. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  815. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  816. //处理 团组模块实际操作人
  817. _DelegationList.ForEach(async x =>
  818. {
  819. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  820. var operatorNames = new StringBuilder();
  821. //operatorNames.AppendLine("各模块实际操作人:");
  822. if (operators.Any())
  823. {
  824. operators.ForEach(y =>
  825. {
  826. string label = string.Empty;
  827. if (y.OperationUsers.Any())
  828. {
  829. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  830. label = string.Join('、', users);
  831. }
  832. else label = "暂未指定";
  833. operatorNames.AppendLine($"{y.CTableName}:{label}");
  834. operatorNames.AppendLine();
  835. });
  836. }
  837. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  838. });
  839. var _view = new
  840. {
  841. PageFuncAuth = pageFunAuthView,
  842. Data = _DelegationList
  843. };
  844. return Ok(JsonView(true, "查询成功!", _view, total));
  845. }
  846. else
  847. {
  848. return Ok(JsonView(false, "查询失败"));
  849. }
  850. }
  851. /// <summary>
  852. /// 团组列表
  853. /// </summary>
  854. /// <returns></returns>
  855. [HttpPost]
  856. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  857. {
  858. #region 参数验证
  859. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  860. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  861. #region 页面操作权限验证
  862. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  863. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  864. #endregion
  865. #endregion
  866. if (dto.PortType != 1 && dto.PortType != 2)
  867. {
  868. return Ok(JsonView(false, "查询失败!"));
  869. }
  870. string orderbyStr = "order by gdi.CreateTime Desc";
  871. string sqlWhere = string.Empty;
  872. if (dto.IsSure == 0) //未完成
  873. {
  874. sqlWhere += string.Format(@" And IsSure = 0");
  875. }
  876. else if (dto.IsSure == 1) //已完成
  877. {
  878. sqlWhere += string.Format(@" And IsSure = 1");
  879. }
  880. //团组类型
  881. if (dto.TeamDid > 0)
  882. {
  883. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  884. }
  885. //团组名称
  886. if (!string.IsNullOrEmpty(dto.TeamName))
  887. {
  888. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  889. }
  890. //客户名称
  891. if (!string.IsNullOrEmpty(dto.ClientName))
  892. {
  893. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  894. }
  895. //客户单位
  896. if (!string.IsNullOrEmpty(dto.ClientUnit))
  897. {
  898. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  899. }
  900. //出访时间
  901. if (!string.IsNullOrEmpty(dto.visitDataTime))
  902. {
  903. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  904. orderbyStr = "order by gdi.VisitDate";
  905. }
  906. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  907. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  908. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  909. JietuanOperator,IsSure,CreateTime
  910. From (
  911. Select row_number() over({0}) as Row_Number,
  912. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  913. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  914. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  915. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  916. From Grp_DelegationInfo gdi
  917. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  918. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  919. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  920. Where gdi.IsDel = 0 {1}
  921. ) temp ", orderbyStr, sqlWhere);
  922. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  923. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  924. #region 处理所属部门
  925. /*
  926. * 1.sq 和 gyy 等显示 市场部
  927. * 2.王鸽和主管及张总还有管理员号统一国交部
  928. * 2-1. 4 管理员 ,21 张海麟
  929. */
  930. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  931. var userIds1 = new List<int>() { 4, 21 };
  932. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  933. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  934. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  935. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  936. .ToList();
  937. foreach (var item in _DelegationList)
  938. {
  939. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  940. }
  941. #endregion
  942. var _view = new
  943. {
  944. PageFuncAuth = pageFunAuthView,
  945. Data = _DelegationList
  946. };
  947. return Ok(JsonView(true, "查询成功!", _view, total));
  948. }
  949. /// <summary>
  950. /// 接团信息详情
  951. /// </summary>
  952. /// <param name="dto">团组info请求dto</param>
  953. /// <returns></returns>
  954. [HttpPost]
  955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  956. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  957. {
  958. var groupData = await _groupRepository.GetGroupInfo(dto);
  959. if (groupData.Code != 0)
  960. {
  961. return Ok(JsonView(false, groupData.Msg));
  962. }
  963. return Ok(JsonView(groupData.Data));
  964. }
  965. /// <summary>
  966. /// 接团信息 编辑添加
  967. /// 基础信息数据源
  968. /// </summary>
  969. /// <param name="dto"></param>
  970. /// <returns></returns>
  971. [HttpPost]
  972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  973. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  974. {
  975. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  976. if (groupData.Code != 0)
  977. {
  978. return Ok(JsonView(false, groupData.Msg));
  979. }
  980. return Ok(JsonView(groupData.Data));
  981. }
  982. /// <summary>
  983. /// 成本修改团组信息
  984. /// </summary>
  985. /// <param name="dto"></param>
  986. /// <returns></returns>
  987. [HttpPost]
  988. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  989. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  990. {
  991. var jw = JsonView(false, "操作失败");
  992. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  993. if (di == null)
  994. {
  995. jw.Msg = "参数有误!";
  996. return Ok(jw);
  997. }
  998. #region 添加出访起止时间
  999. var startTime = new DateTime();
  1000. var endTime = new DateTime();
  1001. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1002. {
  1003. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1004. }
  1005. else
  1006. {
  1007. jw.Msg = "参数有误!";
  1008. return Ok(jw);
  1009. }
  1010. #endregion
  1011. di.VisitDate = startTime;
  1012. di.VisitPNumber = dto.VisitPNumber;
  1013. di.VisitDays = dto.VisitDays;
  1014. di.VisitStartDate = startTime;
  1015. di.VisitEndDate = endTime;
  1016. var count = _sqlSugar.Updateable(di)
  1017. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1018. .ExecuteCommand();
  1019. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1020. }
  1021. /// <summary>
  1022. /// 接团信息 编辑添加
  1023. /// 省份-城市 基础信息数据源
  1024. /// </summary>
  1025. /// <param name="dto"></param>
  1026. /// <returns></returns>
  1027. [HttpPost]
  1028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1029. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1030. {
  1031. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1032. string search = dto.Search;
  1033. var data = await _groupRepository.CityBasicSource();
  1034. int total = data.Length;
  1035. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1036. .Skip((pageIndex - 1) * pageSize)
  1037. .Take(pageSize)
  1038. .ToArray();
  1039. return Ok(JsonView(data, total));
  1040. }
  1041. /// <summary>
  1042. /// 接团信息 操作(增改)
  1043. /// </summary>
  1044. /// <param name="dto"></param>
  1045. /// <returns></returns>
  1046. [HttpPost]
  1047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1048. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1049. {
  1050. // 创建 Stopwatch 实例
  1051. Stopwatch stopwatch = Stopwatch.StartNew();
  1052. decimal ffrPrice = 0.00M;
  1053. DateTime? visitDt = null;
  1054. if (dto.Status == 2)
  1055. {
  1056. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1057. if (groupInfo != null)
  1058. {
  1059. ffrPrice = groupInfo.PaymentMoney;
  1060. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1061. }
  1062. }
  1063. var groupData = await _groupRepository.GroupOperation(dto);
  1064. if (groupData.Code != 0)
  1065. {
  1066. return Ok(JsonView(false, groupData.Msg));
  1067. }
  1068. int diId = 0;
  1069. try
  1070. {
  1071. //添加时 默认加入团组汇率
  1072. if (dto.Status == 1) //添加
  1073. {
  1074. diId = groupData.Data;
  1075. //添加默认币种
  1076. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1077. //默认分配权限
  1078. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1079. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1080. var _managerIds = new List<int>() { 22, 32, 21 };
  1081. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1082. if (userIds.Count > 0)
  1083. {
  1084. userIds.Add(208);
  1085. //创建团组管控
  1086. GroupStepForDelegation.CreateWorkStep(diId);
  1087. //发送消息
  1088. string groupName = dto.TeamName;
  1089. string createGroupUser = string.Empty;
  1090. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1091. if (userInfo != null) createGroupUser = userInfo.CnName;
  1092. string title = $"系统通知";
  1093. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1094. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1095. }
  1096. //默认创建倒推表
  1097. await _invertedListRep._Create(dto.UserId, diId);
  1098. //默认创建签证流程
  1099. await _visaProcessRep.Create(dto.UserId, diId);
  1100. }
  1101. else if (dto.Status == 2)
  1102. {
  1103. diId = dto.Id;
  1104. }
  1105. #region 签证人员团组时间通知
  1106. #region 计算出访起止时间
  1107. var startTime = new DateTime();
  1108. var endTime = new DateTime();
  1109. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1110. {
  1111. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1112. }
  1113. #endregion
  1114. #endregion
  1115. #region 团组操作默认添加/修改收款账单
  1116. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1117. {
  1118. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1119. .Where(x => x.IsDel == 0 &&
  1120. x.Diid == diId &&
  1121. x.Remark.Equals("预付款")
  1122. )
  1123. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1124. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1125. .FirstAsync();
  1126. ffrInfo = new Fin_ForeignReceivables()
  1127. {
  1128. Diid = diId,
  1129. PriceName = dto.ClientUnit,
  1130. Price = dto.PaymentMoney,
  1131. Count = 1,
  1132. Unit = $"元",
  1133. ItemSumPrice = dto.PaymentMoney,
  1134. Rate = 1.0000M,
  1135. Currency = 836,
  1136. AddingWay = 0,
  1137. CreateUserId = dto.UserId,
  1138. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1139. Remark = $"预付款"
  1140. };
  1141. if (ffrInfo == null) //Add
  1142. {
  1143. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1144. }
  1145. else //修改
  1146. {
  1147. await _sqlSugar.Updateable(ffrInfo)
  1148. .UpdateColumns(x => new
  1149. {
  1150. x.PriceName,
  1151. x.Price,
  1152. x.ItemSumPrice,
  1153. x.CreateTime,
  1154. x.CreateUserId
  1155. })
  1156. .WhereColumns(x => x.Id)
  1157. .ExecuteCommandAsync();
  1158. }
  1159. }
  1160. #endregion
  1161. if (diId > 0)
  1162. {
  1163. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1164. }
  1165. // 停止计时
  1166. stopwatch.Stop();
  1167. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1168. }
  1169. catch (Exception ex)
  1170. {
  1171. // 停止计时
  1172. stopwatch.Stop();
  1173. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1174. Logs(ex.Message);
  1175. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1176. }
  1177. // 停止计时
  1178. stopwatch.Stop();
  1179. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1180. }
  1181. /// <summary>
  1182. /// 接团流程操作(增改)
  1183. /// 安卓端使用 建团时添加客户名单
  1184. /// </summary>
  1185. /// <param name="dto"></param>
  1186. /// <returns></returns>
  1187. [HttpPost]
  1188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1189. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1190. {
  1191. #region 参数验证
  1192. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1193. #region 页面操作权限验证
  1194. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1195. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1196. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1197. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1198. #endregion
  1199. #endregion
  1200. try
  1201. {
  1202. //_sqlSugar.BeginTran();
  1203. decimal ffrPrice = 0.00M;
  1204. DateTime? visitDt = null;
  1205. if (dto.Status == 2)
  1206. {
  1207. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1208. if (groupInfo != null)
  1209. {
  1210. ffrPrice = groupInfo.PaymentMoney;
  1211. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1212. }
  1213. }
  1214. var _dto = new GroupOperationDto();
  1215. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1216. var groupData = await _groupRepository.GroupOperation(_dto);
  1217. if (groupData.Code != 0)
  1218. {
  1219. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1220. }
  1221. int diId = 0;
  1222. //添加时 默认加入团组汇率
  1223. if (dto.Status == 1) //添加
  1224. {
  1225. diId = groupData.Data;
  1226. //添加默认币种
  1227. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1228. //默认分配权限
  1229. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1230. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1231. var _managerIds = new List<int>() { 21, 22, 32 };
  1232. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1233. if (userIds.Count > 0)
  1234. {
  1235. userIds.Add(208);
  1236. //创建团组管控
  1237. GroupStepForDelegation.CreateWorkStep(diId);
  1238. //发送消息
  1239. string groupName = dto.TeamName;
  1240. string createGroupUser = string.Empty;
  1241. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1242. if (userInfo != null) createGroupUser = userInfo.CnName;
  1243. string title = $"系统通知";
  1244. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1245. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1246. }
  1247. #region 应用推送
  1248. try
  1249. {
  1250. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1251. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1252. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1253. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1254. {
  1255. var userList = new List<string>() { users.QiyeChatUserId };
  1256. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1257. }
  1258. }
  1259. catch (Exception ex)
  1260. {
  1261. }
  1262. #endregion
  1263. //默认创建倒推表
  1264. await _invertedListRep._Create(dto.UserId, diId);
  1265. }
  1266. if (dto.Status == 2)
  1267. {
  1268. diId = dto.Id;
  1269. if (diId == 0)
  1270. {
  1271. //_sqlSugar.RollbackTran();
  1272. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1273. }
  1274. }
  1275. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1276. if (viewData.Code != 0)
  1277. {
  1278. //_sqlSugar.RollbackTran();
  1279. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1280. }
  1281. #region 团组操作默认添加/修改收款账单
  1282. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1283. {
  1284. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1285. .Where(x => x.IsDel == 0 &&
  1286. x.Diid == diId &&
  1287. x.Remark.Equals("预付款")
  1288. )
  1289. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1290. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1291. .FirstAsync();
  1292. ffrInfo = new Fin_ForeignReceivables()
  1293. {
  1294. Diid = diId,
  1295. PriceName = dto.ClientUnit,
  1296. Price = dto.PaymentMoney,
  1297. Count = 1,
  1298. Unit = $"元",
  1299. ItemSumPrice = dto.PaymentMoney,
  1300. Rate = 1.0000M,
  1301. Currency = 836,
  1302. AddingWay = 0,
  1303. CreateUserId = dto.UserId,
  1304. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1305. Remark = $"预付款"
  1306. };
  1307. if (ffrInfo == null) //Add
  1308. {
  1309. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1310. }
  1311. else //修改
  1312. {
  1313. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1314. .UpdateColumns(x => new
  1315. {
  1316. x.PriceName,
  1317. x.Price,
  1318. x.ItemSumPrice,
  1319. x.CreateTime,
  1320. x.CreateUserId
  1321. })
  1322. .WhereColumns(x => x.Id)
  1323. .ExecuteCommandAsync();
  1324. }
  1325. }
  1326. #endregion
  1327. #region 签证人员团组时间通知
  1328. #region 计算出访起止时间
  1329. var startTime = new DateTime();
  1330. var endTime = new DateTime();
  1331. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1332. {
  1333. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1334. }
  1335. #endregion
  1336. if (diId > 0)
  1337. {
  1338. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1339. }
  1340. #endregion
  1341. //_sqlSugar.CommitTran();
  1342. return Ok(JsonView(true, "添加成功"));
  1343. }
  1344. catch (Exception ex)
  1345. {
  1346. _sqlSugar.RollbackTran();
  1347. return Ok(JsonView(false, ex.Message));
  1348. }
  1349. }
  1350. /// <summary>
  1351. /// 接团流程操作(增改)
  1352. /// 安卓端使用 建团时添加客户名单
  1353. /// </summary>
  1354. /// <param name="dto"></param>
  1355. /// <returns></returns>
  1356. [HttpPost]
  1357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1358. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1359. {
  1360. #region 参数验证
  1361. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1362. #region 页面操作权限验证
  1363. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1364. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1365. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1366. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1367. #endregion
  1368. #endregion
  1369. _sqlSugar.BeginTran();
  1370. decimal ffrPrice = 0.00M;
  1371. DateTime? visitDt = null;
  1372. if (dto.Status == 2)
  1373. {
  1374. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1375. if (groupInfo != null)
  1376. {
  1377. ffrPrice = groupInfo.PaymentMoney;
  1378. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1379. }
  1380. }
  1381. var _dto = new GroupOperationDto();
  1382. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1383. var groupData = await _groupRepository.GroupOperation(_dto);
  1384. if (groupData.Code != 0)
  1385. {
  1386. _sqlSugar.RollbackTran();
  1387. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1388. }
  1389. try
  1390. {
  1391. int diId = 0;
  1392. //添加时 默认加入团组汇率
  1393. if (dto.Status == 1) //添加
  1394. {
  1395. diId = groupData.Data;
  1396. //添加默认币种
  1397. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1398. //默认分配权限
  1399. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1400. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1401. var _managerIds = new List<int>() { 21, 22, 32 };
  1402. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1403. if (userIds.Count > 0)
  1404. {
  1405. userIds.Add(208);
  1406. //创建团组管控
  1407. GroupStepForDelegation.CreateWorkStep(diId);
  1408. //发送消息
  1409. string groupName = dto.TeamName;
  1410. string createGroupUser = string.Empty;
  1411. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1412. if (userInfo != null) createGroupUser = userInfo.CnName;
  1413. string title = $"系统通知";
  1414. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1415. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1416. }
  1417. #region 应用推送
  1418. try
  1419. {
  1420. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1421. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1422. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1423. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1424. {
  1425. var userList = new List<string>() { users.QiyeChatUserId };
  1426. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1427. }
  1428. }
  1429. catch (Exception ex)
  1430. {
  1431. _sqlSugar.CommitTran();
  1432. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1433. }
  1434. #endregion
  1435. //默认创建倒推表
  1436. await _invertedListRep._Create(dto.UserId, diId);
  1437. }
  1438. else if (dto.Status == 2)
  1439. {
  1440. diId = dto.Id;
  1441. if (diId == 0)
  1442. {
  1443. _sqlSugar.RollbackTran();
  1444. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1445. }
  1446. }
  1447. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1448. if (viewData.Code != 0)
  1449. {
  1450. _sqlSugar.RollbackTran();
  1451. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1452. }
  1453. #region 团组操作默认添加/修改收款账单
  1454. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1455. {
  1456. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1457. .Where(x => x.IsDel == 0 &&
  1458. x.Diid == diId &&
  1459. x.Remark.Equals("预付款")
  1460. )
  1461. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1462. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1463. .FirstAsync();
  1464. ffrInfo = new Fin_ForeignReceivables()
  1465. {
  1466. Diid = diId,
  1467. PriceName = dto.ClientUnit,
  1468. Price = dto.PaymentMoney,
  1469. Count = 1,
  1470. Unit = $"元",
  1471. ItemSumPrice = dto.PaymentMoney,
  1472. Rate = 1.0000M,
  1473. Currency = 836,
  1474. AddingWay = 0,
  1475. CreateUserId = dto.UserId,
  1476. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1477. Remark = $"预付款"
  1478. };
  1479. if (ffrInfo == null) //Add
  1480. {
  1481. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1482. }
  1483. else //修改
  1484. {
  1485. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1486. .UpdateColumns(x => new
  1487. {
  1488. x.PriceName,
  1489. x.Price,
  1490. x.ItemSumPrice,
  1491. x.CreateTime,
  1492. x.CreateUserId
  1493. })
  1494. .WhereColumns(x => x.Id)
  1495. .ExecuteCommandAsync();
  1496. }
  1497. }
  1498. #endregion
  1499. #region 签证人员团组时间通知
  1500. #region 计算出访起止时间
  1501. var startTime = new DateTime();
  1502. var endTime = new DateTime();
  1503. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1504. {
  1505. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1506. }
  1507. #endregion
  1508. if (diId > 0)
  1509. {
  1510. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1511. }
  1512. #endregion
  1513. _sqlSugar.CommitTran();
  1514. return Ok(JsonView(true));
  1515. }
  1516. catch (Exception ex)
  1517. {
  1518. _sqlSugar.RollbackTran();
  1519. return Ok(JsonView(false, ex.Message));
  1520. }
  1521. }
  1522. /// <summary>
  1523. /// 接团信息 操作(删除)
  1524. /// </summary>
  1525. /// <param name="dto"></param>
  1526. /// <returns></returns>
  1527. [HttpPost]
  1528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1529. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1530. {
  1531. var diId = dto.Id;
  1532. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1533. #region 删除 验证
  1534. /*
  1535. * 1、收款账单数据:0 条
  1536. * 2、收款退还数据:0 条
  1537. * 3、机票费用数据:0 条
  1538. * 4、签证费用数据:0 条
  1539. * 5、保险费用数据:0 条
  1540. * 6、酒店费用数据:0 条
  1541. * 7、公务出访数据:1 条
  1542. * 8、邀请公务活动费用数据:1 条
  1543. * 9、OP费用数据:5 条
  1544. * 10、其他费用数据:0 条
  1545. * 11、团组日付报销费用数据:0 条
  1546. *
  1547. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1548. */
  1549. //收款账单
  1550. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1551. //收款退还
  1552. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1553. //机票费用
  1554. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1555. //签证费用
  1556. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1557. //保险费用
  1558. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1559. //酒店费用
  1560. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1561. //公务出访
  1562. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1563. //邀请公务活动费用
  1564. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1565. //OP费用
  1566. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1567. //其他费用
  1568. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1569. //团组日付报销费用
  1570. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1571. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1572. if (feeCount > 0)
  1573. {
  1574. var delMsgTips = new StringBuilder();
  1575. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1576. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1577. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1578. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1579. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1580. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1581. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1582. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1583. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1584. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1585. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1586. delMsgTips.AppendLine($"");
  1587. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1588. return Ok(JsonView(false, delMsgTips.ToString()));
  1589. }
  1590. #endregion
  1591. var groupData = await _groupRepository.GroupDel(dto);
  1592. if (groupData.Code != 0)
  1593. {
  1594. return Ok(JsonView(false, groupData.Msg));
  1595. }
  1596. return Ok(JsonView(true));
  1597. }
  1598. /// <summary>
  1599. /// 获取团组销售报价号
  1600. /// 团组添加时 使用
  1601. /// </summary>
  1602. /// <returns></returns>
  1603. [HttpPost]
  1604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1605. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1606. {
  1607. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1608. if (groupData.Code != 0)
  1609. {
  1610. return Ok(JsonView(false, groupData.Msg));
  1611. }
  1612. object salesQuoteNo = new
  1613. {
  1614. SalesQuoteNo = groupData.Data
  1615. };
  1616. return Ok(JsonView(salesQuoteNo));
  1617. }
  1618. /// <summary>
  1619. /// 设置确认出团
  1620. /// </summary>
  1621. /// <param name="dto"></param>
  1622. /// <returns></returns>
  1623. [HttpPost]
  1624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1625. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1626. {
  1627. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1628. if (groupData.Code != 0)
  1629. {
  1630. return Ok(JsonView(false, groupData.Msg));
  1631. }
  1632. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1633. #region OA消息推送
  1634. try
  1635. {
  1636. string groupName = groupInfo.TeamName;
  1637. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1638. string title = $"系统通知";
  1639. string content = $"团组[{groupName}]已确认出团!";
  1640. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1641. }
  1642. catch (Exception ex)
  1643. {
  1644. }
  1645. #endregion
  1646. #region 应用推送
  1647. try
  1648. {
  1649. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1650. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1651. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1652. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1653. {
  1654. var userList = new List<string>() { users.QiyeChatUserId };
  1655. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1656. }
  1657. }
  1658. catch (Exception ex)
  1659. {
  1660. }
  1661. #endregion
  1662. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1663. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1664. }
  1665. /// <summary>
  1666. /// 获取团组名称data And 签证国别Data
  1667. /// </summary>
  1668. /// <param name="dto"></param>
  1669. /// <returns></returns>
  1670. [HttpPost]
  1671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1672. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1673. {
  1674. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1675. if (groupData.Code != 0)
  1676. {
  1677. return Ok(JsonView(false, groupData.Msg));
  1678. }
  1679. return Ok(JsonView(groupData.Data));
  1680. }
  1681. /// <summary>
  1682. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1683. /// </summary>
  1684. /// <returns></returns>
  1685. [HttpPost]
  1686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1687. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1688. {
  1689. try
  1690. {
  1691. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1692. if (groupData.Code != 0)
  1693. {
  1694. return Ok(JsonView(false, groupData.Msg));
  1695. }
  1696. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1697. }
  1698. catch (Exception ex)
  1699. {
  1700. return Ok(JsonView(false, ex.Message));
  1701. throw;
  1702. }
  1703. }
  1704. /// <summary>
  1705. /// 团组清单 Excel
  1706. /// </summary>
  1707. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1708. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1709. /// <returns></returns>
  1710. [HttpGet]
  1711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1712. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1713. {
  1714. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1715. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1716. if (!beginBool && !endBool)
  1717. {
  1718. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1719. }
  1720. string sql = string.Format(@"
  1721. SELECT
  1722. ROW_NUMBER,
  1723. Id,
  1724. SalesQuoteNo,
  1725. TourCode,
  1726. TeamTypeId,
  1727. TeamType,
  1728. TeamLevId,
  1729. TeamLev,
  1730. TeamName,
  1731. ClientName,
  1732. ClientUnit,
  1733. VisitDate,
  1734. VisitDays,
  1735. VisitPNumber,
  1736. JietuanOperatorId,
  1737. JietuanOperator,
  1738. IsSure,
  1739. CreateUserName,
  1740. IsBid
  1741. FROM
  1742. (
  1743. SELECT
  1744. ROW_NUMBER() OVER(
  1745. ORDER BY
  1746. gdi.VisitDate Desc
  1747. ) AS ROW_NUMBER,
  1748. gdi.Id,
  1749. SalesQuoteNo,
  1750. TourCode,
  1751. ssd.Id TeamTypeId,
  1752. ssd.Name TeamType,
  1753. ssd1.Id TeamLevId,
  1754. ssd1.Name TeamLev,
  1755. TeamName,
  1756. ClientName,
  1757. ClientUnit,
  1758. VisitDate,
  1759. VisitDays,
  1760. VisitPNumber,
  1761. JietuanOperator JietuanOperatorId,
  1762. su.CnName JietuanOperator,
  1763. IsSure,
  1764. gdi.CreateTime,
  1765. su1.CnName As CreateUserName,
  1766. gdi.IsBid
  1767. FROM
  1768. Grp_DelegationInfo gdi
  1769. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1770. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1771. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1772. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1773. WHERE
  1774. gdi.IsDel = 0
  1775. AND gdi.IsBid = 0
  1776. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1777. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1778. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1779. #region 处理所属部门
  1780. /*
  1781. * 1.sq 和 gyy 等显示 市场部
  1782. * 2.王鸽和主管及张总还有管理员号统一国交部
  1783. * 2-1. 4 管理员 ,21 张海麟
  1784. */
  1785. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1786. var userIds1 = new List<int>() { 4, 21 };
  1787. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1788. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1789. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1790. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1791. .ToListAsync();
  1792. var droupIds = groupList.Select(it => it.Id).ToList();
  1793. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1794. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1795. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1796. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1797. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1798. {
  1799. DiId = tcl.DiId,
  1800. LastName = dc.LastName,
  1801. FirstName = dc.FirstName,
  1802. Sex = dc.Sex,
  1803. Birthday = dc.BirthDay,
  1804. Company = cc.CompanyFullName,
  1805. Job = dc.Job,
  1806. CreateTime = tcl.CreateTime,
  1807. })
  1808. .ToList();
  1809. foreach (var item in groupList)
  1810. {
  1811. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1812. string groupFirstName = "";
  1813. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1814. if (currDatas.Any())
  1815. {
  1816. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1817. }
  1818. item.GroupFirst = groupFirstName;
  1819. }
  1820. #endregion
  1821. #region Excel
  1822. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1823. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1824. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1825. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1826. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1827. //载入模板
  1828. var designer = new WorkbookDesigner
  1829. {
  1830. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1831. };
  1832. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1833. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1834. dt.TableName = "GroupList";
  1835. designer.SetDataSource(dt);
  1836. designer.Process();
  1837. if (!Directory.Exists(savePath))
  1838. {
  1839. Directory.CreateDirectory(savePath);
  1840. }
  1841. string serverPath = $"{savePath}{fileName}";
  1842. designer.Workbook.Save(serverPath);
  1843. string rst = $"{servicePath}{ftpPath}{fileName}";
  1844. #endregion
  1845. return Ok(JsonView(true, "操作成功!", rst));
  1846. }
  1847. /// <summary>
  1848. /// 团组合同下载(1.付款80% 2.付全款)
  1849. /// </summary>
  1850. /// <param name="dto"></param>
  1851. /// <returns></returns>
  1852. /// <exception cref="Exception"></exception>
  1853. [HttpPost]
  1854. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1855. {
  1856. var jw = JsonView(false);
  1857. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1858. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1859. if (di == null)
  1860. {
  1861. jw.Msg = "团组Id有误!";
  1862. return Ok(jw);
  1863. }
  1864. #region 权限校验
  1865. var allDownFile = new List<int>() { 21 };
  1866. try
  1867. {
  1868. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1869. .First(x => x.Id == 1418 && x.IsDel == 0);
  1870. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1871. }
  1872. catch (Exception)
  1873. { }
  1874. var guojiaoDownFile = new List<int>() { 330, 383 };
  1875. var shichangDownFile = new List<int>() { 95 };
  1876. if (allDownFile.Contains(dto.UserId))
  1877. {
  1878. }
  1879. else if (guojiaoDownFile.Contains(dto.UserId))
  1880. {
  1881. var guojiaobuDi = new List<int>() { 4, 21 };
  1882. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1883. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1884. .Where((d, u) => u.Id == di.JietuanOperator)
  1885. .Select((d, u) => d.DepName)
  1886. .First();
  1887. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1888. {
  1889. jw.Msg = "暂无下载权限!";
  1890. return Ok(jw);
  1891. }
  1892. }
  1893. else if (shichangDownFile.Contains(dto.UserId))
  1894. {
  1895. var dic = new Dictionary<int, int[]>()
  1896. {
  1897. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1898. };
  1899. try
  1900. {
  1901. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1902. if (sqSetting != null)
  1903. {
  1904. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1905. foreach (var item in result.Keys)
  1906. {
  1907. if (dic.ContainsKey(item))
  1908. {
  1909. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1910. Array.Copy(dic[item], dilatation, dic[item].Length);
  1911. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1912. dic[item] = dilatation;
  1913. }
  1914. else
  1915. {
  1916. dic.Add(item, result[item]);
  1917. }
  1918. }
  1919. }
  1920. if (!dic[95].Contains(di.CreateUserId))
  1921. {
  1922. jw.Msg = "暂无下载权限!";
  1923. return Ok(jw);
  1924. }
  1925. }
  1926. catch (Exception)
  1927. { }
  1928. }
  1929. else if (dto.UserId == di.CreateUserId)
  1930. {
  1931. }
  1932. else
  1933. {
  1934. jw.Msg = "暂无下载权限!";
  1935. return Ok(jw);
  1936. }
  1937. #endregion
  1938. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1939. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1940. .ToListAsync();
  1941. if (!blackCodeList.Any())
  1942. {
  1943. jw.Msg = "该团无机票行程代码!";
  1944. return Ok(jw);
  1945. }
  1946. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1947. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1948. if (groupEnterExitCost == null)
  1949. {
  1950. jw.Msg = "暂无三公费用信息!";
  1951. return Ok(jw);
  1952. }
  1953. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1954. rateList ??= new List<CurrencyInfo>();
  1955. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1956. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1957. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1958. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1959. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1960. .Select((x, a, b) => new
  1961. {
  1962. x.Index,
  1963. itemName = a.Name,
  1964. CurrencyStr = b.Name,
  1965. x.Cost,
  1966. x.SubTotal,
  1967. x.Remark
  1968. })
  1969. .OrderBy((x) => x.Index)
  1970. .ToList();
  1971. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1972. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1973. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1974. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1975. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1976. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1977. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1978. decimal subJJC = 0.00M,
  1979. subGWC = 0.00M,
  1980. subTDC = 0.00M;
  1981. //经济舱
  1982. if (groupEnterExitCost.SumJJC == 1)
  1983. {
  1984. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1985. }
  1986. //公务舱
  1987. if (groupEnterExitCost.SumGWC == 1)
  1988. {
  1989. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1990. }
  1991. //头等舱
  1992. if (groupEnterExitCost.SumTDC == 1)
  1993. {
  1994. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1995. }
  1996. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1997. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1998. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1999. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  2000. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  2001. .Select((x, s, dc, cc) => new GroupClints
  2002. {
  2003. Id = x.Id,
  2004. Name = s.Name,
  2005. IsAccompany = x.IsAccompany,
  2006. CompanyFullName = cc.CompanyFullName
  2007. })
  2008. .ToListAsync();
  2009. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  2010. //获取舱位人数
  2011. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2012. .GroupBy(x => x.Name)
  2013. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2014. .ToList();
  2015. string cityPath = string.Empty;
  2016. string startCity = string.Empty;
  2017. string endCity = string.Empty;
  2018. foreach (var item in blackCodeList)
  2019. {
  2020. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2021. cityPath += city + "\r\n";
  2022. if (item.Equals(blackCodeList.First()))
  2023. {
  2024. var sp = city.Split('-');
  2025. startCity = sp[0];
  2026. endCity = sp[^1];
  2027. }
  2028. }
  2029. var bookMarkDic = new Dictionary<string, string>
  2030. {
  2031. { "ClientUnit", di.ClientUnit },
  2032. { "VisitCountry", di.VisitCountry },
  2033. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2034. { "VisitPNumber", di.VisitPNumber.ToString() },
  2035. { "CityPath", cityPath },
  2036. { "StartCity", startCity },
  2037. { "EndCity", endCity },
  2038. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2039. };
  2040. Document doc = null;
  2041. var percentage = 0.8M;
  2042. var fileNameadd = "预付";
  2043. if (dto.FileType == 1)
  2044. {
  2045. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2046. }
  2047. else if (dto.FileType == 2)
  2048. {
  2049. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2050. percentage = 1;
  2051. fileNameadd = "全款";
  2052. }
  2053. else
  2054. {
  2055. throw new Exception("FileType有误!");
  2056. }
  2057. var builder = new DocumentBuilder(doc);
  2058. decimal totalPrice = 0.00M;
  2059. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2060. if (firstTable != null)
  2061. {
  2062. // 遍历表格的行和单元格
  2063. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2064. {
  2065. for (int i = 0; i < row.Cells.Count; i++)
  2066. {
  2067. var cell = row.Cells[i];
  2068. // 读取单元格内容
  2069. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2070. if (cellTextFirst.Contains("舱位"))
  2071. {
  2072. break;
  2073. }
  2074. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2075. {
  2076. if (i == 2)
  2077. {
  2078. if (cellTextFirst == "经济舱")
  2079. {
  2080. // 设置单元格内容
  2081. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2082. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2083. }
  2084. else
  2085. {
  2086. // 设置单元格内容
  2087. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2088. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2089. }
  2090. }
  2091. if (i == 3)
  2092. {
  2093. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2094. if (count != null)
  2095. {
  2096. // 设置单元格内容
  2097. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2098. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2099. }
  2100. }
  2101. if (i == 4)
  2102. {
  2103. var rowPrice = 0.00M;
  2104. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2105. count ??= 0;
  2106. if (cellTextFirst == "经济舱")
  2107. {
  2108. rowPrice = subJJC * (int)count;
  2109. }
  2110. else
  2111. {
  2112. rowPrice = subGWC * (int)count;
  2113. }
  2114. totalPrice += rowPrice;
  2115. // 设置单元格内容
  2116. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2117. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2118. }
  2119. }
  2120. }
  2121. }
  2122. }
  2123. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2124. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2125. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2126. //--合同表格部分
  2127. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2128. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2129. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2130. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2131. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2132. bookMarkDic.Add("CityPath1", cityPath);
  2133. bookMarkDic.Add("CityPath2", cityPath);
  2134. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2135. if (contractTable != null)
  2136. {
  2137. //数据源
  2138. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2139. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2140. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2141. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2142. .Select((it, y, s) => new
  2143. {
  2144. it.Cost,
  2145. it.SubTotal,
  2146. it.Type,
  2147. y.Id,
  2148. y.City,
  2149. s.Name,
  2150. CurrencyCodeCn = s.Remark
  2151. })
  2152. .ToList()
  2153. .Select(x => new
  2154. {
  2155. CurrencyCode = x.Name,
  2156. CityId = x.Id,
  2157. x.City,
  2158. di.VisitPNumber,
  2159. x.Type,
  2160. x.Cost,
  2161. x.SubTotal,
  2162. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2163. x.CurrencyCodeCn,
  2164. });
  2165. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2166. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2167. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2168. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2169. var tableSettings = new List<tableSetting>()
  2170. {
  2171. new(){ Index = 1 , Property = "City"},
  2172. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2173. new(){ Index = 3 , Property = "Cost"},
  2174. new(){ Index = 4 , Property = "VisitPNumber"},
  2175. //new tableSetting{ Index = 5 , Property = ""},
  2176. //new tableSetting{ Index = 6 , Property = ""},
  2177. new(){ Index = 7 , Property = "Rate"},
  2178. //new tableSetting{ Index = 8 , Property = ""},
  2179. };
  2180. //1.住宿费
  2181. int cloneRow = 8;
  2182. int startDayPrice = 8; //写入index
  2183. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2184. foreach (var dac in dac1)
  2185. {
  2186. var first = dac.First();
  2187. var dayCount = dac.Count();
  2188. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2189. for (int i = 1; i < row.Cells.Count; i++)
  2190. {
  2191. var cell = row.Cells[i];
  2192. var findProperty = tableSettings.Find(x => x.Index == i);
  2193. if (findProperty != null)
  2194. {
  2195. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2196. // 设置单元格内容
  2197. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2198. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2199. }
  2200. else
  2201. {
  2202. switch (i)
  2203. {
  2204. case 5:
  2205. cell.FirstParagraph.Runs.Clear();
  2206. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2207. break;
  2208. case 6:
  2209. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2210. cell.FirstParagraph.Runs.Clear();
  2211. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2212. break;
  2213. case 8:
  2214. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2215. cell.FirstParagraph.Runs.Clear();
  2216. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2217. ZSPriceSum += xiaojiRMB;
  2218. break;
  2219. default:
  2220. break;
  2221. }
  2222. }
  2223. }
  2224. startDayPrice++;
  2225. if (!dac1.Last().Equals(dac))
  2226. {
  2227. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2228. // 将克隆的行追加到原行后面
  2229. contractTable.Rows.Insert(startDayPrice, newRow);
  2230. }
  2231. else
  2232. {
  2233. cloneRow += dac1.Count + 1;
  2234. startDayPrice = cloneRow;
  2235. }
  2236. }
  2237. //2.伙食费
  2238. foreach (var dac in dac2)
  2239. {
  2240. var first = dac.First();
  2241. var dayCount = dac.Count();
  2242. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2243. for (int i = 1; i < row.Cells.Count; i++)
  2244. {
  2245. var cell = row.Cells[i];
  2246. var findProperty = tableSettings.Find(x => x.Index == i);
  2247. if (findProperty != null)
  2248. {
  2249. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2250. // 设置单元格内容
  2251. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2252. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2253. }
  2254. else
  2255. {
  2256. switch (i)
  2257. {
  2258. case 5:
  2259. cell.FirstParagraph.Runs.Clear();
  2260. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2261. break;
  2262. case 6:
  2263. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2264. cell.FirstParagraph.Runs.Clear();
  2265. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2266. break;
  2267. case 8:
  2268. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2269. cell.FirstParagraph.Runs.Clear();
  2270. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2271. HSPriceSum += xiaojiRMB;
  2272. break;
  2273. default:
  2274. break;
  2275. }
  2276. }
  2277. }
  2278. startDayPrice++;
  2279. if (!dac2.Last().Equals(dac))
  2280. {
  2281. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2282. // 将克隆的行追加到原行后面
  2283. contractTable.Rows.Insert(startDayPrice, newRow);
  2284. }
  2285. else
  2286. {
  2287. cloneRow += dac2.Count + 1;
  2288. startDayPrice = cloneRow;
  2289. }
  2290. }
  2291. //3.公杂费
  2292. foreach (var dac in dac3)
  2293. {
  2294. var first = dac.First();
  2295. var dayCount = dac.Count();
  2296. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2297. for (int i = 1; i < row.Cells.Count; i++)
  2298. {
  2299. var cell = row.Cells[i];
  2300. var findProperty = tableSettings.Find(x => x.Index == i);
  2301. if (findProperty != null)
  2302. {
  2303. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2304. // 设置单元格内容
  2305. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2306. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2307. }
  2308. else
  2309. {
  2310. switch (i)
  2311. {
  2312. case 5:
  2313. cell.FirstParagraph.Runs.Clear();
  2314. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2315. break;
  2316. case 6:
  2317. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2318. cell.FirstParagraph.Runs.Clear();
  2319. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2320. break;
  2321. case 8:
  2322. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2323. cell.FirstParagraph.Runs.Clear();
  2324. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2325. GZPriceSum += xiaojiRMB;
  2326. break;
  2327. default:
  2328. break;
  2329. }
  2330. }
  2331. }
  2332. startDayPrice++;
  2333. if (!dac3.Last().Equals(dac))
  2334. {
  2335. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2336. // 将克隆的行追加到原行后面
  2337. contractTable.Rows.Insert(startDayPrice, newRow);
  2338. }
  2339. else
  2340. {
  2341. cloneRow += dac3.Count + 1;
  2342. startDayPrice = cloneRow;
  2343. }
  2344. }
  2345. //合并单元格
  2346. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2347. {
  2348. var currentRow = contractTable.Rows[i];
  2349. var nextRow = contractTable.Rows[i + 1];
  2350. // 获取当前行和下一行的第一个单元格
  2351. Cell currentCell = currentRow.Cells[0];
  2352. Cell nextCell = nextRow.Cells[0];
  2353. // 检查单元格内容是否一致(去除尾部的换行符)
  2354. string currentText = currentCell.GetText().Trim();
  2355. string nextText = nextCell.GetText().Trim();
  2356. if (currentText == nextText)
  2357. {
  2358. // 如果当前单元格已经被合并,找到合并的起始单元格
  2359. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2360. {
  2361. // 找到合并的起始单元格
  2362. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2363. // 将下一行的单元格设置为合并的后续单元格
  2364. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2365. }
  2366. else
  2367. {
  2368. // 如果当前单元格是合并的起始单元格
  2369. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2370. // 将下一行的单元格设置为合并的后续单元格
  2371. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2372. }
  2373. }
  2374. else
  2375. {
  2376. // 如果内容不一致,重置当前单元格的合并属性
  2377. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2378. {
  2379. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2380. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2381. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2382. }
  2383. else
  2384. {
  2385. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2386. }
  2387. }
  2388. }
  2389. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2390. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2391. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2392. }
  2393. foreach (var bookmarkName in bookMarkDic.Keys)
  2394. {
  2395. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2396. if (bookmark != null)
  2397. {
  2398. if (bookmarkName == "ClientUnit")
  2399. {
  2400. // 移动到书签位置
  2401. builder.MoveTo(bookmark.BookmarkStart);
  2402. // 设置字体样式为下划线
  2403. builder.Font.Underline = Aspose.Words.Underline.Single;
  2404. // 插入书签值
  2405. builder.Write(bookMarkDic[bookmarkName]);
  2406. // 清除字体格式,避免影响后续文本
  2407. builder.Font.ClearFormatting();
  2408. }
  2409. else
  2410. {
  2411. builder.MoveToBookmark(bookmarkName);
  2412. builder.Write(bookMarkDic[bookmarkName]);
  2413. }
  2414. }
  2415. }
  2416. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2417. doc.Save(savePaht);
  2418. jw.Msg = "生成成功!";
  2419. jw.Code = 200;
  2420. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2421. return Ok(jw);
  2422. }
  2423. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2424. {
  2425. int index = rowIndex;
  2426. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2427. {
  2428. index--;
  2429. }
  2430. return index;
  2431. }
  2432. /// <summary>
  2433. /// 报批完成企微通知
  2434. /// </summary>
  2435. /// <param name="dto"></param>
  2436. /// <returns></returns>
  2437. [HttpPost]
  2438. public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
  2439. {
  2440. int currUserId = dto.currUserId;
  2441. int diid = dto.diid;
  2442. var jw = JsonView(true);
  2443. var users = new List<string>();
  2444. var ssd = _sqlSugar.Queryable<Sys_SetData>()
  2445. .First(x => x.Id == 1460);
  2446. try
  2447. {
  2448. users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
  2449. var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
  2450. //消息通知成功 更改团组step、记录日志
  2451. if (res)
  2452. {
  2453. var groupStep = 0; //0-新建 1-企微消息通知
  2454. //更改团组step
  2455. var updStatus = await _sqlSugar.Updateable<Grp_DelegationInfo>()
  2456. .SetColumns(x => new Grp_DelegationInfo()
  2457. {
  2458. Step = 2
  2459. })
  2460. .Where(x => x.Id == diid && x.IsDel == 0)
  2461. .ExecuteCommandAsync();
  2462. if (updStatus > 0) groupStep = 2;
  2463. string groupStepLabel = groupStep switch
  2464. {
  2465. 1 => "新建",
  2466. 2 => "企微消息通知(报批)",
  2467. _ => "未设置"
  2468. };
  2469. //记录日志
  2470. var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2471. .Where(x => x.Id == diid && x.IsDel == 0)
  2472. .Select(x => x.TeamName)
  2473. .First() ?? "-";
  2474. var operationName = _sqlSugar.Queryable<Sys_Users>()
  2475. .Where(x => x.Id == currUserId && x.IsDel == 0)
  2476. .Select(x => x.CnName)
  2477. .First() ?? "-";
  2478. _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
  2479. //设置 签证流程初始值
  2480. await _visaProcessRep.UpdateBatchTop4Step(dto.diid, dto.currUserId);
  2481. }
  2482. }
  2483. catch (Exception ex)
  2484. {
  2485. return Ok(JsonView(false, ex.Message));
  2486. }
  2487. return Ok(jw);
  2488. }
  2489. #endregion
  2490. #region 团组&签证
  2491. #region 团组&签证 New
  2492. /// <summary>
  2493. /// 团组&签证 New
  2494. /// DeepSeek API:测试API连通性
  2495. /// </summary>
  2496. /// <param name="file">请求dto</param>
  2497. /// <returns></returns>
  2498. [HttpPost]
  2499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2500. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2501. {
  2502. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2503. }
  2504. /// <summary>
  2505. /// 团组&签证 New
  2506. /// DeepSeek API:检查可用端点
  2507. /// </summary>
  2508. /// <param name="file">请求dto</param>
  2509. /// <returns></returns>
  2510. [HttpPost]
  2511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2512. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2513. {
  2514. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2515. }
  2516. /// <summary>
  2517. /// 团组&签证 New
  2518. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2519. /// </summary>
  2520. /// <param name="file">请求dto</param>
  2521. /// <returns></returns>
  2522. [HttpPost]
  2523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2524. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  2525. {
  2526. //文件验证
  2527. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2528. //var visaFiles = new VisaUploadFileTypeView();
  2529. var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2530. if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2531. //服务器存储文件
  2532. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2533. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2534. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  2535. using (var stream = new FileStream(filePath, FileMode.Create))
  2536. {
  2537. await visaFile.CopyToAsync(stream);
  2538. }
  2539. //日志记录-上传文件
  2540. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  2541. IFormFile localFile = null;
  2542. //获取项目中的cs文件
  2543. try
  2544. {
  2545. _logger.LogInformation("读取并上传项目文件请求");
  2546. // 1. 读取项目文件
  2547. var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  2548. if (readResponse.SuccessCount == 0)
  2549. {
  2550. return Ok(JsonView(false, "读取项目文件失败"));
  2551. }
  2552. localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  2553. }
  2554. catch (Exception ex)
  2555. {
  2556. _logger.LogError(ex, "读取项目文件失败");
  2557. return Ok(JsonView(false, "读取项目文件失败"));
  2558. }
  2559. if (localFile == null)
  2560. {
  2561. return Ok(JsonView(false, "读取项目文件失败"));
  2562. }
  2563. var fileReq = new DeepSeekFileUploadRequest()
  2564. {
  2565. Files = new List<IFormFile> { localFile, visaFile },
  2566. };
  2567. var filesResult = new List<FileUploadResult>();
  2568. #region 上传文件到DeepSeekAPI
  2569. try
  2570. {
  2571. _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  2572. filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  2573. // 需要等待处理完成
  2574. if (fileReq.WaitForProcessing)
  2575. {
  2576. foreach (var result in filesResult)
  2577. {
  2578. if (result.Success)
  2579. {
  2580. try
  2581. {
  2582. var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  2583. result.Status = processedFile.Status;
  2584. }
  2585. catch (Exception ex)
  2586. {
  2587. _logger.LogError(ex, "DeepSeek API文件上传失败");
  2588. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2589. }
  2590. }
  2591. }
  2592. }
  2593. }
  2594. catch (Exception ex)
  2595. {
  2596. _logger.LogError(ex, "DeepSeek API文件上传失败");
  2597. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2598. }
  2599. #endregion
  2600. if (filesResult == null || filesResult.Count < 1)
  2601. {
  2602. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  2603. }
  2604. //
  2605. try
  2606. {
  2607. var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  2608. _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  2609. string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  2610. var response = await _deepSeekService.ChatWithFilesAsync(fileIds, question);
  2611. return Ok(response);
  2612. }
  2613. catch (Exception ex)
  2614. {
  2615. _logger.LogError(ex, "使用文件聊天失败");
  2616. return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  2617. }
  2618. //加载文件OpCarTouristGuideGroundContent
  2619. ////kimi AI 识别文档返回json结果
  2620. //int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2621. //var KiMiApi = new KiMiApiClient();
  2622. //var files = new List<IFormFile>() { file };
  2623. //var seedConter = await KiMiApi.UploadFilesAsync(files);
  2624. //if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2625. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2626. //var messages = new List<SeedMessages>
  2627. //{
  2628. // new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2629. // new() { Role = KimiRole.user, Content = seedMessage }
  2630. //};
  2631. //messages.InsertRange(1, seedConter);
  2632. string jsonString = string.Empty;
  2633. //bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2634. //while (!isJson)
  2635. //{
  2636. // kimiAI_API_Index++;
  2637. // var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2638. // var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2639. // jsonString += kimiApiResult_JObject["content"].ToString();
  2640. // string startStr = "```json", endStr = "```";
  2641. // // 判断并清除开头部分
  2642. // if (jsonString.StartsWith(startStr))
  2643. // {
  2644. // jsonString = jsonString.Replace(startStr, "");
  2645. // }
  2646. // // 判断并清除结尾部分
  2647. // if (jsonString.EndsWith(endStr))
  2648. // {
  2649. // jsonString = jsonString.Replace(endStr, "");
  2650. // }
  2651. // //验证json格式是否正确
  2652. // try
  2653. // {
  2654. // JsonDocument.Parse(jsonString);
  2655. // isJson = true; // 如果解析成功,则是json格式
  2656. // }
  2657. // catch (Exception)
  2658. // {
  2659. // //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2660. // messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2661. // }
  2662. //}
  2663. //var clientInfo = new Crm_DeleClient(); //客户资料表
  2664. //var clientFamily = new Crm_VisaCustomerFamily(); //客户家庭表
  2665. //var clientCompany = new Crm_CustomerCompany(); //客户公司表
  2666. //var clientCert = new Crm_CustomerCert(); //客户证件表
  2667. //var clientSchool = new Crm_VisaCustomerSchool(); //客户学历表
  2668. ////按照表格类型分别进行参数处理
  2669. //switch (fileTypeId)
  2670. //{
  2671. // //澳新签证个人申请表
  2672. // case 1:
  2673. // _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2674. // VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2675. // break;
  2676. // default:
  2677. // break;
  2678. //}
  2679. return Ok(JsonView(true, jsonString));
  2680. }
  2681. private int GetSuccessCount(List<FileUploadResult> results)
  2682. {
  2683. var count = 0;
  2684. foreach (var result in results)
  2685. {
  2686. if (result.Success) count++;
  2687. }
  2688. return count;
  2689. }
  2690. #endregion
  2691. /// <summary>
  2692. /// 根据团组Id获取签证客户信息List
  2693. /// </summary>
  2694. /// <param name="dto">请求dto</param>
  2695. /// <returns></returns>
  2696. [HttpPost]
  2697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2698. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2699. {
  2700. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2701. if (groupData.Code != 0)
  2702. {
  2703. return Ok(JsonView(false, groupData.Msg));
  2704. }
  2705. return Ok(JsonView(groupData.Data));
  2706. }
  2707. /// <summary>
  2708. /// IOS获取团组签证拍照上传进度01(团组列表)
  2709. /// </summary>
  2710. /// <param name="dto">请求dto</param>
  2711. /// <returns></returns>
  2712. [HttpPost]
  2713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2714. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2715. {
  2716. if (dto == null)
  2717. {
  2718. return Ok(JsonView(false, "参数为空"));
  2719. }
  2720. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2721. return Ok(JsonView(visaList));
  2722. }
  2723. /// <summary>
  2724. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2725. /// </summary>
  2726. /// <returns></returns>
  2727. [HttpPost]
  2728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2729. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2730. {
  2731. if (dto == null)
  2732. {
  2733. return Ok(JsonView(false, "请求错误:"));
  2734. }
  2735. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2736. return Ok(JsonView(list));
  2737. }
  2738. /// <summary>
  2739. /// IOS获取团组签证拍照上传进度03(相册)
  2740. /// </summary>
  2741. /// <returns></returns>
  2742. [HttpPost]
  2743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2744. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2745. {
  2746. if (dto == null)
  2747. {
  2748. return Ok(JsonView(false, "请求错误:"));
  2749. }
  2750. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2751. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2752. list.ForEach(s => s.url = url);
  2753. return Ok(JsonView(list));
  2754. }
  2755. /// <summary>
  2756. /// IOS获取团组签证拍照上传进度04(图片上传)
  2757. /// </summary>
  2758. /// <param name="dto"></param>
  2759. /// <returns></returns>
  2760. [HttpPost]
  2761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2762. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2763. {
  2764. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2765. //if (!string.IsNullOrEmpty(result))
  2766. //{
  2767. //}
  2768. //else {
  2769. // return Ok(JsonView(false, "上传失败"));
  2770. //}
  2771. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2772. int sucNum = 0;
  2773. try
  2774. {
  2775. foreach (var item in dto.base64DataList)
  2776. {
  2777. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2778. string result = DecodeBase64ToImage(item, imageName);
  2779. if (!string.IsNullOrEmpty(result))
  2780. {
  2781. var pic = new Grp_VisaProgressCustomerPicture
  2782. {
  2783. CreateUserId = dto.CreateUserId,
  2784. PicName = imageName,
  2785. PicPath = result,
  2786. VisaProgressCustomerId = dto.visaProgressCustomerId
  2787. };
  2788. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2789. if (insertResult > 0)
  2790. {
  2791. sucNum++;
  2792. }
  2793. }
  2794. }
  2795. }
  2796. catch (Exception ex)
  2797. {
  2798. return Ok(JsonView(false, ex.Message));
  2799. }
  2800. string msg = string.Format(@"成功上传{0}张", sucNum);
  2801. return Ok(JsonView(true, msg));
  2802. }
  2803. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2804. {
  2805. string filename = "";//声明一个string类型的相对路径
  2806. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2807. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2808. try//会有异常抛出,try,catch一下
  2809. {
  2810. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2811. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2812. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2813. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2814. //文件名称
  2815. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2816. //上传的文件的路径
  2817. string filePath = "";
  2818. if (!Directory.Exists(fileDir))
  2819. {
  2820. Directory.CreateDirectory(fileDir);
  2821. }
  2822. //上传的文件的路径
  2823. filePath = fileDir + filename;
  2824. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2825. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2826. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2827. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2828. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2829. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2830. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2831. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2832. bitmap.Dispose();
  2833. }
  2834. catch (Exception e)
  2835. {
  2836. string massage = e.Message;
  2837. Logs("IOS图片上传Error:" + massage);
  2838. //filename = e.Message;
  2839. }
  2840. return filename;//返回相对路径
  2841. }
  2842. /// <summary>
  2843. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2844. /// </summary>
  2845. /// <param name="dto"></param>
  2846. /// <returns></returns>
  2847. [HttpPost]
  2848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2849. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2850. {
  2851. if (dto == null)
  2852. {
  2853. return Ok(JsonView(false, "请求错误:"));
  2854. }
  2855. string msg = "参数错误";
  2856. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2857. {
  2858. try
  2859. {
  2860. //_delegationVisaRep.BeginTran();
  2861. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2862. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2863. .Where(s => s.Id == dto.visaProgressCustomerId)
  2864. .ExecuteCommandAsync();
  2865. if (updCount > 0 && dto.publishCode == 1)
  2866. {
  2867. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2868. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2869. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2870. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2871. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2872. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2873. if (groupData == null)
  2874. {
  2875. _delegationVisaRep.RollbackTran();
  2876. }
  2877. string title = string.Format(@"[签证进度更新]");
  2878. string content = string.Format(@"测试文本");
  2879. bool rst = await _message.AddMsg(new MessageDto()
  2880. {
  2881. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2882. IssuerId = dto.publisher,
  2883. Title = title,
  2884. Content = content,
  2885. ReleaseTime = DateTime.Now,
  2886. UIdList = new List<int> {
  2887. 234
  2888. }
  2889. });
  2890. if (rst)
  2891. {
  2892. return Ok(JsonView(true, "发送通知成功"));
  2893. }
  2894. }
  2895. //_delegationVisaRep.CommitTran();
  2896. }
  2897. catch (Exception)
  2898. {
  2899. //_delegationVisaRep.RollbackTran();
  2900. }
  2901. }
  2902. return Ok(JsonView(true, msg));
  2903. }
  2904. #endregion
  2905. #region 团组任务分配
  2906. /// <summary>
  2907. /// 团组任务分配初始化
  2908. /// </summary>
  2909. /// <returns></returns>
  2910. [HttpPost]
  2911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2912. public async Task<IActionResult> GetTaskAssignmen()
  2913. {
  2914. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2915. if (groupData.Code != 0)
  2916. {
  2917. return Ok(JsonView(false, groupData.Msg));
  2918. }
  2919. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2920. }
  2921. /// <summary>
  2922. /// 团组任务分配查询
  2923. /// </summary>
  2924. /// <param name="dto"></param>
  2925. /// <returns></returns>
  2926. [HttpPost]
  2927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2928. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2929. {
  2930. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2931. if (groupData.Code != 0)
  2932. {
  2933. return Ok(JsonView(false, groupData.Msg));
  2934. }
  2935. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2936. }
  2937. /// <summary>
  2938. /// 团组任务分配操作
  2939. /// </summary>
  2940. /// <param name="dto"></param>
  2941. /// <returns></returns>
  2942. [HttpPost]
  2943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2944. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2945. {
  2946. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2947. if (groupData.Code != 0)
  2948. {
  2949. return Ok(JsonView(false, groupData.Msg));
  2950. }
  2951. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2952. }
  2953. /// <summary>
  2954. /// 团组任务分配
  2955. /// 批量分配
  2956. /// 查询团组
  2957. /// </summary>
  2958. /// <param name="dto"></param>
  2959. /// <returns></returns>
  2960. [HttpPost]
  2961. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2962. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2963. {
  2964. //参数验证
  2965. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2966. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2967. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2968. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2969. }
  2970. /// <summary>
  2971. /// 团组任务分配
  2972. /// 批量分配
  2973. /// </summary>
  2974. /// <param name="dto"></param>
  2975. /// <returns></returns>
  2976. [HttpPost]
  2977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2978. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2979. {
  2980. //参数验证
  2981. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2982. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2983. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2984. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2985. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2986. }
  2987. #endregion
  2988. #region 团组费用审核
  2989. /// <summary>
  2990. /// 费用审核
  2991. /// 团组列表 Page
  2992. /// </summary>
  2993. /// <param name="_dto">团组列表请求dto</param>
  2994. /// <returns></returns>
  2995. [HttpPost]
  2996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2997. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2998. {
  2999. #region 参数验证
  3000. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3001. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3002. #region 页面操作权限验证
  3003. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3004. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3005. #endregion
  3006. #endregion
  3007. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  3008. {
  3009. string sqlWhere = string.Empty;
  3010. if (_dto.IsSure == 0) //未完成
  3011. {
  3012. sqlWhere += string.Format(@" And IsSure = 0");
  3013. }
  3014. else if (_dto.IsSure == 1) //已完成
  3015. {
  3016. sqlWhere += string.Format(@" And IsSure = 1");
  3017. }
  3018. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  3019. {
  3020. string tj = _dto.SearchCriteria;
  3021. 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}%')",
  3022. tj, tj, tj, tj, tj);
  3023. }
  3024. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3025. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  3026. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3027. From (
  3028. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  3029. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  3030. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  3031. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3032. From Grp_DelegationInfo gdi
  3033. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3034. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3035. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3036. Where gdi.IsDel = 0 {0}
  3037. ) temp ", sqlWhere);
  3038. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3039. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  3040. var _view = new
  3041. {
  3042. PageFuncAuth = pageFunAuthView,
  3043. Data = _DelegationList
  3044. };
  3045. return Ok(JsonView(true, "查询成功!", _view, total));
  3046. }
  3047. else
  3048. {
  3049. return Ok(JsonView(false, "查询失败"));
  3050. }
  3051. }
  3052. /// <summary>
  3053. /// 获取团组费用审核
  3054. /// </summary>
  3055. /// <param name="_dto"></param>
  3056. /// <returns></returns>
  3057. [HttpPost]
  3058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3059. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  3060. {
  3061. try
  3062. {
  3063. #region 参数验证
  3064. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3065. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3066. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  3067. #region 页面操作权限验证
  3068. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3069. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3070. #endregion
  3071. #endregion
  3072. var _view = new Grp_CreditCardPaymentView();
  3073. var clientNameList = GetSimplClientList(_dto.DiId);
  3074. #region 费用清单
  3075. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  3076. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  3077. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  3078. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  3079. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  3080. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  3081. /*
  3082. * 76://酒店预订
  3083. */
  3084. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3085. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3086. /*
  3087. * 79://车/导游地接
  3088. */
  3089. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3090. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3091. /*
  3092. * 80: //签证
  3093. */
  3094. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3095. /*
  3096. *81: //邀请/公务活动
  3097. */
  3098. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3099. /*
  3100. * 82: //团组客户保险
  3101. */
  3102. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3103. /*
  3104. * Lable = 85 机票预订
  3105. */
  3106. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3107. /*
  3108. * 85 机票预定
  3109. */
  3110. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3111. /*
  3112. * 98 其他款项
  3113. */
  3114. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3115. /*
  3116. * 285:收款退还
  3117. */
  3118. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3119. /*
  3120. * 1015: //超支费用
  3121. */
  3122. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3123. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  3124. /*
  3125. * 币种信息
  3126. */
  3127. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  3128. /*
  3129. * 车/导游地接 费用类型
  3130. */
  3131. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  3132. /*
  3133. * 车/导游地接 费用类型
  3134. */
  3135. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  3136. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  3137. /*
  3138. * 用户信息
  3139. */
  3140. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  3141. /*
  3142. * 费用模块
  3143. */
  3144. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  3145. string priceModule = string.Empty;
  3146. if (sdPriceName != null)
  3147. {
  3148. priceModule = sdPriceName.Name;
  3149. }
  3150. /*
  3151. * 成本信息
  3152. */
  3153. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  3154. decimal _groupRate = 0.0000M;
  3155. string _groupCurrencyCode = "-";
  3156. if (groupCost != null)
  3157. {
  3158. _groupRate = groupCost.Rate;
  3159. if (int.TryParse(groupCost.Currency, out int _currency))
  3160. {
  3161. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  3162. }
  3163. else _groupCurrencyCode = groupCost.Currency;
  3164. }
  3165. string costContentSql = $"Select * From Grp_GroupCost";
  3166. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  3167. //处理日期为空的天数
  3168. for (int i = 0; i < groupCostDetails.Count; i++)
  3169. if (i != 0)
  3170. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  3171. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  3172. /*
  3173. * 处理详情数据
  3174. */
  3175. foreach (var entity in entityList)
  3176. {
  3177. var _detail = new Grp_CreditCardPaymentDetailView
  3178. {
  3179. Id = entity.Id,
  3180. PriceName = priceModule,
  3181. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  3182. };
  3183. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3184. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  3185. //处理金额
  3186. if (entity.CTable == 1015)
  3187. {
  3188. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  3189. if (czInfo != null)
  3190. {
  3191. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3192. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3193. }
  3194. }
  3195. /*
  3196. * 应付款金额
  3197. */
  3198. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3199. string PaymentCurrency_WaitPay = "Unknown";
  3200. string hotelCurrncyCode = "Unknown";
  3201. string hotelCurrncyName = "Unknown";
  3202. if (sdPaymentCurrency_WaitPay != null)
  3203. {
  3204. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3205. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3206. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3207. if (hotelCurrncyCode.Equals("CNY"))
  3208. {
  3209. entity.DayRate = 1.0000M;
  3210. }
  3211. }
  3212. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3213. /*
  3214. * 此次付款金额
  3215. */
  3216. decimal CurrPayStr = 0.00M,
  3217. OriginalCurrPay = 0.00M;
  3218. if (entity.PayPercentage == 0)
  3219. {
  3220. if (entity.PayThenMoney != 0)
  3221. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3222. }
  3223. else
  3224. {
  3225. if (entity.PayMoney != 0)
  3226. {
  3227. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3228. }
  3229. }
  3230. //if (_dto.Label == 79)
  3231. //{
  3232. // string original = string.Empty;
  3233. // if (hotelCurrncyCode.Equals("CNY"))
  3234. // {
  3235. // OriginalCurrPay = CurrPayStr;
  3236. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3237. // }
  3238. // else
  3239. // {
  3240. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3241. // //760 EUR(7600.00 CNY)
  3242. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3243. // }
  3244. //}
  3245. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3246. string original = string.Empty;
  3247. if (hotelCurrncyCode.Equals("CNY"))
  3248. {
  3249. OriginalCurrPay = CurrPayStr;
  3250. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3251. }
  3252. else
  3253. {
  3254. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3255. //760 EUR(7600.00 CNY)
  3256. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3257. }
  3258. /*
  3259. * 剩余尾款
  3260. */
  3261. decimal BalanceStr = 0;
  3262. if (CurrPayStr != 0)
  3263. {
  3264. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3265. BalanceStr = 0;
  3266. else
  3267. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3268. }
  3269. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3270. /*
  3271. * Bus名称
  3272. */
  3273. _detail.BusName = "待增加";
  3274. /*
  3275. *费用所属
  3276. */
  3277. switch (entity.CTable)
  3278. {
  3279. case 76://酒店预订
  3280. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3281. if (hotelReservations != null)
  3282. {
  3283. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3284. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3285. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3286. string roomFeeStr = "", roomFeestr1 = "";
  3287. //是否比较房型价格
  3288. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3289. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3290. roomFeeStr += $"<br/>";
  3291. var roomTotal = 0.00M;
  3292. if (hotelReservations.SingleRoomPrice > 0)
  3293. {
  3294. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3295. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3296. //__isSingle = true;
  3297. roomTotal += fee;
  3298. }
  3299. if (hotelReservations.DoubleRoomPrice > 0)
  3300. {
  3301. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3302. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3303. // __isDouble = true;
  3304. roomTotal += fee;
  3305. }
  3306. if (hotelReservations.SuiteRoomPrice > 0)
  3307. {
  3308. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3309. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3310. //__isSuite = true;
  3311. roomTotal += fee;
  3312. }
  3313. if (hotelReservations.OtherRoomPrice > 0)
  3314. {
  3315. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3316. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3317. //__isOther = true;
  3318. roomTotal += fee;
  3319. }
  3320. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3321. else roomFeeStr += " 0.00 * 0";
  3322. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3323. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3324. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3325. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3326. /*
  3327. * 费用类型
  3328. * 1:房费
  3329. * 2:早餐
  3330. * 3:地税
  3331. * 4:城市税
  3332. * </summary>
  3333. */
  3334. //地税
  3335. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3336. if (governmentRentData != null)
  3337. {
  3338. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3339. governmentRentFee = governmentRentData.Price;
  3340. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3341. if (governmentRentCurrData != null)
  3342. {
  3343. governmentRentCode = governmentRentCurrData.Name;
  3344. governmentRentName = $"({governmentRentCurrData.Remark})";
  3345. }
  3346. }
  3347. //城市税
  3348. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3349. if (cityTaxData != null)
  3350. {
  3351. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3352. cityTaxFee = cityTaxData.Price;
  3353. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3354. if (cityTaxCurrData != null)
  3355. {
  3356. cityTaxCode = cityTaxCurrData.Name;
  3357. cityTaxName = $"({cityTaxCurrData.Remark})";
  3358. }
  3359. }
  3360. //酒店早餐
  3361. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3362. if (breakfastData != null)
  3363. {
  3364. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3365. breakfastFee = breakfastData.Price;
  3366. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3367. if (breakfastCurrData != null)
  3368. {
  3369. breakfastCode = breakfastCurrData.Name;
  3370. breakfastName = $"({breakfastCurrData.Remark})";
  3371. }
  3372. }
  3373. //房间费用
  3374. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3375. if (roomData != null)
  3376. {
  3377. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3378. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3379. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3380. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3381. roomFee = roomData.Price;
  3382. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3383. if (roomCurrData != null)
  3384. {
  3385. roomCode = roomCurrData.Name;
  3386. roomName = $"({roomCurrData.Remark})";
  3387. }
  3388. }
  3389. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3390. string hotelCostStr = "";
  3391. decimal hotelCsotTotal = 0.00M;
  3392. if (groupCost != null)
  3393. {
  3394. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3395. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3396. }
  3397. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3398. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3399. string hotelCost_day = "";
  3400. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3401. foreach (var item in hotelCostDetails1)
  3402. {
  3403. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3404. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3405. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3406. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3407. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3408. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3409. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3410. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3411. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3412. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3413. hotelCost_day += @$"<br/>";
  3414. }
  3415. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3416. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3417. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3418. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3419. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3420. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3421. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3422. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3423. $"房间说明: {hotelReservations.Remark} <br/>" +
  3424. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3425. $"{hotelBreakfastStr}" +
  3426. $"{hotelGovernmentRentStr}" +
  3427. $"{hotelCityTaxStr}";
  3428. _detail.PriceNameContent = hotelReservations.HotelName;
  3429. }
  3430. break;
  3431. case 79://车/导游地接
  3432. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3433. if (touristGuideGroundReservations != null)
  3434. {
  3435. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3436. {
  3437. _detail.BusName = touristGuideGroundReservations.BusName;
  3438. }
  3439. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3440. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3441. //if (isInt)
  3442. //{
  3443. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3444. // if (cityInfo != null)
  3445. // {
  3446. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3447. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3448. // if (carFeeItem != null)
  3449. // {
  3450. // nameContent += $@"({carFeeItem.Name})";
  3451. // }
  3452. // _detail.PriceNameContent = nameContent;
  3453. // }
  3454. //}
  3455. //else
  3456. //{
  3457. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3458. //}
  3459. var touristGuideGroundReservationsContents =
  3460. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3461. var opContent_sb = new StringBuilder();
  3462. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3463. opContent_sb.AppendLine(contetTitle);
  3464. foreach (var item in touristGuideGroundReservationsContents)
  3465. {
  3466. string typeName = "Unknown";
  3467. string carCurrencyCode = "Unknown";
  3468. string carCurrencyName = "Unknown";
  3469. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3470. if (carTypeData != null) typeName = carTypeData.Name;
  3471. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3472. if (currencyData != null)
  3473. {
  3474. carCurrencyCode = currencyData.Name;
  3475. carCurrencyName = currencyData.Remark;
  3476. }
  3477. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3478. bool IsCurrencyAgreement = false;
  3479. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3480. string opCostStr = string.Empty;
  3481. decimal opCostTypePrice = 0.00M;
  3482. #region 处理成本各项费用
  3483. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3484. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3485. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3486. costOPFeeCNY = 0.00M, //团组成本 op费用
  3487. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3488. if (opCost.Count > 0)
  3489. {
  3490. switch (item.SId)
  3491. {
  3492. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3493. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3494. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3495. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3496. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3497. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3498. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3499. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3500. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3501. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3502. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3503. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3504. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3505. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3506. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3507. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3508. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3509. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3510. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3511. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3512. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3513. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3514. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3515. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3516. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3517. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3518. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3519. }
  3520. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3521. costOPFeeCNY = opCostTypePrice * _groupRate;
  3522. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3523. }
  3524. #endregion
  3525. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3526. aduitOPFeeCNY = item.Price * entity.DayRate;
  3527. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3528. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3529. $"{opTypeStr} {opCostStr}<br/>" +
  3530. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3531. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3532. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3533. {
  3534. if (IsCurrencyAgreement)
  3535. {
  3536. if (item.Price > opCostTypePrice)
  3537. {
  3538. opContent_sb.Append("<span style='color:red;'>");
  3539. opContent_sb.Append(opContent);
  3540. opContent_sb.Append("</span>");
  3541. opContent_sb.AppendLine();
  3542. }
  3543. else
  3544. {
  3545. opContent_sb.Append(opContent);
  3546. opContent_sb.AppendLine();
  3547. }
  3548. }
  3549. else
  3550. {
  3551. //验证是否超成本 按付款比例计算
  3552. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3553. {
  3554. opContent_sb.Append("<span style='color:red;'>");
  3555. opContent_sb.Append(opContent);
  3556. opContent_sb.Append("</span>");
  3557. opContent_sb.AppendLine();
  3558. }
  3559. else
  3560. {
  3561. opContent_sb.Append(opContent);
  3562. opContent_sb.AppendLine();
  3563. }
  3564. }
  3565. }
  3566. else
  3567. {
  3568. opContent_sb.Append(opContent);
  3569. opContent_sb.AppendLine();
  3570. }
  3571. }
  3572. _detail.PriceMsgContent = opContent_sb.ToString();
  3573. }
  3574. break;
  3575. case 80: //签证
  3576. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3577. if (visaInfo != null)
  3578. {
  3579. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  3580. _detail.PriceNameContent = visaInfo.VisaDescription;
  3581. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3582. }
  3583. break;
  3584. case 81: //邀请/公务活动
  3585. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3586. if (_ioa != null)
  3587. {
  3588. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3589. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3590. sendCurrName = "Unknown", //快递费用币种 Name
  3591. sendCurrCode = "Unknown", //快递费用币种 Code
  3592. eventsCurrName = "Unknown", //公务活动费币种 Name
  3593. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3594. translateCurrName = "Unknown", //公务翻译费 Name
  3595. translateCurrCode = "Unknown"; //公务翻译费 Code
  3596. #region 处理费用币种
  3597. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3598. if (inviteCurrData != null)
  3599. {
  3600. inviteCurrName = inviteCurrData.Remark;
  3601. inviteCurrCode = inviteCurrData.Name;
  3602. }
  3603. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3604. if (sendCurrData != null)
  3605. {
  3606. sendCurrName = sendCurrData.Remark;
  3607. sendCurrCode = sendCurrData.Name;
  3608. }
  3609. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3610. if (eventsCurrData != null)
  3611. {
  3612. eventsCurrName = eventsCurrData.Remark;
  3613. eventsCurrCode = eventsCurrData.Name;
  3614. }
  3615. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3616. if (translateCurrData != null)
  3617. {
  3618. translateCurrName = translateCurrData.Remark;
  3619. translateCurrCode = translateCurrData.Name;
  3620. }
  3621. #endregion
  3622. _detail.PriceNameContent = _ioa.InviterArea;
  3623. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  3624. List<string> priceExpNames = new List<string>();
  3625. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  3626. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  3627. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  3628. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  3629. if (priceExpNames != null && priceExpNames.Count > 0)
  3630. {
  3631. _detail.PriceNameContent += $"({string.Join("+", priceExpNames)})";
  3632. }
  3633. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3634. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3635. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3636. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3637. $@"备注:" + _ioa.Remark + "<br/>";
  3638. }
  3639. break;
  3640. case 82: //团组客户保险
  3641. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3642. if (customers != null)
  3643. {
  3644. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3645. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3646. }
  3647. break;
  3648. case 85: //机票预订
  3649. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3650. if (jpRes != null)
  3651. {
  3652. string FlightsDescription = jpRes.FlightsDescription;
  3653. string PriceDescription = jpRes.PriceDescription;
  3654. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3655. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3656. }
  3657. break;
  3658. case 98://其他款项
  3659. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3660. if (gdpRes != null)
  3661. {
  3662. //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/";
  3663. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  3664. //{
  3665. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  3666. //}
  3667. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3668. _detail.PriceNameContent = gdpRes.PriceName;
  3669. }
  3670. break;
  3671. case 285://收款退还
  3672. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3673. if (refundAndOtherMoney != null)
  3674. {
  3675. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3676. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3677. }
  3678. break;
  3679. case 751://酒店早餐
  3680. break;
  3681. case 1015://超支费用
  3682. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3683. if (groupExtraCost != null)
  3684. {
  3685. _detail.PriceNameContent = groupExtraCost.PriceName;
  3686. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3687. }
  3688. break;
  3689. default:
  3690. break;
  3691. }
  3692. /*
  3693. * 申请人
  3694. */
  3695. string operatorName = " - ";
  3696. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3697. if (_opUser != null)
  3698. {
  3699. operatorName = _opUser.CnName;
  3700. }
  3701. _detail.OperatorName = operatorName;
  3702. /*
  3703. * 审核人
  3704. */
  3705. string auditOperatorName = " - ";
  3706. if (entity.IsAuditGM != 0)
  3707. {
  3708. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3709. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3710. else
  3711. {
  3712. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3713. if (_adUser != null)
  3714. {
  3715. auditOperatorName = _adUser.CnName;
  3716. }
  3717. }
  3718. }
  3719. _detail.AuditOperatorName = auditOperatorName;
  3720. /*
  3721. * 超预算比例
  3722. */
  3723. string overBudgetStr = "";
  3724. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3725. else if (entity.ExceedBudget == 0)
  3726. {
  3727. if (entity.CTable == 76 || entity.CTable == 79)
  3728. {
  3729. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3730. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3731. }
  3732. else
  3733. {
  3734. overBudgetStr = "未超预算";
  3735. }
  3736. }
  3737. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3738. _detail.OverBudget = overBudgetStr;
  3739. decimal auditFee = 0.00M; //已审核金额 人名币
  3740. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3741. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3742. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3743. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3744. {
  3745. auditedFeeOriginal = entity.PayMoney;
  3746. auditFee = CurrPayStr;
  3747. }
  3748. else if (entity.IsAuditGM == 0)
  3749. {
  3750. unAuditFeeCNY = CurrPayStr;
  3751. unAuditFeeOriginal = OriginalCurrPay;
  3752. OriginalCurrPay = 0.00M;
  3753. }
  3754. /*
  3755. * 费用总计
  3756. */
  3757. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3758. {
  3759. CurrencyId = entity.PaymentCurrency,
  3760. CurrencyName = PaymentCurrency_WaitPay,
  3761. AmountPayable = entity.PayMoney,
  3762. ThisPayment = OriginalCurrPay,
  3763. BalancePayment = BalanceStr,
  3764. AuditedFunds = auditFee,
  3765. AuditedFundsOriginal = auditedFeeOriginal,
  3766. UnAuditFundsCNY = unAuditFeeCNY,
  3767. UnAuditFundsOriginal = unAuditFeeOriginal
  3768. });
  3769. _detail.IsAuditGM = entity.IsAuditGM;
  3770. detailList.Add(_detail);
  3771. }
  3772. #endregion
  3773. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3774. /*
  3775. * 下方描述处理
  3776. */
  3777. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3778. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3779. if (ccpCurrencyPrice != null)
  3780. {
  3781. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3782. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3783. }
  3784. else
  3785. {
  3786. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3787. }
  3788. string amountPayableStr = string.Format(@"应付款总金额: ");
  3789. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3790. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3791. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3792. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3793. foreach (var item in nonDuplicat)
  3794. {
  3795. var currencyName = item.CurrencyName;
  3796. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3797. if (strs.Count > 0)
  3798. {
  3799. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3800. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3801. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3802. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3803. //单独处理此次付款金额
  3804. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3805. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3806. //单独处理已审核费用
  3807. //if (item.CurrencyId == 836) //人民币
  3808. //{
  3809. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3810. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3811. //}
  3812. //else
  3813. //{
  3814. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3815. //}
  3816. if (currencyName.Equals("CNY"))
  3817. {
  3818. //已审核费用
  3819. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3820. //未审核费用
  3821. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3822. }
  3823. else
  3824. {
  3825. //已审核费用
  3826. 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"));
  3827. //未审核费用
  3828. 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"));
  3829. }
  3830. }
  3831. }
  3832. _view.TotalStr1 = amountPayableStr[..^1];
  3833. _view.TotalStr2 = thisPaymentStr[..^1];
  3834. _view.TotalStr3 = balancePaymentStr[..^1];
  3835. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3836. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3837. var _view1 = new
  3838. {
  3839. PageFuncAuth = pageFunAuthView,
  3840. Data = _view
  3841. };
  3842. return Ok(JsonView(_view1));
  3843. }
  3844. catch (Exception ex)
  3845. {
  3846. return Ok(JsonView(false, ex.Message));
  3847. }
  3848. }
  3849. /// <summary>
  3850. /// 费用审核
  3851. /// 修改团组费用审核状态
  3852. /// </summary>
  3853. /// <param name="_dto">参数Json字符串</param>
  3854. /// <returns></returns>
  3855. [HttpPost]
  3856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3857. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3858. {
  3859. #region 参数验证
  3860. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3861. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3862. #endregion
  3863. #region 页面操作权限验证
  3864. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3865. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3866. #endregion
  3867. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3868. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3869. DateTime dtNow = DateTime.Now;
  3870. _groupRepository.BeginTran();
  3871. int rst = 0;
  3872. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3873. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3874. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3875. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3876. var msgDatas = new List<dynamic>();
  3877. var dic_ccp_user = new Dictionary<int, int>() { };
  3878. foreach (var item in idList)
  3879. {
  3880. int CreditId = int.Parse(item);
  3881. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3882. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3883. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3884. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3885. .Where(s => s.Id == CreditId)
  3886. .ExecuteCommandAsync();
  3887. if (result < 1)
  3888. {
  3889. rst = -1;
  3890. _groupRepository.RollbackTran();
  3891. return Ok(JsonView(false, "操作失败并回滚!"));
  3892. }
  3893. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3894. if (creditData != null)
  3895. {
  3896. #region 应用通知配置
  3897. try
  3898. {
  3899. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3900. }
  3901. catch (Exception ex)
  3902. {
  3903. }
  3904. #endregion
  3905. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3906. string groupNameStr = string.Empty;
  3907. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3908. if (groupData != null) groupNameStr = groupData.TeamName;
  3909. string creditTypeStr = string.Empty;
  3910. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3911. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3912. string creditCurrency = string.Empty;
  3913. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3914. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3915. if (creditCurrency.Equals("CNY"))
  3916. {
  3917. creditData.DayRate = 1.0000M;
  3918. }
  3919. if (creditData.PayPercentage == 0.00M)
  3920. {
  3921. creditData.PayPercentage = 100M;
  3922. }
  3923. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3924. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3925. string msgContent = "";
  3926. if (creditCurrency.Equals("CNY"))
  3927. {
  3928. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3929. }
  3930. else
  3931. {
  3932. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3933. }
  3934. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3935. }
  3936. }
  3937. if (rst == 0)
  3938. {
  3939. _groupRepository.CommitTran();
  3940. foreach (var item in msgDatas)
  3941. {
  3942. //发送消息
  3943. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3944. }
  3945. #region 应用推送
  3946. try
  3947. {
  3948. foreach (var ccpId in dic_ccp_user.Keys)
  3949. {
  3950. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3951. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3952. }
  3953. }
  3954. catch (Exception)
  3955. {
  3956. }
  3957. #endregion
  3958. return Ok(JsonView(true, "操作成功!"));
  3959. }
  3960. return Ok(JsonView(false, "操作失败!"));
  3961. }
  3962. /// <summary>
  3963. /// 费用审核
  3964. /// 其他款项 文件下载
  3965. /// </summary>
  3966. /// <param name="id">其他款项 主键编号</param>
  3967. /// <returns></returns>
  3968. [HttpGet("{id}")]
  3969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3970. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  3971. {
  3972. //网站域名
  3973. 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/";
  3974. var otherInfo = await _decreasePaymentsRep._sqlSugar
  3975. .Queryable<Grp_DecreasePayments>()
  3976. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  3977. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  3978. .Select((x, y) => new
  3979. {
  3980. x.Id,
  3981. x.FilePath
  3982. })
  3983. .FirstAsync();
  3984. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  3985. {
  3986. var url = $"{baseUrl}{otherInfo.FilePath}";
  3987. return Ok(JsonView(true, "操作成功!", url));
  3988. }
  3989. return Ok(JsonView(false, "暂无附件"));
  3990. }
  3991. #endregion
  3992. #region 机票费用录入
  3993. /// <summary>
  3994. /// 机票录入当前登录人可操作团组
  3995. /// </summary>
  3996. /// <param name="dto"></param>
  3997. /// <returns></returns>
  3998. [HttpPost]
  3999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4000. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  4001. {
  4002. try
  4003. {
  4004. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  4005. if (groupData.Code != 0)
  4006. {
  4007. return Ok(JsonView(false, groupData.Msg));
  4008. }
  4009. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4010. }
  4011. catch (Exception ex)
  4012. {
  4013. return Ok(JsonView(false, ex.Message));
  4014. }
  4015. }
  4016. /// <summary>
  4017. /// 机票费用录入列表
  4018. /// </summary>
  4019. /// <param name="dto"></param>
  4020. /// <returns></returns>
  4021. [HttpPost]
  4022. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4023. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  4024. {
  4025. try
  4026. {
  4027. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  4028. if (groupData.Code != 0)
  4029. {
  4030. return Ok(JsonView(false, groupData.Msg));
  4031. }
  4032. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4033. }
  4034. catch (Exception ex)
  4035. {
  4036. return Ok(JsonView(false, ex.Message));
  4037. throw;
  4038. }
  4039. }
  4040. /// <summary>
  4041. /// 根据id查询费用录入信息
  4042. /// </summary>
  4043. /// <param name="dto"></param>
  4044. /// <returns></returns>
  4045. [HttpPost]
  4046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4047. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  4048. {
  4049. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  4050. if (groupData.Code != 0)
  4051. {
  4052. return Ok(JsonView(false, groupData.Msg));
  4053. }
  4054. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4055. }
  4056. /// <summary>
  4057. /// 机票费用录入操作(Status:1.新增,2.修改)
  4058. /// </summary>
  4059. /// <param name="dto"></param>
  4060. /// <returns></returns>
  4061. [HttpPost]
  4062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4063. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  4064. {
  4065. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  4066. if (groupData.Code != 0)
  4067. {
  4068. return Ok(JsonView(false, groupData.Msg));
  4069. }
  4070. #region 应用推送
  4071. try
  4072. {
  4073. var diId = dto.AirTicketResOpData.DiId;
  4074. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4075. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4076. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4077. //自动审核
  4078. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  4079. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  4080. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  4081. $"GroupId:{diId};airId:{dataId};",
  4082. status,
  4083. auditMsg);
  4084. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4085. //2024-10-21 新增LZ UID
  4086. var userIds = new List<int>() { 21 };
  4087. string title = $"系统通知";
  4088. string content = "";
  4089. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4090. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4091. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4092. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4093. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4094. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  4095. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4096. }
  4097. catch (Exception ex)
  4098. {
  4099. }
  4100. #endregion
  4101. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4102. }
  4103. /// <summary>
  4104. /// 机票费用自动审核 AI识别方式
  4105. /// </summary>
  4106. /// <returns></returns>
  4107. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  4108. {
  4109. var ecoTypeIds = new List<int>() {
  4110. 459, //超经舱
  4111. 460, //经济舱
  4112. 1430, //公务舱(实际经济舱)
  4113. 1432, //头等舱(实际经济舱)
  4114. };
  4115. var bizTypeIds = new List<int>() {
  4116. 457, //头等舱
  4117. 458, //公务舱
  4118. 1431, //头等舱(实际公务舱)
  4119. };
  4120. var auditFeeTypeIds = new List<int>() { };
  4121. auditFeeTypeIds.AddRange(ecoTypeIds);
  4122. auditFeeTypeIds.AddRange(bizTypeIds);
  4123. int currModule = 85;
  4124. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  4125. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  4126. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  4127. .Select((x, y) => new
  4128. {
  4129. x.Id,
  4130. CcpId = y.Id,
  4131. x.FlightsDate,
  4132. x.PrePrice,
  4133. x.CType,
  4134. x.ClientNum,
  4135. x.DIId
  4136. })
  4137. .FirstAsync();
  4138. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  4139. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  4140. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  4141. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  4142. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  4143. var groupCostContents = await _sqlSugar
  4144. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  4145. .Where(x => x.IsDel == 0 && x.Diid == diId)
  4146. .ToListAsync();
  4147. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  4148. //处理 成本详细信息日期为空 填装费用信息
  4149. var airFeeLabel = new StringBuilder();
  4150. airFeeLabel.AppendLine("费用成本:");
  4151. for (int i = 0; i < groupCostContents.Count; i++)
  4152. {
  4153. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  4154. {
  4155. int index = i - 1;
  4156. if (index >= 0)
  4157. {
  4158. groupCostContents[i].Date = groupCostContents[index].Date;
  4159. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4160. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4161. }
  4162. }
  4163. else
  4164. {
  4165. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4166. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4167. }
  4168. var item = groupCostContents[i];
  4169. airFeeLabel.AppendLine($"{item.Date}");
  4170. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  4171. }
  4172. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  4173. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  4174. //访问Kimi AI 返回价格结果
  4175. var msgs = new List<SeedMessages>()
  4176. {
  4177. new ()
  4178. {
  4179. Role = KimiRole.user,
  4180. Content = airFeeLabel.ToString()
  4181. }
  4182. };
  4183. var client = new KiMiApiClient();
  4184. var kimiApiResult = await client.SeedMessage(msgs);
  4185. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  4186. string clients = kimiApiResult_JObject["content"].ToString();
  4187. decimal ecoPri_kimiAI = 0.00M,
  4188. bizPri_kimiAI = 0.00M;
  4189. //单个价格: 经济舱价格
  4190. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  4191. //价格文本包含/:/前经济舱价格 /后公务舱价格
  4192. if (clients.Contains('/'))
  4193. {
  4194. var priArray = clients.Split('/');
  4195. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  4196. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  4197. }
  4198. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  4199. var isAutoAudit = false;
  4200. //价格验证处理
  4201. //经济舱
  4202. if (ecoTypeIds.Contains(airInfo.CType))
  4203. {
  4204. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  4205. }
  4206. //公务舱
  4207. else if (bizTypeIds.Contains(airInfo.CType))
  4208. {
  4209. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4210. }
  4211. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4212. //是否执行自动审核
  4213. if (isAutoAudit)
  4214. {
  4215. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4216. .SetColumns(x => x.IsAuditGM == 3)
  4217. .SetColumns(x => x.AuditGMOperate == 4)
  4218. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4219. .Where(x => x.Id == airInfo.CcpId)
  4220. .ExecuteCommandAsync();
  4221. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4222. }
  4223. return (false, "当前费用超过成本费用,不可自动审核!");
  4224. }
  4225. /// <summary>
  4226. /// 机票费用录入
  4227. /// 自动审核测试 - AI 识别
  4228. /// </summary>
  4229. /// <param name="groupId"></param>
  4230. /// <param name="Id"></param>
  4231. /// <returns></returns>
  4232. [HttpPost]
  4233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4234. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4235. {
  4236. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4237. return Ok(JsonView(status, msg));
  4238. }
  4239. /// <summary>
  4240. /// 根据舱位类型查询接团客户名单信息
  4241. /// </summary>
  4242. /// <param name="dto"></param>
  4243. /// <returns></returns>
  4244. [HttpPost]
  4245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4246. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4247. {
  4248. try
  4249. {
  4250. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4251. if (crm_Groups.Count != 0)
  4252. {
  4253. var Customer = new List<dynamic>();
  4254. foreach (var item in crm_Groups)
  4255. {
  4256. var data = new
  4257. {
  4258. item.Id,
  4259. item.Pinyin,
  4260. Name = item.LastName + item.FirstName
  4261. };
  4262. Customer.Add(data);
  4263. }
  4264. return Ok(JsonView(true, "查询成功!", Customer));
  4265. }
  4266. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4267. }
  4268. catch (Exception ex)
  4269. {
  4270. return Ok(JsonView(false, "程序错误!"));
  4271. throw;
  4272. }
  4273. }
  4274. /// <summary>
  4275. /// 根据团号获取客户信息
  4276. /// </summary>
  4277. /// <param name="dto"></param>
  4278. /// <returns></returns>
  4279. [HttpPost]
  4280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4281. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4282. {
  4283. var jw = JsonView(false);
  4284. if (dto.DIID < 1)
  4285. {
  4286. jw.Msg += "请输入正确的diid";
  4287. return Ok(jw);
  4288. }
  4289. var arr = GetSimplClientList(dto.DIID);
  4290. jw = JsonView(true, "获取成功!", arr);
  4291. return Ok(jw);
  4292. }
  4293. private List<SimplClientInfo> GetSimplClientList(int diId)
  4294. {
  4295. 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);
  4296. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4297. foreach (var item in arr)
  4298. {
  4299. EncryptionProcessor.DecryptProperties(item);
  4300. }
  4301. return arr;
  4302. }
  4303. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4304. {
  4305. string result = origin;
  4306. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4307. {
  4308. string[] temparr = origin.Split(',');
  4309. string fistrStr = temparr[0];
  4310. int count = temparr.Length;
  4311. bool success = int.TryParse(fistrStr, out int tempId);
  4312. if (success)
  4313. {
  4314. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4315. if (tempInfo != null)
  4316. {
  4317. if (count > 1)
  4318. {
  4319. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4320. }
  4321. else
  4322. {
  4323. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4324. }
  4325. }
  4326. }
  4327. }
  4328. return result;
  4329. }
  4330. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4331. {
  4332. string result = origin;
  4333. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4334. {
  4335. string[] temparr = origin.Split(',');
  4336. result = "";
  4337. foreach (var item in temparr)
  4338. {
  4339. bool success = int.TryParse(item, out int tempId);
  4340. if (success)
  4341. {
  4342. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4343. if (tempInfo != null)
  4344. {
  4345. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4346. }
  4347. }
  4348. }
  4349. }
  4350. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4351. return result;
  4352. }
  4353. /// <summary>
  4354. /// 机票费用录入,删除
  4355. /// </summary>
  4356. /// <param name="dto"></param>
  4357. /// <returns></returns>
  4358. [HttpPost]
  4359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4360. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4361. {
  4362. try
  4363. {
  4364. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4365. if (res)
  4366. {
  4367. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4368. {
  4369. IsDel = 1,
  4370. DeleteUserId = dto.DeleteUserId,
  4371. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4372. }).ExecuteCommandAsync();
  4373. return Ok(JsonView(true, "删除成功!"));
  4374. }
  4375. return Ok(JsonView(false, "删除失败!"));
  4376. }
  4377. catch (Exception ex)
  4378. {
  4379. return Ok(JsonView(false, "程序错误!"));
  4380. throw;
  4381. }
  4382. }
  4383. /// <summary>
  4384. /// 导出机票录入报表
  4385. /// </summary>
  4386. /// <param name="dto"></param>
  4387. /// <returns></returns>
  4388. [HttpPost]
  4389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4390. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4391. {
  4392. try
  4393. {
  4394. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4395. if (groupData.Code != 0)
  4396. {
  4397. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4398. }
  4399. else
  4400. {
  4401. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4402. if (AirTicketReservations.Count != 0)
  4403. {
  4404. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4405. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4406. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4407. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4408. var designer = new WorkbookDesigner
  4409. {
  4410. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4411. };
  4412. decimal countCost = 0;
  4413. foreach (var item in AirTicketReservations)
  4414. {
  4415. #region 处理客人姓名
  4416. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4417. item.ClientName = clientNames;
  4418. #endregion
  4419. if (item.BankType == "其他")
  4420. {
  4421. item.BankNo = "--";
  4422. }
  4423. else
  4424. {
  4425. if (!string.IsNullOrEmpty(item.BankType))
  4426. {
  4427. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  4428. }
  4429. }
  4430. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4431. item.Price = System.Decimal.Round(item.Price, 2);
  4432. countCost += Convert.ToDecimal(item.Price);
  4433. }
  4434. designer.SetDataSource("Export", AirTicketReservations);
  4435. designer.SetDataSource("ExportDiCode", diCode);
  4436. designer.SetDataSource("ExportDiName", diName);
  4437. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4438. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4439. designer.Process();
  4440. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4441. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4442. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4443. return Ok(JsonView(true, "成功", url = rst));
  4444. }
  4445. else
  4446. {
  4447. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4448. }
  4449. }
  4450. }
  4451. catch (Exception ex)
  4452. {
  4453. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4454. throw;
  4455. }
  4456. }
  4457. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  4458. /// <summary>
  4459. /// 行程单导出
  4460. /// </summary>
  4461. /// <param name="dto"></param>
  4462. /// <returns></returns>
  4463. [HttpPost]
  4464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4465. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4466. {
  4467. try
  4468. {
  4469. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4470. if (groupData.Code != 0)
  4471. {
  4472. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4473. }
  4474. else
  4475. {
  4476. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4477. if (dto.Language == "CN")
  4478. {
  4479. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4480. var builder = new DocumentBuilder(doc);
  4481. int tableIndex = 0;//表格索引
  4482. //得到文档中的第一个表格
  4483. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4484. foreach (var item in _AirTicketReservations)
  4485. {
  4486. #region 处理固定数据
  4487. string[] FlightsCode = item.FlightsCode.Split('/');
  4488. if (FlightsCode.Length != 0)
  4489. {
  4490. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4491. if (_AirCompany != null)
  4492. {
  4493. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4494. }
  4495. else
  4496. {
  4497. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4498. }
  4499. }
  4500. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4501. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4502. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4503. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4504. string name = "";
  4505. foreach (string clientName in nameArray)
  4506. {
  4507. if (!name.Contains(clientName))
  4508. {
  4509. name += clientName + ",";
  4510. }
  4511. }
  4512. if (!string.IsNullOrWhiteSpace(name))
  4513. {
  4514. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4515. }
  4516. else
  4517. {
  4518. table.Range.Bookmarks["ClientName"].Text = "--";
  4519. }
  4520. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4521. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4522. table.Range.Bookmarks["JointTicket"].Text = "--";
  4523. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4524. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4525. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4526. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4527. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4528. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4529. #endregion
  4530. #region 循环数据处理
  4531. var airs = new List<AirInfo>();
  4532. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4533. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4534. for (int i = 0; i < FlightsCode.Length; i++)
  4535. {
  4536. var air = new AirInfo();
  4537. string[] tempstr = DayArray[i]
  4538. .Replace("\r\n", string.Empty)
  4539. .Replace("\\r\\n", string.Empty)
  4540. .TrimStart().TrimEnd()
  4541. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4542. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4543. string starCity = "";
  4544. if (star_Three != null)
  4545. {
  4546. starCity = star_Three.AirPort;
  4547. }
  4548. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4549. string EndCity = "";
  4550. if (End_Three != null)
  4551. {
  4552. EndCity = End_Three.AirPort;
  4553. }
  4554. air.Destination = starCity + "/" + EndCity;
  4555. air.Flight = FlightsCode[i];
  4556. air.SeatingClass = item.CTypeName;
  4557. string dateTime = tempstr[2];
  4558. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4559. air.FlightDate = DateTemp;
  4560. air.DepartureTime = tempstr[5];
  4561. air.LandingTime = tempstr[6];
  4562. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4563. air.TicketStatus = "--";
  4564. air.Luggage = "--";
  4565. air.DepartureTerminal = "--";
  4566. air.LandingTerminal = "--";
  4567. airs.Add(air);
  4568. }
  4569. int row = 13;
  4570. for (int i = 0; i < airs.Count; i++)
  4571. {
  4572. if (airs.Count > 2)
  4573. {
  4574. for (int j = 0; j < airs.Count - 2; j++)
  4575. {
  4576. var CopyRow = table.Rows[12].Clone(true);
  4577. table.Rows.Add(CopyRow);
  4578. }
  4579. }
  4580. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4581. int index = 0;
  4582. foreach (PropertyInfo property in properties)
  4583. {
  4584. string value = property.GetValue(airs[i]).ToString();
  4585. Cell ishcel0 = table.Rows[row].Cells[index];
  4586. var p = new Paragraph(doc);
  4587. string s = value;
  4588. p.AppendChild(new Run(doc, s));
  4589. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4590. ishcel0.AppendChild(p);
  4591. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4592. index++;
  4593. }
  4594. row++;
  4595. }
  4596. #endregion
  4597. var lastParagraph = new Paragraph(doc);
  4598. //第一个表格末尾加段落
  4599. table.ParentNode.InsertAfter(lastParagraph, table);
  4600. //复制第一个表格
  4601. Table cloneTable = (Table)table.Clone(true);
  4602. //在文档末尾段落后面加入复制的表格
  4603. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4604. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4605. {
  4606. int rownewsIndex = 13;
  4607. for (int i = 0; i < 2; i++)
  4608. {
  4609. var CopyRow = table.Rows[12].Clone(true);
  4610. table.Rows.RemoveAt(13);
  4611. table.Rows.Add(CopyRow);
  4612. rownewsIndex++;
  4613. }
  4614. }
  4615. else
  4616. {
  4617. table.Rows.RemoveAt(12);
  4618. }
  4619. cloneTable.Rows.RemoveAt(12);
  4620. }
  4621. if (_AirTicketReservations.Count != 0)
  4622. {
  4623. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4624. if (FlightsCode.Length != 0)
  4625. {
  4626. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4627. if (_AirCompany != null)
  4628. {
  4629. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4630. }
  4631. else
  4632. {
  4633. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4634. }
  4635. }
  4636. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4637. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4638. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4639. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4640. string name = "";
  4641. foreach (string clientName in nameArray)
  4642. {
  4643. if (!name.Contains(clientName))
  4644. {
  4645. name += clientName + ",";
  4646. }
  4647. }
  4648. if (!string.IsNullOrWhiteSpace(name))
  4649. {
  4650. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4651. }
  4652. else
  4653. {
  4654. table.Range.Bookmarks["ClientName"].Text = "--";
  4655. }
  4656. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4657. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4658. table.Range.Bookmarks["JointTicket"].Text = "--";
  4659. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4660. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4661. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4662. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4663. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4664. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4665. }
  4666. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4667. //保存合并后的文档
  4668. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4669. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4670. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4671. return Ok(JsonView(true, "成功!", rst));
  4672. }
  4673. else
  4674. {
  4675. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4676. var builder = new DocumentBuilder(doc);
  4677. int tableIndex = 0;//表格索引
  4678. //得到文档中的第一个表格
  4679. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4680. var texts = new List<string>();
  4681. foreach (var item in _AirTicketReservations)
  4682. {
  4683. string[] FlightsCode = item.FlightsCode.Split('/');
  4684. if (FlightsCode.Length != 0)
  4685. {
  4686. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4687. if (_AirCompany != null)
  4688. {
  4689. if (!transDic.ContainsKey(_AirCompany.CnName))
  4690. {
  4691. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4692. }
  4693. }
  4694. else
  4695. {
  4696. if (!transDic.ContainsKey("--"))
  4697. {
  4698. transDic.Add("--", "--");
  4699. }
  4700. }
  4701. }
  4702. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4703. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4704. string name = "";
  4705. foreach (string clientName in nameArray)
  4706. {
  4707. name += clientName + ",";
  4708. }
  4709. if (!texts.Contains(name))
  4710. {
  4711. texts.Add(name);
  4712. }
  4713. var airs = new List<AirInfo>();
  4714. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4715. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4716. for (int i = 0; i < FlightsCode.Length; i++)
  4717. {
  4718. var air = new AirInfo();
  4719. string[] tempstr = DayArray[i]
  4720. .Replace("\r\n", string.Empty)
  4721. .Replace("\\r\\n", string.Empty)
  4722. .TrimStart().TrimEnd()
  4723. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4724. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4725. if (star_Three != null)
  4726. {
  4727. if (!transDic.ContainsKey(star_Three.AirPort))
  4728. {
  4729. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4730. }
  4731. }
  4732. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4733. if (End_Three != null)
  4734. {
  4735. if (!transDic.ContainsKey(End_Three.AirPort))
  4736. {
  4737. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4738. }
  4739. }
  4740. if (!texts.Contains(item.CTypeName))
  4741. {
  4742. texts.Add(item.CTypeName);
  4743. }
  4744. }
  4745. }
  4746. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4747. if (transData.Count > 0)
  4748. {
  4749. foreach (TranslateResult item in transData)
  4750. {
  4751. if (!transDic.ContainsKey(item.Query))
  4752. {
  4753. transDic.Add(item.Query, item.Translation);
  4754. }
  4755. }
  4756. }
  4757. foreach (var item in _AirTicketReservations)
  4758. {
  4759. #region 处理固定数据
  4760. string[] FlightsCode = item.FlightsCode.Split('/');
  4761. if (FlightsCode.Length != 0)
  4762. {
  4763. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4764. if (_AirCompany != null)
  4765. {
  4766. string str = "--";
  4767. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4768. if (!string.IsNullOrEmpty(translateResult))
  4769. {
  4770. str = translateResult;
  4771. str = _airTicketResRep.Processing(str);
  4772. }
  4773. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4774. }
  4775. else
  4776. {
  4777. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4778. }
  4779. }
  4780. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4781. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4782. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4783. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4784. string names = "";
  4785. foreach (string clientName in nameArray)
  4786. {
  4787. names += clientName + ",";
  4788. }
  4789. if (!string.IsNullOrWhiteSpace(names))
  4790. {
  4791. string str = "--";
  4792. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4793. if (!string.IsNullOrEmpty(translateResult))
  4794. {
  4795. str = translateResult;
  4796. str = _airTicketResRep.Processing(str);
  4797. }
  4798. table.Range.Bookmarks["ClientName"].Text = str;
  4799. }
  4800. else
  4801. {
  4802. table.Range.Bookmarks["ClientName"].Text = "--";
  4803. }
  4804. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4805. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4806. table.Range.Bookmarks["JointTicket"].Text = "--";
  4807. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4808. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4809. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4810. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4811. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4812. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4813. #endregion
  4814. #region 循环数据处理
  4815. var airs = new List<AirInfo>();
  4816. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4817. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4818. for (int i = 0; i < FlightsCode.Length; i++)
  4819. {
  4820. var air = new AirInfo();
  4821. string[] tempstr = DayArray[i]
  4822. .Replace("\r\n", string.Empty)
  4823. .Replace("\\r\\n", string.Empty)
  4824. .TrimStart().TrimEnd()
  4825. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4826. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4827. string starCity = "";
  4828. if (star_Three != null)
  4829. {
  4830. string str2 = "--";
  4831. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4832. if (!string.IsNullOrEmpty(translateResult2))
  4833. {
  4834. str2 = translateResult2;
  4835. str2 = _airTicketResRep.Processing(str2);
  4836. }
  4837. starCity = str2;
  4838. }
  4839. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4840. string EndCity = "";
  4841. if (End_Three != null)
  4842. {
  4843. string str1 = "--";
  4844. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4845. if (!string.IsNullOrEmpty(translateResult1))
  4846. {
  4847. str1 = translateResult1;
  4848. str1 = _airTicketResRep.Processing(str1);
  4849. }
  4850. EndCity = str1;
  4851. }
  4852. air.Destination = starCity + "/" + EndCity;
  4853. air.Flight = FlightsCode[i];
  4854. string str = "--";
  4855. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4856. if (!string.IsNullOrEmpty(translateResult))
  4857. {
  4858. str = translateResult;
  4859. str = _airTicketResRep.Processing(str);
  4860. }
  4861. air.SeatingClass = str;
  4862. string dateTime = tempstr[2];
  4863. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4864. air.FlightDate = DateTemp;
  4865. air.DepartureTime = tempstr[5];
  4866. air.LandingTime = tempstr[6];
  4867. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4868. air.TicketStatus = "--";
  4869. air.Luggage = "--";
  4870. air.DepartureTerminal = "--";
  4871. air.LandingTerminal = "--";
  4872. airs.Add(air);
  4873. }
  4874. int row = 13;
  4875. for (int i = 0; i < airs.Count; i++)
  4876. {
  4877. if (airs.Count > 2)
  4878. {
  4879. for (int j = 0; j < airs.Count - 2; j++)
  4880. {
  4881. var CopyRow = table.Rows[12].Clone(true);
  4882. table.Rows.Add(CopyRow);
  4883. }
  4884. }
  4885. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4886. int index = 0;
  4887. foreach (PropertyInfo property in properties)
  4888. {
  4889. string value = property.GetValue(airs[i]).ToString();
  4890. Cell ishcel0 = table.Rows[row].Cells[index];
  4891. var p = new Paragraph(doc);
  4892. string s = value;
  4893. p.AppendChild(new Run(doc, s));
  4894. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4895. ishcel0.AppendChild(p);
  4896. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4897. //ishcel0.CellFormat.VerticalAlignment=
  4898. index++;
  4899. }
  4900. row++;
  4901. }
  4902. #endregion
  4903. var lastParagraph = new Paragraph(doc);
  4904. //第一个表格末尾加段落
  4905. table.ParentNode.InsertAfter(lastParagraph, table);
  4906. //复制第一个表格
  4907. Table cloneTable = (Table)table.Clone(true);
  4908. //在文档末尾段落后面加入复制的表格
  4909. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4910. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4911. {
  4912. int rownewsIndex = 13;
  4913. for (int i = 0; i < 2; i++)
  4914. {
  4915. var CopyRow = table.Rows[12].Clone(true);
  4916. table.Rows.RemoveAt(13);
  4917. table.Rows.Add(CopyRow);
  4918. rownewsIndex++;
  4919. }
  4920. }
  4921. else
  4922. {
  4923. table.Rows.RemoveAt(12);
  4924. }
  4925. cloneTable.Rows.RemoveAt(12);
  4926. }
  4927. if (_AirTicketReservations.Count != 0)
  4928. {
  4929. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4930. if (FlightsCode.Length != 0)
  4931. {
  4932. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4933. if (_AirCompany != null)
  4934. {
  4935. string str = "--";
  4936. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4937. if (!string.IsNullOrEmpty(translateResult))
  4938. {
  4939. str = translateResult;
  4940. str = _airTicketResRep.Processing(str);
  4941. }
  4942. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4943. }
  4944. else
  4945. {
  4946. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4947. }
  4948. }
  4949. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4950. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4951. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4952. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4953. string names = "";
  4954. foreach (string clientName in nameArray)
  4955. {
  4956. names += clientName + ",";
  4957. }
  4958. if (!string.IsNullOrWhiteSpace(names))
  4959. {
  4960. string str = "--";
  4961. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4962. if (!string.IsNullOrEmpty(translateResult))
  4963. {
  4964. str = translateResult;
  4965. str = _airTicketResRep.Processing(str);
  4966. }
  4967. table.Range.Bookmarks["ClientName"].Text = str;
  4968. }
  4969. else
  4970. {
  4971. table.Range.Bookmarks["ClientName"].Text = "--";
  4972. }
  4973. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4974. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4975. table.Range.Bookmarks["JointTicket"].Text = "--";
  4976. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4977. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4978. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4979. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4980. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4981. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4982. }
  4983. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4984. //保存合并后的文档
  4985. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4986. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4987. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4988. return Ok(JsonView(true, "成功!", rst));
  4989. }
  4990. }
  4991. }
  4992. catch (Exception ex)
  4993. {
  4994. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4995. throw;
  4996. }
  4997. }
  4998. #endregion
  4999. #region 团组增减款项 --> 其他款项
  5000. /// <summary>
  5001. /// 团组增减款项下拉框绑定
  5002. /// </summary>
  5003. /// <param name="dto"></param>
  5004. /// <returns></returns>
  5005. [HttpPost]
  5006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5007. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  5008. {
  5009. #region 参数验证
  5010. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5011. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  5012. #endregion
  5013. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  5014. }
  5015. /// <summary>
  5016. /// 根据团组Id查询团组增减款项
  5017. /// </summary>
  5018. /// <param name="dto"></param>
  5019. /// <returns></returns>
  5020. [HttpPost]
  5021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5022. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  5023. {
  5024. #region 参数验证
  5025. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5026. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5027. #endregion
  5028. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  5029. }
  5030. /// <summary>
  5031. /// 团组增减款项操作(Status:1.新增,2.修改)
  5032. /// </summary>
  5033. /// <param name="dto"></param>
  5034. /// <returns></returns>
  5035. [HttpPost]
  5036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5037. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  5038. {
  5039. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  5040. if (groupData.Code != 200)
  5041. {
  5042. return Ok(JsonView(false, groupData.Msg));
  5043. }
  5044. #region 应用推送
  5045. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  5046. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5047. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5048. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  5049. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  5050. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  5051. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  5052. if (recheck)
  5053. {
  5054. //自动审核
  5055. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  5056. }
  5057. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5058. //2024-10-21 新增LZ UID
  5059. var userIds = new List<int>() { 21 };
  5060. string title = $"系统通知";
  5061. string content = "";
  5062. var diId = dto.DiId;
  5063. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5064. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5065. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5066. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5067. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5068. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  5069. #endregion
  5070. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5071. }
  5072. /// <summary>
  5073. /// 团组增减款项操作 删除
  5074. /// </summary>
  5075. /// <param name="dto"></param>
  5076. /// <returns></returns>
  5077. [HttpPost]
  5078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5079. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  5080. {
  5081. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  5082. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  5083. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  5084. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  5085. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  5086. }
  5087. /// <summary>
  5088. /// 根据团组增减款项Id查询
  5089. /// </summary>
  5090. /// <param name="dto"></param>
  5091. /// <returns></returns>
  5092. [HttpPost]
  5093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5094. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  5095. {
  5096. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  5097. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  5098. }
  5099. /// <summary>
  5100. /// 查询供应商名称
  5101. /// </summary>
  5102. /// <param name="dto"></param>
  5103. /// <returns></returns>
  5104. [HttpPost]
  5105. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  5106. {
  5107. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  5108. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  5109. ?? new List<Grp_DecreasePayments>();
  5110. dbResult = dbResult.Distinct(new
  5111. ProductComparer()).ToList();
  5112. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  5113. {
  5114. x.Id,
  5115. x.SupplierAddress,
  5116. x.SupplierArea,
  5117. x.SupplierContact,
  5118. x.SupplierContactNumber,
  5119. x.SupplierEmail,
  5120. x.SupplierName,
  5121. x.SupplierSocialAccount,
  5122. x.SupplierTypeId,
  5123. }).ToList());
  5124. return Ok(jw);
  5125. }
  5126. /// <summary>
  5127. /// 团组增减款项 OTA匹配
  5128. /// </summary>
  5129. /// <param name="file"></param>
  5130. /// <returns></returns>
  5131. [HttpPost]
  5132. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  5133. {
  5134. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  5135. string fileName = file.FileName;
  5136. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  5137. {
  5138. return Ok(JsonView(false, "请上传Excel文件!"));
  5139. }
  5140. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  5141. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  5142. if (!Directory.Exists(path))
  5143. {
  5144. Directory.CreateDirectory(path);
  5145. }
  5146. var filePath = @$"{path}/{fileName}";
  5147. //保存文件
  5148. using (FileStream fs = System.IO.File.Create(filePath))
  5149. {
  5150. file.CopyTo(fs);
  5151. fs.Flush();
  5152. }
  5153. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  5154. //读取ExcelFile
  5155. DataTable dt = ConvertExcelToDataTable(filePath);
  5156. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  5157. dt.TableName = "TB";
  5158. //修改table列名
  5159. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  5160. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  5161. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  5162. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  5163. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  5164. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  5165. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  5166. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  5167. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  5168. dt.Columns[9].ColumnName = "Quantity"; // 台数
  5169. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  5170. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  5171. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  5172. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  5173. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  5174. var otaOrderNos = new List<string>();
  5175. foreach (DataRow item in dt.Rows)
  5176. {
  5177. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  5178. }
  5179. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  5180. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  5181. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  5182. .Select((dp, di) => new
  5183. {
  5184. dp.PriceName,
  5185. dp.OTAOrderNo,
  5186. dp.FeeTotal,
  5187. di.TeamName,
  5188. })
  5189. .ToListAsync();
  5190. foreach (DataRow item in dt.Rows)
  5191. {
  5192. var otaOrderNo = item["OTAOrderNo"].ToString();
  5193. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  5194. if (oaData == null) continue;
  5195. item["GroupName"] = oaData.TeamName;
  5196. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  5197. }
  5198. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  5199. var pairs = new Dictionary<string, object>();
  5200. var datas = new List<DataTable>
  5201. {
  5202. dt
  5203. };
  5204. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  5205. return Ok(JsonView(true, "操作成功", new { url }));
  5206. }
  5207. #region
  5208. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  5209. {
  5210. // 创建Workbook对象
  5211. var workbook = new Workbook(excelFilePath);
  5212. // 获取第一个工作表
  5213. var worksheet = workbook.Worksheets[0];
  5214. // 将工作表转换为DataTable
  5215. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5216. return dataTable;
  5217. }
  5218. #endregion
  5219. /// <summary>
  5220. /// 世运会数据
  5221. /// </summary>
  5222. /// <returns></returns>
  5223. [HttpGet]
  5224. public IActionResult WorldGamesData()
  5225. {
  5226. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5227. var groupMenu = setData.GroupBy(x => x.T0);
  5228. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5229. foreach (var item in groupMenu)
  5230. {
  5231. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5232. {
  5233. Data = new SetDataView
  5234. {
  5235. Name = item.Key
  5236. },
  5237. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5238. });
  5239. }
  5240. return Ok(JsonView(true, "success", resultArr));
  5241. }
  5242. #endregion
  5243. #region 文件上传、删除
  5244. /// <summary>
  5245. /// region 文件上传 可以带参数
  5246. /// </summary>
  5247. /// <param name="file"></param>
  5248. /// <returns></returns>
  5249. [HttpPost]
  5250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5251. public async Task<IActionResult> UploadProject(IFormFile file)
  5252. {
  5253. //var TypeName = Request.Headers["TypeName"].ToString();
  5254. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5255. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5256. ////文件名称
  5257. //string projectFileName = file.FileName;
  5258. ////上传的文件的路径
  5259. //string filePath = $"{fileDir}/{projectFileName}";
  5260. //if (TypeName == "A")//A代表团组增减款项
  5261. //{
  5262. // filePath = fileDir + $@"\团组增减款项相关文件";
  5263. // if (!Directory.Exists(filePath))
  5264. // {
  5265. // Directory.CreateDirectory(filePath);
  5266. // }
  5267. // //上传的文件的路径
  5268. // filePath += $@"\{projectFileName}";
  5269. //}
  5270. //else if (TypeName == "B")//B代表商邀相关文件
  5271. //{
  5272. // //上传的文件的路径
  5273. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5274. // if (!Directory.Exists(filePath))
  5275. // {
  5276. // Directory.CreateDirectory(filePath);
  5277. // }
  5278. // //上传的文件的路径
  5279. // filePath = $@"\{projectFileName}";
  5280. //}
  5281. //try
  5282. //{
  5283. // using (FileStream fs = System.IO.File.Create(filePath))
  5284. // {
  5285. // file.CopyTo(fs);
  5286. // fs.Flush();
  5287. // }
  5288. //}
  5289. //catch (Exception ex)
  5290. //{
  5291. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5292. //}
  5293. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5294. try
  5295. {
  5296. var TypeName = Request.Headers["TypeName"].ToString();
  5297. if (file != null)
  5298. {
  5299. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5300. //文件名称
  5301. string projectFileName = file.FileName;
  5302. //上传的文件的路径
  5303. string filePath = $"{fileDir}/{projectFileName}";
  5304. if (TypeName == "A")//A代表团组增减款项
  5305. {
  5306. if (!Directory.Exists(fileDir))
  5307. {
  5308. Directory.CreateDirectory(fileDir);
  5309. }
  5310. //上传的文件的路径
  5311. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5312. }
  5313. else if (TypeName == "B")//B代表商邀相关文件
  5314. {
  5315. if (!Directory.Exists(fileDir))
  5316. {
  5317. Directory.CreateDirectory(fileDir);
  5318. }
  5319. //上传的文件的路径
  5320. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5321. }
  5322. using (FileStream fs = System.IO.File.Create(filePath))
  5323. {
  5324. file.CopyTo(fs);
  5325. fs.Flush();
  5326. }
  5327. return Ok(JsonView(true, "上传成功!", projectFileName));
  5328. }
  5329. else
  5330. {
  5331. return Ok(JsonView(false, "上传失败!"));
  5332. }
  5333. }
  5334. catch (Exception ex)
  5335. {
  5336. return Ok(JsonView(false, ex.Message));
  5337. }
  5338. }
  5339. /// <summary>
  5340. /// 删除指定文件
  5341. /// </summary>
  5342. /// <param name="dto"></param>
  5343. /// <returns></returns>
  5344. [HttpPost]
  5345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5346. public async Task<IActionResult> DelFile(DelFileDto dto)
  5347. {
  5348. try
  5349. {
  5350. var TypeName = Request.Headers["TypeName"].ToString();
  5351. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5352. string filePath = "";
  5353. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5354. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5355. int id = 0;
  5356. if (TypeName == "A")
  5357. {
  5358. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5359. // 删除该文件
  5360. System.IO.File.Delete(filePath);
  5361. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5362. .Where(a => a.Id == dto.Id)
  5363. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5364. .ExecuteCommandAsync();
  5365. }
  5366. else if (TypeName == "B")
  5367. {
  5368. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5369. // 删除该文件
  5370. System.IO.File.Delete(filePath);
  5371. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5372. if (info != null)
  5373. {
  5374. string[] files = Array.Empty<string>();
  5375. if (!string.IsNullOrEmpty(info.Attachment))
  5376. {
  5377. try
  5378. {
  5379. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5380. }
  5381. catch (Exception)
  5382. {
  5383. files = new List<string>() { info.Attachment }.ToArray();
  5384. }
  5385. }
  5386. if (files.Length > 0)
  5387. {
  5388. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5389. string filePath2 = string.Empty;
  5390. if (files1.Length > 0)
  5391. {
  5392. filePath2 = JsonConvert.SerializeObject(files1);
  5393. }
  5394. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5395. .Where(a => a.Id == dto.Id)
  5396. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5397. .ExecuteCommandAsync();
  5398. }
  5399. }
  5400. }
  5401. if (id != 0)
  5402. {
  5403. return Ok(JsonView(true, "成功!"));
  5404. }
  5405. else
  5406. {
  5407. return Ok(JsonView(false, "失败!"));
  5408. }
  5409. }
  5410. catch (Exception ex)
  5411. {
  5412. return Ok(JsonView(false, "程序错误!"));
  5413. throw;
  5414. }
  5415. }
  5416. /// <summary>
  5417. /// 文件上传多个文件 可以带参数
  5418. /// </summary>
  5419. /// <param name="files"></param>
  5420. /// <returns></returns>
  5421. [HttpPost]
  5422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5423. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5424. {
  5425. try
  5426. {
  5427. var TypeName = Request.Headers["TypeName"].ToString();
  5428. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5429. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5430. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5431. var filePahts = new List<string>();
  5432. foreach (var file in files)
  5433. {
  5434. //文件名称
  5435. string projectFileName = file.FileName;
  5436. //上传的文件的路径
  5437. string filePath = $"{fileDir}/{projectFileName}";
  5438. if (TypeName == "A")//A代表团组增减款项
  5439. {
  5440. if (!Directory.Exists(fileDir))
  5441. {
  5442. Directory.CreateDirectory(fileDir);
  5443. }
  5444. //上传的文件的路径
  5445. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5446. }
  5447. else if (TypeName == "B")//B代表商邀相关文件
  5448. {
  5449. if (!Directory.Exists(fileDir))
  5450. {
  5451. Directory.CreateDirectory(fileDir);
  5452. }
  5453. //上传的文件的路径
  5454. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5455. }
  5456. using (FileStream fs = System.IO.File.Create(filePath))
  5457. {
  5458. file.CopyTo(fs);
  5459. fs.Flush();
  5460. }
  5461. filePahts.Add(projectFileName);
  5462. }
  5463. return Ok(JsonView(true, "上传成功!", filePahts));
  5464. }
  5465. catch (Exception ex)
  5466. {
  5467. return Ok(JsonView(false, ex.Message));
  5468. }
  5469. }
  5470. #endregion
  5471. #region 商邀费用录入
  5472. /// <summary>
  5473. /// 根据团组Id查询商邀费用列表
  5474. /// </summary>
  5475. /// <param name="dto"></param>
  5476. /// <returns></returns>
  5477. [HttpPost]
  5478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5479. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5480. {
  5481. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5482. if (groupData.Code != 0)
  5483. {
  5484. return Ok(JsonView(false, groupData.Msg));
  5485. }
  5486. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5487. }
  5488. /// <summary>
  5489. /// 商邀费用列表
  5490. /// 下载文件
  5491. /// </summary>
  5492. /// <param name="id"></param>
  5493. /// <returns></returns>
  5494. [HttpGet("{id}")]
  5495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5496. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5497. {
  5498. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5499. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5500. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5501. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5502. var filePaths = new List<string>();
  5503. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5504. try
  5505. {
  5506. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5507. }
  5508. catch (Exception ex)
  5509. {
  5510. filePaths.Add(info.Attachment);
  5511. }
  5512. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5513. for (int i = 0; i < filePaths.Count; i++)
  5514. {
  5515. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5516. }
  5517. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5518. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5519. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5520. {
  5521. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5522. {
  5523. foreach (string filePath in filePaths)
  5524. {
  5525. if (System.IO.File.Exists(filePath))
  5526. {
  5527. // 获取文件名
  5528. string fileName = Path.GetFileName(filePath);
  5529. // 将文件添加到ZIP归档中
  5530. zipArchive.CreateEntryFromFile(filePath, fileName);
  5531. }
  5532. }
  5533. }
  5534. }
  5535. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5536. }
  5537. /// <summary>
  5538. /// 商邀费用 Info Page 基础数据源
  5539. /// </summary>
  5540. /// <returns></returns>
  5541. [HttpPost]
  5542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5543. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5544. {
  5545. try
  5546. {
  5547. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5548. if (groupData.Code != 0)
  5549. {
  5550. return Ok(JsonView(false, groupData.Msg));
  5551. }
  5552. return Ok(JsonView(true, "操作成功", groupData.Data));
  5553. }
  5554. catch (Exception ex)
  5555. {
  5556. return Ok(JsonView(false, ex.Message));
  5557. throw;
  5558. }
  5559. }
  5560. /// <summary>
  5561. /// 根据商邀费用ID查询C表和商邀费用数据
  5562. /// </summary>
  5563. /// <param name="dto"></param>
  5564. /// <returns></returns>
  5565. [HttpPost]
  5566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5567. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5568. {
  5569. try
  5570. {
  5571. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5572. if (groupData.Code != 0)
  5573. {
  5574. return Ok(JsonView(false, groupData.Msg));
  5575. }
  5576. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5577. }
  5578. catch (Exception ex)
  5579. {
  5580. return Ok(JsonView(false, ex.Message));
  5581. throw;
  5582. }
  5583. }
  5584. /// <summary>
  5585. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5586. /// </summary>
  5587. /// <param name="dto"></param>
  5588. /// <returns></returns>
  5589. [HttpPost]
  5590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5591. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5592. {
  5593. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5594. if (groupData.Code != 0)
  5595. {
  5596. return Ok(JsonView(false, groupData.Msg));
  5597. }
  5598. #region 应用推送
  5599. try
  5600. {
  5601. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5602. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5603. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5604. //2024-10-21 新增LZ UID
  5605. var userIds = new List<int>() { 21 };
  5606. string title = $"系统通知";
  5607. string content = "";
  5608. var diId = dto.DiId;
  5609. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5610. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5611. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5612. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5613. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5614. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5615. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5616. }
  5617. catch (Exception ex)
  5618. {
  5619. }
  5620. #endregion
  5621. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5622. }
  5623. /// <summary>
  5624. /// 商邀删除
  5625. /// </summary>
  5626. /// <param name="dto"></param>
  5627. /// <returns></returns>
  5628. [HttpPost]
  5629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5630. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5631. {
  5632. try
  5633. {
  5634. _sqlSugar.BeginTran();
  5635. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5636. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5637. {
  5638. IsDel = 1,
  5639. DeleteUserId = dto.DeleteUserId,
  5640. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5641. })
  5642. .Where(it => it.Id == dto.Id)
  5643. .ExecuteCommand();
  5644. if (res1 > 0)
  5645. {
  5646. int _diId = 0;
  5647. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5648. if (_ioaInfo != null)
  5649. {
  5650. _diId = _ioaInfo.DiId;
  5651. }
  5652. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5653. .SetColumns(a => new Grp_CreditCardPayment()
  5654. {
  5655. IsDel = 1,
  5656. DeleteUserId = dto.DeleteUserId,
  5657. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5658. })
  5659. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5660. .ExecuteCommand();
  5661. if (res2 > 0)
  5662. {
  5663. _sqlSugar.CommitTran();
  5664. return Ok(JsonView(true, "删除成功!"));
  5665. }
  5666. }
  5667. _sqlSugar.RollbackTran();
  5668. return Ok(JsonView(false, "删除失败"));
  5669. }
  5670. catch (Exception ex)
  5671. {
  5672. _sqlSugar.RollbackTran();
  5673. return Ok(JsonView(false, ex.Message));
  5674. }
  5675. }
  5676. #endregion
  5677. #region 票据上传
  5678. /// <summary>
  5679. /// 团组模块文件上传
  5680. /// </summary>
  5681. /// <param name="dto"></param>
  5682. /// <returns></returns>
  5683. [HttpPost]
  5684. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5685. {
  5686. var jw = JsonView(false);
  5687. long M = 1024 * 1024;
  5688. if (dto.Files == null || dto.Files.Count == 0)
  5689. {
  5690. jw.Msg = "无文件信息!";
  5691. return Ok(jw);
  5692. }
  5693. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5694. {
  5695. jw.Msg = "文件大小超过20M!";
  5696. return Ok(jw);
  5697. }
  5698. //var nameSp = dto.File.FileName.Split(".");
  5699. //if (nameSp.Length < 2)
  5700. //{
  5701. // jw.Msg = "拓展名称有误!";
  5702. // return Ok(jw);
  5703. //}
  5704. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5705. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5706. //{
  5707. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5708. // return Ok(jw);
  5709. //}
  5710. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5711. if (Ctable == null)
  5712. {
  5713. jw.Msg = "Ctable指向有误!";
  5714. return Ok(jw);
  5715. }
  5716. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5717. if (groupInfo == null)
  5718. {
  5719. jw.Msg = "团组信息不存在!";
  5720. return Ok(jw);
  5721. }
  5722. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5723. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5724. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5725. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5726. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5727. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5728. try
  5729. {
  5730. if (!Directory.Exists(fileBase))
  5731. {
  5732. Directory.CreateDirectory(fileBase);
  5733. }
  5734. var saveArr = new List<Grp_GroupModelFile>();
  5735. foreach (var fileStream in dto.Files)
  5736. {
  5737. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5738. var file = new Grp_GroupModelFile()
  5739. {
  5740. Cid = dto.Cid,
  5741. CreateTime = DateTime.Now,
  5742. CreateUserId = dto.Userid,
  5743. Ctable = dto.Ctable,
  5744. Diid = dto.Diid,
  5745. IsDel = 0,
  5746. FilePath = saveFilePath,
  5747. FileName = fileStream.FileName
  5748. };
  5749. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5750. {
  5751. fileStream.CopyTo(fs);
  5752. fs.Flush();
  5753. }
  5754. saveArr.Add(file);
  5755. }
  5756. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5757. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5758. jw = JsonView(true, "保存成功!", new
  5759. {
  5760. count = addResult,
  5761. filesName = saveArr.Select(x => x.FileName)
  5762. });
  5763. }
  5764. catch (Exception ex)
  5765. {
  5766. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5767. {
  5768. count = 0,
  5769. filesName = Array.Empty<string>(),
  5770. });
  5771. }
  5772. return Ok(jw);
  5773. }
  5774. /// <summary>
  5775. /// 查询各模块已保存文件
  5776. /// </summary>
  5777. /// <param name="dto"></param>
  5778. /// <returns></returns>
  5779. [HttpPost]
  5780. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5781. {
  5782. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5783. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5784. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5785. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5786. {
  5787. expression = Expressionable.Create<Grp_GroupModelFile>()
  5788. .And(x => visaIds.Contains(x.CreateUserId));
  5789. }
  5790. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5791. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5792. .Where(expression.ToExpression())
  5793. .ToList();
  5794. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5795. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5796. {
  5797. x.FileName,
  5798. x.Id,
  5799. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5800. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5801. })));
  5802. }
  5803. /// <summary>
  5804. /// 下载该团组下的所有文件
  5805. /// </summary>
  5806. /// <param name="dto"></param>
  5807. /// <returns></returns>
  5808. [HttpPost]
  5809. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5810. {
  5811. var jw = JsonView(false);
  5812. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5813. if (groupInfo == null)
  5814. {
  5815. jw.Msg = "团组信息不存在!";
  5816. return Ok(jw);
  5817. }
  5818. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5819. var isModule = Convert.ToBoolean(dto.isModule);
  5820. var Zips = new Dictionary<string, Stream>();
  5821. var io = new IOOperatorHelper();
  5822. if (isModule)
  5823. {
  5824. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5825. foreach (var moduleArr in moduleGroup)
  5826. {
  5827. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5828. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5829. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5830. var chiZips = new Dictionary<string, Stream>();
  5831. foreach (var item in moduleArr)
  5832. {
  5833. if (System.IO.File.Exists(item.FilePath))
  5834. {
  5835. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5836. {
  5837. byte[] bytes = new byte[fileStream.Length];
  5838. fileStream.Read(bytes, 0, bytes.Length);
  5839. fileStream.Close();
  5840. Stream stream = new MemoryStream(bytes);
  5841. chiZips.Add(item.FileName, stream);
  5842. }
  5843. }
  5844. }
  5845. if (chiZips.Count > 0)
  5846. {
  5847. var byts = io.ConvertZipStream(chiZips);
  5848. Stream stream = new MemoryStream(byts);
  5849. Zips.Add(key.Name + "_.zip", stream);
  5850. }
  5851. }
  5852. }
  5853. else
  5854. {
  5855. foreach (var item in dbQuery)
  5856. {
  5857. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5858. {
  5859. byte[] bytes = new byte[fileStream.Length];
  5860. fileStream.Read(bytes, 0, bytes.Length);
  5861. fileStream.Close();
  5862. var stream = new MemoryStream(bytes);
  5863. while (Zips.ContainsKey(item.FileName))
  5864. {
  5865. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5866. }
  5867. Zips.Add(item.FileName, stream);
  5868. }
  5869. }
  5870. }
  5871. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5872. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5873. if (Zips.Count > 0)
  5874. {
  5875. var byts = io.ConvertZipStream(Zips);
  5876. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5877. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5878. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5879. }
  5880. else
  5881. {
  5882. jw.Msg = "暂无生成文件!";
  5883. }
  5884. return Ok(jw);
  5885. }
  5886. /// <summary>
  5887. /// 下载该团组下此模块的所有文件
  5888. /// </summary>
  5889. /// <param name="dto"></param>
  5890. /// <returns></returns>
  5891. [HttpPost]
  5892. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5893. {
  5894. var jw = JsonView(false);
  5895. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5896. if (groupInfo == null)
  5897. {
  5898. jw.Msg = "团组信息不存在!";
  5899. return Ok(jw);
  5900. }
  5901. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5902. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5903. && x.IsDel == 0);
  5904. if (key == null)
  5905. {
  5906. jw.Msg = "Ctable指向错误!";
  5907. return Ok(jw);
  5908. }
  5909. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5910. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5911. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5912. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5913. var io = new IOOperatorHelper();
  5914. var Zips = new Dictionary<string, Stream>();
  5915. foreach (var item in dbQuery)
  5916. {
  5917. if (System.IO.File.Exists(item.FilePath))
  5918. {
  5919. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5920. {
  5921. byte[] bytes = new byte[fileStream.Length];
  5922. fileStream.Read(bytes, 0, bytes.Length);
  5923. fileStream.Close();
  5924. var stream = new MemoryStream(bytes);
  5925. while (Zips.ContainsKey(item.FileName))
  5926. {
  5927. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5928. }
  5929. Zips.Add(item.FileName, stream);
  5930. }
  5931. }
  5932. }
  5933. if (Zips.Count > 0)
  5934. {
  5935. var byts = io.ConvertZipStream(Zips);
  5936. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5937. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5938. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5939. }
  5940. else
  5941. {
  5942. jw.Msg = "暂无生成文件!";
  5943. }
  5944. return Ok(jw);
  5945. }
  5946. /// <summary>
  5947. /// 删除该团组下的指定文件
  5948. /// </summary>
  5949. /// <param name="dto"></param>
  5950. /// <returns></returns>
  5951. [HttpPost]
  5952. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5953. {
  5954. var jw = JsonView(false);
  5955. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5956. if (sing == null)
  5957. {
  5958. jw.Msg = "暂无";
  5959. return Ok(jw);
  5960. }
  5961. if (System.IO.File.Exists(sing.FilePath))
  5962. {
  5963. try
  5964. {
  5965. System.IO.File.Delete(sing.FilePath);
  5966. }
  5967. catch (Exception ex)
  5968. {
  5969. jw.Msg = "删除失败!" + ex.Message;
  5970. return Ok(jw);
  5971. }
  5972. }
  5973. sing.IsDel = 1;
  5974. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5975. sing.DeleteUserId = dto.UserId;
  5976. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5977. jw = JsonView(true, "删除成功!");
  5978. return Ok(jw);
  5979. }
  5980. #endregion
  5981. #region 共享文件上传
  5982. /// <summary>
  5983. /// 共享文件数据初始化
  5984. /// </summary>
  5985. /// <returns></returns>
  5986. [HttpGet]
  5987. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5988. {
  5989. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5990. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5991. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5992. .Select(x => x.Id)
  5993. .ToList()
  5994. .Contains(userid);
  5995. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5996. .Where(x => x.STid == 111 && x.IsDel == 0)
  5997. .Select(x => new
  5998. {
  5999. x.Name,
  6000. x.Id,
  6001. }).ToList();
  6002. if (isMarketingDepartment)
  6003. {
  6004. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  6005. }
  6006. if (portType == 1)
  6007. {
  6008. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  6009. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  6010. .Where(x => x.IsDel == 0)
  6011. .OrderByDescending(x => x.VisitDate)
  6012. .Select(x => new
  6013. {
  6014. x.TeamName,
  6015. x.Id,
  6016. x.CityId,
  6017. })
  6018. .ToList()
  6019. .Select(x =>
  6020. {
  6021. var provinceId = x.CityId;
  6022. var isDefualtVal = true;
  6023. if (provinceId > 0)
  6024. {
  6025. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  6026. if (parentId != null)
  6027. {
  6028. isDefualtVal = false;
  6029. provinceId = (int)parentId;
  6030. }
  6031. }
  6032. if (isDefualtVal)
  6033. {
  6034. provinceId = 122; //默认四川
  6035. }
  6036. return new
  6037. {
  6038. x.TeamName,
  6039. x.Id,
  6040. provinceId,
  6041. };
  6042. })
  6043. .ToList();
  6044. return Ok(JsonView(true, "SUCCESS!", new
  6045. {
  6046. dropDownType,
  6047. dropDownGroupList,
  6048. isMarketingDepartment
  6049. }));
  6050. }
  6051. else if (portType == 2 || portType == 3)
  6052. {
  6053. return Ok(JsonView(true, "SUCCESS!", new
  6054. {
  6055. dropDownType,
  6056. isMarketingDepartment
  6057. }));
  6058. }
  6059. else
  6060. {
  6061. return Ok(JsonView(false, "portType有误!"));
  6062. }
  6063. }
  6064. /// <summary>
  6065. /// 共享文件上传
  6066. /// </summary>
  6067. /// <param name="dto"></param>
  6068. /// <returns></returns>
  6069. [HttpPost]
  6070. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  6071. {
  6072. var isGroup = new List<int> { 1412 };
  6073. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  6074. {
  6075. return Ok(JsonView(false, "该文件需要关联团组!"));
  6076. }
  6077. if (dto.Files == null || dto.Files.Count == 0)
  6078. {
  6079. return Ok(JsonView(false, "无文件信息!"));
  6080. }
  6081. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  6082. {
  6083. return Ok(JsonView(false, "文件大小超过20M!"));
  6084. }
  6085. if (dto.Userid < 1)
  6086. {
  6087. return Ok(JsonView(false, "请传入有效的Userid!"));
  6088. }
  6089. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  6090. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  6091. .Select((u, j) => new
  6092. {
  6093. u.CnName,
  6094. UserId = u.Id,
  6095. j.JobName,
  6096. })
  6097. .First();
  6098. if (jobInfo == null)
  6099. {
  6100. return Ok(JsonView(false, "请传入有效的Userid!"));
  6101. }
  6102. var commonFileExtensions = new List<string>
  6103. {
  6104. // 文本文件
  6105. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  6106. // 图片文件
  6107. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  6108. // 视频文件
  6109. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  6110. // 音频文件
  6111. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  6112. // 压缩文件
  6113. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  6114. // 数据文件
  6115. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  6116. };
  6117. try
  6118. {
  6119. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  6120. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  6121. commonFileExtensions.AddRange(settingExtend);
  6122. }
  6123. catch (Exception)
  6124. { }
  6125. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  6126. if (setdata == null)
  6127. {
  6128. return Ok(JsonView(false, "请传入有效的FileType!"));
  6129. }
  6130. var insertList = new List<Grp_GroupShareFile>();
  6131. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  6132. if (!Directory.Exists(winPath))
  6133. {
  6134. Directory.CreateDirectory(winPath);
  6135. }
  6136. foreach (var item in dto.Files)
  6137. {
  6138. var houzui = Path.GetExtension(item.FileName);
  6139. if (!commonFileExtensions.Contains(houzui))
  6140. {
  6141. return Ok(JsonView(false, "未知后缀名称!"));
  6142. }
  6143. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  6144. var saveFilePath = winPath + fileName;
  6145. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6146. {
  6147. item.CopyTo(fs);
  6148. fs.Flush();
  6149. }
  6150. var fileDetail = new Grp_GroupShareFile()
  6151. {
  6152. CreateUserId = dto.Userid,
  6153. CreateTime = DateTime.Now,
  6154. UploadJob = jobInfo.JobName,
  6155. FileName = fileName,
  6156. FileType = dto.FileType,
  6157. Diid = dto.Diid,
  6158. FilePath = winPath + fileName,
  6159. };
  6160. insertList.Add(fileDetail);
  6161. }
  6162. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  6163. return Ok(JsonView(true, "保存成功!"));
  6164. }
  6165. /// <summary>
  6166. /// 查询共享文件列表
  6167. /// </summary>
  6168. /// <param name="dto"></param>
  6169. /// <returns></returns>
  6170. [HttpPost]
  6171. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  6172. {
  6173. var isGroup = new List<int> { 1412 };
  6174. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  6175. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  6176. .And(x => x.Diid == dto.Diid)
  6177. .And(x => x.FileType == dto.FileType)
  6178. .And(x => x.IsDel == 0)
  6179. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  6180. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  6181. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  6182. int totalCount = 0;
  6183. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  6184. .Where(queryExpression.ToExpression())
  6185. .OrderBy(x => x.UploadJob)
  6186. .Select(x => new
  6187. {
  6188. x.Id,
  6189. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  6190. x.FileName,
  6191. x.FileType,
  6192. x.CreateTime,
  6193. })
  6194. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  6195. return Ok(JsonView(true, "SUCCESS!", new
  6196. {
  6197. FileList = dbQuery,
  6198. dto.PageSize,
  6199. dto.PageIndex,
  6200. totalCount
  6201. }));
  6202. }
  6203. /// <summary>
  6204. /// 删除共享文件模块下的指定文件
  6205. /// </summary>
  6206. /// <param name="dto"></param>
  6207. /// <returns></returns>
  6208. [HttpPost]
  6209. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  6210. {
  6211. var jw = JsonView(false);
  6212. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6213. if (sing == null)
  6214. {
  6215. jw.Msg = "暂无文件信息!";
  6216. return Ok(jw);
  6217. }
  6218. if (sing.CreateUserId != dto.UserId)
  6219. {
  6220. jw.Msg = "只能删除自己上传的文件!";
  6221. return Ok(jw);
  6222. }
  6223. if (System.IO.File.Exists(sing.FilePath))
  6224. {
  6225. try
  6226. {
  6227. System.IO.File.Delete(sing.FilePath);
  6228. }
  6229. catch (Exception ex)
  6230. {
  6231. jw.Msg = "删除失败!" + ex.Message;
  6232. return Ok(jw);
  6233. }
  6234. }
  6235. sing.IsDel = 1;
  6236. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6237. sing.DeleteUserId = dto.UserId;
  6238. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6239. jw = JsonView(true, "删除成功!");
  6240. return Ok(jw);
  6241. }
  6242. #endregion
  6243. #region 团组英文资料
  6244. /// <summary>
  6245. /// 查询团组英文所有资料
  6246. /// </summary>
  6247. /// <param name="dto"></param>
  6248. /// <returns></returns>
  6249. [HttpPost]
  6250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6251. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6252. {
  6253. try
  6254. {
  6255. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6256. if (groupData.Code != 0)
  6257. {
  6258. return Ok(JsonView(false, groupData.Msg));
  6259. }
  6260. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6261. }
  6262. catch (Exception ex)
  6263. {
  6264. return Ok(JsonView(false, ex.Message));
  6265. throw;
  6266. }
  6267. }
  6268. /// <summary>
  6269. /// 团组英文资料操作(Status:1.新增,2.修改)
  6270. /// </summary>
  6271. /// <param name="dto"></param>
  6272. /// <returns></returns>
  6273. [HttpPost]
  6274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6275. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6276. {
  6277. try
  6278. {
  6279. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6280. if (groupData.Code != 0)
  6281. {
  6282. return Ok(JsonView(false, groupData.Msg));
  6283. }
  6284. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6285. }
  6286. catch (Exception ex)
  6287. {
  6288. return Ok(JsonView(false, ex.Message));
  6289. throw;
  6290. }
  6291. }
  6292. /// <summary>
  6293. /// 团组英文资料Id查询数据
  6294. /// </summary>
  6295. /// <param name="dto"></param>
  6296. /// <returns></returns>
  6297. [HttpPost]
  6298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6299. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6300. {
  6301. try
  6302. {
  6303. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6304. if (_DelegationEnData != null)
  6305. {
  6306. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6307. }
  6308. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6309. }
  6310. catch (Exception ex)
  6311. {
  6312. return Ok(JsonView(false, "程序错误!"));
  6313. throw;
  6314. }
  6315. }
  6316. /// <summary>
  6317. /// 团组英文资料删除
  6318. /// </summary>
  6319. /// <param name="dto"></param>
  6320. /// <returns></returns>
  6321. [HttpPost]
  6322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6323. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6324. {
  6325. try
  6326. {
  6327. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6328. if (!res)
  6329. {
  6330. return Ok(JsonView(false, "删除失败"));
  6331. }
  6332. return Ok(JsonView(true, "删除成功!"));
  6333. }
  6334. catch (Exception ex)
  6335. {
  6336. return Ok(JsonView(false, ex.Message));
  6337. throw;
  6338. }
  6339. }
  6340. #endregion
  6341. #region 导出邀请函
  6342. /// <summary>
  6343. /// 导出邀请函页面初始化
  6344. /// </summary>
  6345. /// <param name="dto"></param>
  6346. /// <returns></returns>
  6347. [HttpPost]
  6348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6349. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6350. {
  6351. try
  6352. {
  6353. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6354. var crm_Deles = new List<Crm_DeleClient>();
  6355. if (dto.DiId == 0)
  6356. {
  6357. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6358. }
  6359. else
  6360. {
  6361. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6362. }
  6363. return Ok(JsonView(true, "查询成功!", new
  6364. {
  6365. deleClient = crm_Deles,
  6366. delegations = grp_Delegations
  6367. }));
  6368. }
  6369. catch (Exception ex)
  6370. {
  6371. return Ok(JsonView(false, "程序错误!"));
  6372. throw;
  6373. }
  6374. }
  6375. /// <summary>
  6376. /// 导出邀请函
  6377. /// </summary>
  6378. /// <param name="dto"></param>
  6379. /// <returns></returns>
  6380. [HttpPost]
  6381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6382. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6383. {
  6384. #region 参数验证
  6385. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6386. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6387. #endregion
  6388. try
  6389. {
  6390. var transDic = new Dictionary<string, string>();
  6391. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6392. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6393. From Grp_TourClientList tcl
  6394. Left Join
  6395. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6396. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6397. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6398. From Crm_DeleClient dc
  6399. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6400. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6401. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6402. Where dc.IsDel = 0) temp
  6403. On temp.DcId =tcl.ClientId
  6404. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6405. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6406. var texts = new List<string>();
  6407. if (datas.Count != 0)
  6408. {
  6409. foreach (TourClientListDetailsView item in datas)
  6410. {
  6411. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6412. {
  6413. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6414. }
  6415. else
  6416. {
  6417. string name = item.LastName + item.FirstName;
  6418. texts.Add(name);
  6419. }
  6420. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6421. {
  6422. if (!transDic.ContainsKey(item.Job))
  6423. {
  6424. texts.Add(item.Job);
  6425. }
  6426. }
  6427. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6428. {
  6429. texts.Add(item.CompanyFullName);
  6430. }
  6431. }
  6432. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6433. if (transData.Count > 0)
  6434. {
  6435. foreach (TranslateResult item in transData)
  6436. {
  6437. if (!transDic.ContainsKey(item.Query))
  6438. {
  6439. transDic.Add(item.Query, item.Translation);
  6440. }
  6441. }
  6442. }
  6443. var list = new List<GuestList>();
  6444. foreach (var dele in datas)
  6445. {
  6446. var guestList = new GuestList();
  6447. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6448. {
  6449. guestList.Name = dele.Pinyin;
  6450. }
  6451. else
  6452. {
  6453. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6454. guestList.Name = Name;
  6455. }
  6456. if (dele.Sex == 0)
  6457. {
  6458. guestList.Sex = "Male";
  6459. }
  6460. else if (dele.Sex == 1)
  6461. {
  6462. guestList.Sex = "Female";
  6463. }
  6464. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6465. if (!string.IsNullOrEmpty(dele.Job))
  6466. {
  6467. guestList.Job = dele.Job;
  6468. }
  6469. list.Add(guestList);
  6470. }
  6471. //载入模板
  6472. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6473. var builder = new DocumentBuilder(doc);
  6474. //获取word里所有表格
  6475. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6476. //获取所填表格的序数
  6477. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6478. var rowStart = tableOne.Rows[0]; //获取第1行
  6479. //循环赋值
  6480. for (int i = 0; i < list.Count; i++)
  6481. {
  6482. builder.MoveToCell(0, i + 1, 0, 0);
  6483. builder.Write(list[i].Name.ToString());
  6484. builder.MoveToCell(0, i + 1, 1, 0);
  6485. builder.Write(list[i].Sex.ToString());
  6486. builder.MoveToCell(0, i + 1, 2, 0);
  6487. builder.Write(list[i].DOB.ToString());
  6488. builder.MoveToCell(0, i + 1, 3, 0);
  6489. builder.Write(list[i].Job.ToString());
  6490. }
  6491. //删除多余行
  6492. while (tableOne.Rows.Count > list.Count + 1)
  6493. {
  6494. tableOne.Rows.RemoveAt(list.Count + 1);
  6495. }
  6496. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6497. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6498. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6499. doc.Save(filePath);
  6500. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6501. return Ok(JsonView(true, "操作成功!", Url));
  6502. }
  6503. else
  6504. {
  6505. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6506. }
  6507. }
  6508. catch (Exception ex)
  6509. {
  6510. return Ok(JsonView(false, ex.Message));
  6511. throw;
  6512. }
  6513. }
  6514. #endregion
  6515. #region 团组经理模块 出入境费用
  6516. /// <summary>
  6517. /// 团组模块 - 出入境费用 - 省份基础数据源
  6518. /// </summary>
  6519. /// <returns></returns>
  6520. [HttpGet]
  6521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6522. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6523. {
  6524. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6525. }
  6526. /// <summary>
  6527. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6528. /// </summary>
  6529. /// <param name="dto"></param>
  6530. /// <returns></returns>
  6531. [HttpPost]
  6532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6533. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6534. {
  6535. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6536. var groupNamFirst = groupNameData.FirstOrDefault();
  6537. //SetDataInfoView
  6538. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6539. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6540. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6541. //验证城市归属并给默认值
  6542. int provinceId = 122;
  6543. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6544. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6545. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6546. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6547. return Ok(JsonView(true, "查询成功!", new
  6548. {
  6549. GroupNameData = groupNameData,
  6550. CurrencyData = _CurrencyData,
  6551. WordTypeData = wordTypeData,
  6552. ExcelTypeData = excelTypeData,
  6553. CurrencyInit = _currencyInfos,
  6554. ViewPermissionData = viewPermissionData
  6555. }));
  6556. }
  6557. /// <summary>
  6558. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6559. /// </summary>
  6560. /// <returns></returns>
  6561. [HttpGet("{provinceId}")]
  6562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6563. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6564. {
  6565. //验证城市归属并给默认值
  6566. if (provinceId < 1) provinceId = 122;
  6567. /*
  6568. * 122 四川
  6569. * 108 贵州
  6570. * 103 重庆
  6571. * 132 云南
  6572. */
  6573. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6574. return Ok(JsonView(true, "查询成功!", new
  6575. {
  6576. WordTypeData = wordTypeData,
  6577. ExcelTypeData = excelTypeData,
  6578. }));
  6579. }
  6580. /// <summary>
  6581. /// 团组模块 - 出入境费用
  6582. /// 实时汇率 tips
  6583. /// 签证费用 tips
  6584. /// 机票费用 tips
  6585. /// </summary>
  6586. /// <returns></returns>
  6587. [HttpPost]
  6588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6589. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6590. {
  6591. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6592. //默认币种显示
  6593. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6594. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6595. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6596. return Ok(JsonView(true, "查询成功!", new
  6597. {
  6598. //GroupNameData = groupNameData.Data,
  6599. visaData = visaData.Data,
  6600. airData,
  6601. reteInfos
  6602. }));
  6603. }
  6604. /// <summary>
  6605. /// 团组模块 - 出入境费用 - Info
  6606. /// </summary>
  6607. /// <param name="dto"></param>
  6608. /// <returns></returns>
  6609. [HttpPost]
  6610. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6612. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6613. {
  6614. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6615. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6616. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6617. }
  6618. /// <summary>
  6619. /// 团组模块 - 出入境费用 - 设置view权限
  6620. /// </summary>
  6621. /// <returns></returns>
  6622. [HttpPost]
  6623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6624. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6625. {
  6626. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6627. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6628. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6629. var permissions = new List<Grp_EnterExitCostPermission>();
  6630. foreach (var userId in dto.UserIds)
  6631. {
  6632. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6633. }
  6634. if (permissions.Any())
  6635. {
  6636. _sqlSugar.BeginTran();
  6637. try
  6638. {
  6639. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6640. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6641. if (result < 1)
  6642. {
  6643. _sqlSugar.RollbackTran();
  6644. return Ok(JsonView(false));
  6645. }
  6646. }
  6647. catch (Exception ex)
  6648. {
  6649. _sqlSugar.RollbackTran();
  6650. return Ok(JsonView(false, ex.Message));
  6651. }
  6652. _sqlSugar.CommitTran();
  6653. return Ok(JsonView(true));
  6654. }
  6655. return Ok(JsonView(false));
  6656. }
  6657. /// <summary>
  6658. /// 团组模块 - 出入境费用 - Add And Update
  6659. /// </summary>
  6660. /// <returns></returns>
  6661. [HttpPost]
  6662. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6664. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6665. {
  6666. try
  6667. {
  6668. var rateRecords = new List<RateRecordInfo>();
  6669. #region 汇率保存前存储
  6670. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  6671. if (info != null)
  6672. {
  6673. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  6674. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  6675. {
  6676. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  6677. {
  6678. CurrencyCode = x.CurrencyCode,
  6679. CurrencyName = x.CurrencyName,
  6680. UpdatePreRate = x.Rate,
  6681. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  6682. }).ToList();
  6683. }
  6684. else
  6685. {
  6686. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6687. {
  6688. CurrencyCode = x.CurrencyCode,
  6689. CurrencyName = x.CurrencyName,
  6690. UpdatePreRate = 0.00M,
  6691. UpdateBreRate = x.Rate
  6692. }).ToList();
  6693. }
  6694. }
  6695. else
  6696. {
  6697. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6698. {
  6699. CurrencyCode = x.CurrencyCode,
  6700. CurrencyName = x.CurrencyName,
  6701. UpdatePreRate = 0.00M,
  6702. UpdateBreRate = x.Rate
  6703. }).ToList();
  6704. }
  6705. #endregion
  6706. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6707. if (dto.DayOtherPriceData.Any())
  6708. {
  6709. var inserList = dto.DayOtherPriceData
  6710. .Where(x => x.Id == 0)
  6711. .Select(x => new Grp_DayOtherPrice
  6712. {
  6713. Cost = x.Cost,
  6714. Id = x.Id,
  6715. CreateTime = DateTime.Now,
  6716. CreateUserId = dto.UserId,
  6717. Currency = x.Currency,
  6718. Diid = x.DiId,
  6719. Index = x.Index,
  6720. IsDel = 0,
  6721. SetDataId = x.SetDataId,
  6722. SubTotal = x.SubTotal,
  6723. Remark = x.Remark
  6724. })
  6725. .ToList();
  6726. var updateList = dto.DayOtherPriceData
  6727. .Where(x => x.Id != 0)
  6728. .Select(x => new Grp_DayOtherPrice
  6729. {
  6730. Cost = x.Cost,
  6731. Id = x.Id,
  6732. CreateTime = DateTime.Now,
  6733. CreateUserId = dto.UserId,
  6734. Currency = x.Currency,
  6735. Diid = x.DiId,
  6736. Index = x.Index,
  6737. IsDel = 0,
  6738. SetDataId = x.SetDataId,
  6739. SubTotal = x.SubTotal,
  6740. Remark = x.Remark
  6741. })
  6742. .ToList();
  6743. //添加
  6744. _sqlSugar.BeginTran();
  6745. if (inserList.Any())
  6746. {
  6747. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6748. }
  6749. if (updateList.Any())
  6750. {
  6751. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6752. }
  6753. _sqlSugar.CommitTran();
  6754. }
  6755. if (data.Code != 0)
  6756. {
  6757. return Ok(JsonView(false, data.Msg));
  6758. }
  6759. //生成默认文件pdf并且通知人员
  6760. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6761. {
  6762. DiId = dto.DiId,
  6763. ExportType = 1,
  6764. SubTypeId = 1005
  6765. }, "pdf");
  6766. //发送通知
  6767. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6768. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6769. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6770. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6771. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6772. //汇率信息记录
  6773. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6774. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  6775. //汇率验证、反推
  6776. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  6777. if (isSendMsg)
  6778. {
  6779. //消息推送
  6780. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  6781. }
  6782. #region //日志汇率记录
  6783. //按照已使用币种记录
  6784. if (checkCurrencys != null && checkCurrencys.Count > 0)
  6785. {
  6786. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  6787. //汇率记录中加入实时汇率
  6788. if (liveRates != null && liveRates.Count > 0)
  6789. {
  6790. foreach (var item in rateRecords)
  6791. {
  6792. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  6793. }
  6794. }
  6795. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  6796. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  6797. var logContent = new StringBuilder();
  6798. foreach (var item in rateRecords)
  6799. {
  6800. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  6801. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  6802. logContent.AppendLine(msg);
  6803. }
  6804. _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());
  6805. }
  6806. #endregion
  6807. return Ok(JsonView(true, data.Msg, data.Data));
  6808. }
  6809. catch (Exception ex)
  6810. {
  6811. return Ok(JsonView(false, ex.Message));
  6812. }
  6813. }
  6814. /// <summary>
  6815. /// 团组模块 - 出入境费用 - Confirm 费用
  6816. /// </summary>
  6817. /// <returns></returns>
  6818. [HttpPost]
  6819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6820. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6821. {
  6822. //TODO:测试完毕需把对应的用户ID更改
  6823. //1、数据表添加字段
  6824. //2、更改字段接口()
  6825. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6826. //3、确认成功 给财务发送消息
  6827. if (_view.Code == 200)
  6828. {
  6829. if (dto.Type == 1)
  6830. {
  6831. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6832. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6833. }
  6834. }
  6835. return Ok(_view);
  6836. }
  6837. /// <summary>
  6838. /// 团组模块 - 出入境费用 - File download
  6839. /// </summary>
  6840. /// <param name="dto"></param>
  6841. /// <returns></returns>
  6842. [HttpPost]
  6843. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6845. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6846. {
  6847. try
  6848. {
  6849. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6850. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6851. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6852. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6853. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6854. 3 团组成员名单 1 团组成员名单", ""));
  6855. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6856. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6857. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6858. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6859. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6860. //数据源
  6861. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6862. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6863. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6864. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6865. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6866. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6867. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6868. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6869. .Select((x, a, b) => new
  6870. {
  6871. x.Index,
  6872. itemName = a.Name,
  6873. CurrencyStr = b.Name,
  6874. x.Cost,
  6875. x.SubTotal,
  6876. x.Remark
  6877. })
  6878. .OrderBy((x) => x.Index)
  6879. .ToList(); //其他款项费用
  6880. var peiceItemCurrencys = new List<string>();
  6881. if (_DayAndCosts.Any())
  6882. {
  6883. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6884. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6885. }
  6886. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6887. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6888. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6889. {
  6890. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6891. }
  6892. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6893. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6894. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6895. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6896. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6897. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6898. .Select((tcl, dc, cc) => new ClientInfo
  6899. {
  6900. LastName = dc.LastName,
  6901. FirstName = dc.FirstName,
  6902. Sex = dc.Sex,
  6903. Birthday = dc.BirthDay,
  6904. Company = cc.CompanyFullName,
  6905. Job = dc.Job
  6906. })
  6907. .ToList();
  6908. foreach (var item in DeleClientList)
  6909. {
  6910. EncryptionProcessor.DecryptProperties(item);
  6911. }
  6912. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6913. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6914. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6915. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6916. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6917. if (dto.ExportType == 1) //明细表
  6918. {
  6919. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6920. {
  6921. //获取模板
  6922. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6923. //载入模板
  6924. var doc = new Document(tempPath);
  6925. var builder = new DocumentBuilder(doc);
  6926. var dic = new Dictionary<string, string>();
  6927. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6928. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6929. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6930. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6931. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6932. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6933. //境内费用(其他费用)
  6934. if (_EnterExitCosts.ChoiceOne == 1)
  6935. {
  6936. string row1_1 = "";
  6937. if (_EnterExitCosts.Visa > 0)
  6938. {
  6939. //insidePayTotal += _EnterExitCosts.Visa;
  6940. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  6941. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6942. //{
  6943. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6944. //}
  6945. }
  6946. string row1_2 = "";
  6947. if (_EnterExitCosts.YiMiao > 0)
  6948. {
  6949. //insidePayTotal += _EnterExitCosts.YiMiao;
  6950. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  6951. }
  6952. if (_EnterExitCosts.HeSuan > 0)
  6953. {
  6954. //insidePayTotal += _EnterExitCosts.HeSuan;
  6955. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  6956. }
  6957. if (_EnterExitCosts.Service > 0)
  6958. {
  6959. //insidePayTotal += _EnterExitCosts.Service;
  6960. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  6961. }
  6962. string row1_3 = "";
  6963. if (_EnterExitCosts.Safe > 0)
  6964. {
  6965. //insidePayTotal += _EnterExitCosts.Safe;
  6966. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  6967. }
  6968. if (_EnterExitCosts.Ticket > 0)
  6969. {
  6970. //insidePayTotal += _EnterExitCosts.Ticket;
  6971. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  6972. }
  6973. string row1 = "";
  6974. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6975. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6976. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6977. row1 += $"备注:{_EnterExitCosts.Remark}";
  6978. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6979. dic.Add("Row1Str", row1);
  6980. }
  6981. string airTotalStr = string.Empty,
  6982. airPriceStr = string.Empty;
  6983. //经济舱
  6984. if (_EnterExitCosts.SumJJC == 1)
  6985. {
  6986. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  6987. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  6988. }
  6989. //公务舱
  6990. if (_EnterExitCosts.SumGWC == 1)
  6991. {
  6992. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  6993. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  6994. }
  6995. //头等舱
  6996. if (_EnterExitCosts.SumTDC == 1)
  6997. {
  6998. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  6999. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  7000. }
  7001. //汇率描述
  7002. string rateStr = "";
  7003. if (peiceItemCurrencyInfos.Any())
  7004. {
  7005. rateStr = "\r\n汇率描述:";
  7006. foreach (var item in peiceItemCurrencyInfos)
  7007. {
  7008. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  7009. }
  7010. }
  7011. string twoItemRemark = "备注:";
  7012. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7013. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7014. dic.Add("AirTotalStr", airTotalStr);
  7015. dic.Add("AirPriceStr", airPriceStr);
  7016. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7017. dic.Add("TwoItemRemark", twoItemRemark);
  7018. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7019. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7020. int table1Row = 0,
  7021. table2Row = 0,
  7022. table3Row = 0,
  7023. table4Row = 0,
  7024. table5Row = 0;
  7025. //住宿费
  7026. if (_EnterExitCosts.ChoiceThree == 1)
  7027. {
  7028. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7029. table1Row = dac1.Count;
  7030. #region 填充word表格内容
  7031. for (int i = 0; i < dac1.Count; i++)
  7032. {
  7033. Grp_DayAndCost dac = dac1[i];
  7034. if (dac == null) continue;
  7035. builder.MoveToCell(0, i, 0, 0);
  7036. builder.Write("第" + dac.Days.ToString() + "晚:");
  7037. builder.MoveToCell(0, i, 1, 0);
  7038. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7039. //builder.Write(dac.Place == null ? "" : dac.Place);
  7040. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7041. builder.MoveToCell(0, i, 2, 0);
  7042. builder.Write("费用标准:");
  7043. string curr = "";
  7044. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7045. if (currData != null)
  7046. {
  7047. curr = currData.Name;
  7048. }
  7049. builder.MoveToCell(0, i, 3, 0);
  7050. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7051. builder.MoveToCell(0, i, 4, 0);
  7052. builder.Write("费用小计:");
  7053. builder.MoveToCell(0, i, 5, 0);
  7054. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7055. }
  7056. #endregion
  7057. }
  7058. else dic.Add("SubZS", "0.00");
  7059. //删除多余行
  7060. while (table1.Rows.Count > table1Row)
  7061. {
  7062. table1.Rows.RemoveAt(table1Row);
  7063. }
  7064. //伙食费
  7065. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7066. if (_EnterExitCosts.ChoiceFour == 1)
  7067. {
  7068. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7069. table2Row = dac2.Count;
  7070. #region 填充word表格内容
  7071. for (int i = 0; i < dac2.Count; i++)
  7072. {
  7073. Grp_DayAndCost dac = dac2[i];
  7074. if (dac == null) continue;
  7075. builder.MoveToCell(1, i, 0, 0);
  7076. builder.Write("第" + dac.Days.ToString() + "天:");
  7077. builder.MoveToCell(1, i, 1, 0);
  7078. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7079. builder.MoveToCell(1, i, 2, 0);
  7080. builder.Write("费用标准:");
  7081. string curr = "";
  7082. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7083. if (currData != null)
  7084. {
  7085. curr = currData.Name;
  7086. }
  7087. builder.MoveToCell(1, i, 3, 0);
  7088. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7089. builder.MoveToCell(1, i, 4, 0);
  7090. builder.Write("费用小计:");
  7091. builder.MoveToCell(1, i, 5, 0);
  7092. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7093. }
  7094. #endregion
  7095. }
  7096. else dic.Add("SubHS", "0.00");
  7097. //删除多余行
  7098. while (table2.Rows.Count > table2Row)
  7099. {
  7100. table2.Rows.RemoveAt(table2Row);
  7101. }
  7102. //公杂费
  7103. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7104. if (_EnterExitCosts.ChoiceFive == 1)
  7105. {
  7106. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7107. table3Row = dac3.Count;
  7108. #region 填充word表格内容
  7109. for (int i = 0; i < dac3.Count; i++)
  7110. {
  7111. Grp_DayAndCost dac = dac3[i];
  7112. if (dac == null) continue;
  7113. builder.MoveToCell(2, i, 0, 0);
  7114. builder.Write("第" + dac.Days.ToString() + "天:");
  7115. builder.MoveToCell(2, i, 1, 0);
  7116. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7117. builder.MoveToCell(2, i, 2, 0);
  7118. builder.Write("费用标准:");
  7119. string curr = "";
  7120. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7121. if (currData != null)
  7122. {
  7123. curr = currData.Name;
  7124. }
  7125. builder.MoveToCell(2, i, 3, 0);
  7126. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7127. builder.MoveToCell(2, i, 4, 0);
  7128. builder.Write("费用小计:");
  7129. builder.MoveToCell(2, i, 5, 0);
  7130. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7131. }
  7132. //删除多余行
  7133. while (table3.Rows.Count > table3Row)
  7134. {
  7135. table3.Rows.RemoveAt(table3Row);
  7136. }
  7137. #endregion
  7138. }
  7139. else dic.Add("SubGZF", "0.00");
  7140. //删除多余行
  7141. while (table3.Rows.Count > table3Row)
  7142. {
  7143. table3.Rows.RemoveAt(table3Row);
  7144. }
  7145. //培训费
  7146. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7147. if (_EnterExitCosts.ChoiceSix == 1)
  7148. {
  7149. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  7150. dic.Add("SubPX", pxStr);
  7151. table4Row = dac4.Count;
  7152. #region 填充word表格内容
  7153. for (int i = 0; i < dac4.Count; i++)
  7154. {
  7155. Grp_DayAndCost dac = dac4[i];
  7156. if (dac == null) continue;
  7157. builder.MoveToCell(3, i, 0, 0);
  7158. builder.Write("第" + dac.Days.ToString() + "天:");
  7159. builder.MoveToCell(3, i, 1, 0);
  7160. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7161. builder.MoveToCell(3, i, 2, 0);
  7162. builder.Write("费用标准:");
  7163. string curr = "";
  7164. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7165. if (currData != null)
  7166. {
  7167. curr = currData.Name;
  7168. }
  7169. builder.MoveToCell(3, i, 3, 0);
  7170. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7171. builder.MoveToCell(3, i, 4, 0);
  7172. builder.Write("费用小计:");
  7173. builder.MoveToCell(3, i, 5, 0);
  7174. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7175. }
  7176. #endregion
  7177. }
  7178. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  7179. //删除多余行
  7180. while (table4.Rows.Count > table4Row)
  7181. {
  7182. table4.Rows.RemoveAt(table4Row);
  7183. }
  7184. //其他费用
  7185. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7186. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7187. {
  7188. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  7189. dic.Add("titleQi", qtStr);
  7190. table5Row = dac5.Count;
  7191. #region 填充word表格内容
  7192. for (int i = 0; i < dac5.Count; i++)
  7193. {
  7194. var dac = dac5[i];
  7195. if (dac == null) continue;
  7196. builder.MoveToCell(4, i, 0, 0);
  7197. builder.Write("第" + dac.Index.ToString() + "项:");
  7198. builder.MoveToCell(4, i, 1, 0);
  7199. builder.Write(dac.itemName);
  7200. builder.MoveToCell(4, i, 2, 0);
  7201. builder.Write("费用标准:");
  7202. builder.MoveToCell(4, i, 3, 0);
  7203. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7204. builder.MoveToCell(4, i, 4, 0);
  7205. builder.Write("费用小计:");
  7206. builder.MoveToCell(4, i, 5, 0);
  7207. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7208. builder.MoveToCell(4, i, 6, 0);
  7209. builder.Write("备注:");
  7210. builder.MoveToCell(4, i, 7, 0);
  7211. builder.Write(dac.Remark);
  7212. }
  7213. #endregion
  7214. }
  7215. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7216. //删除多余行
  7217. while (table5.Rows.Count > table5Row)
  7218. {
  7219. table5.Rows.RemoveAt(table5Row);
  7220. }
  7221. //加上其他费用
  7222. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7223. decimal subJJC = 0.00M,
  7224. subGWC = 0.00M,
  7225. subTDC = 0.00M;
  7226. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7227. string totalLabel = string.Format("全部费用总计:");
  7228. //经济舱
  7229. if (_EnterExitCosts.SumJJC == 1)
  7230. {
  7231. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7232. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  7233. }
  7234. //公务舱
  7235. if (_EnterExitCosts.SumGWC == 1)
  7236. {
  7237. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7238. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  7239. }
  7240. //头等舱
  7241. if (_EnterExitCosts.SumTDC == 1)
  7242. {
  7243. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7244. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  7245. }
  7246. //TotalLabel
  7247. dic.Add("TotalLabel", totalLabel);
  7248. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7249. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7250. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7251. #region 填充word模板书签内容
  7252. foreach (var key in dic.Keys)
  7253. {
  7254. Bookmark bookmark = doc.Range.Bookmarks[key];
  7255. if (bookmark != null)
  7256. {
  7257. builder.MoveToBookmark(key);
  7258. builder.Write(dic[key]);
  7259. }
  7260. }
  7261. #endregion
  7262. #region 设置页眉
  7263. string userLabel = string.Empty;
  7264. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7265. if (currUserInfo != null)
  7266. {
  7267. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  7268. if (userInfo != null)
  7269. {
  7270. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  7271. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  7272. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  7273. }
  7274. }
  7275. //设置页脚
  7276. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  7277. #endregion
  7278. //文件名
  7279. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  7280. AsposeHelper.removewatermark_v2180();
  7281. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7282. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7283. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7284. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7285. }
  7286. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7287. {
  7288. //获取模板
  7289. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7290. //载入模板
  7291. var doc = new Document(tempPath);
  7292. var builder = new DocumentBuilder(doc);
  7293. var dic = new Dictionary<string, string>();
  7294. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7295. {
  7296. var list = new List<string>();
  7297. try
  7298. {
  7299. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7300. foreach (var item in spilitArr)
  7301. {
  7302. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7303. var depCode = spDotandEmpty[2].Substring(0, 3);
  7304. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7305. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7306. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7307. list.Add(depName);
  7308. list.Add(arrName);
  7309. }
  7310. list = list.Distinct().ToList();
  7311. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7312. }
  7313. catch (Exception)
  7314. {
  7315. dic.Add("ReturnCode", "行程录入不正确!");
  7316. }
  7317. }
  7318. else
  7319. {
  7320. dic.Add("ReturnCode", "未录入行程!");
  7321. }
  7322. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7323. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7324. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7325. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7326. {
  7327. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7328. dic.Add("Day", sp.Days.ToString());
  7329. }
  7330. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7331. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7332. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7333. //dic.Add("Names", Names);
  7334. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7335. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7336. decimal dac1totalPrice = 0.00M;
  7337. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7338. foreach (var dac in dac1)
  7339. {
  7340. if (dac.SubTotal == 0.00M)
  7341. {
  7342. continue;
  7343. }
  7344. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7345. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7346. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7347. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7348. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7349. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7350. builder.Write(currency);//币种
  7351. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7352. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7353. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7354. builder.Write("");//人数
  7355. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7356. builder.Write("");//天数
  7357. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7358. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7359. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7360. decimal rate = 0.00M;
  7361. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7362. builder.Write(rate.ToString("#0.0000"));//汇率
  7363. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7364. decimal rbmPrice = dac.SubTotal;
  7365. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7366. accommodationStartIndex++;
  7367. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7368. }
  7369. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7370. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7371. {
  7372. table1.Rows.RemoveAt(i - 1);
  7373. foodandotherStartIndex--;
  7374. }
  7375. if (dac2.Count == dac3.Count)//国家 币种 金额
  7376. {
  7377. for (int i = 0; i < dac2.Count; i++)
  7378. {
  7379. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7380. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7381. }
  7382. }
  7383. decimal dac2totalPrice = 0.00M;
  7384. foreach (var dac in dac2)
  7385. {
  7386. if (dac.SubTotal == 0)
  7387. {
  7388. continue;
  7389. }
  7390. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7391. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7392. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7393. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7394. builder.Write(currency);//币种
  7395. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7396. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7397. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7398. builder.Write("");//人数
  7399. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7400. builder.Write("");//天数
  7401. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7402. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7403. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7404. decimal rate = 0.00M;
  7405. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7406. builder.Write(rate.ToString("#0.0000"));//汇率
  7407. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7408. decimal rbmPrice = dac.SubTotal;
  7409. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7410. foodandotherStartIndex++;
  7411. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7412. }
  7413. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7414. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7415. {
  7416. table1.Rows.RemoveAt(i - 1);
  7417. }
  7418. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7419. string otherFeeStr = "";
  7420. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7421. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7422. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7423. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7424. foreach (var otherInfo in dac5)
  7425. {
  7426. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7427. }
  7428. #endregion
  7429. if (otherFeeStr.Length > 0)
  7430. {
  7431. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7432. otherFeeStr = $"({otherFeeStr})";
  7433. dic.Add("OtherFeeStr", otherFeeStr);
  7434. }
  7435. //总计
  7436. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7437. //国际旅费
  7438. string outsideAir = string.Empty;
  7439. string allPriceAir = string.Empty;
  7440. if (_EnterExitCosts.SumJJC == 1)
  7441. {
  7442. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7443. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7444. }
  7445. if (_EnterExitCosts.SumGWC == 1)
  7446. {
  7447. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7448. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7449. }
  7450. if (_EnterExitCosts.SumTDC == 1)
  7451. {
  7452. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7453. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7454. }
  7455. dic.Add("InTravelPrice", $"({outsideAir})");
  7456. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7457. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7458. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7459. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7460. foreach (var key in dic.Keys)
  7461. {
  7462. builder.MoveToBookmark(key);
  7463. builder.Write(dic[key]);
  7464. }
  7465. //模板文件名
  7466. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7467. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7468. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7469. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7470. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7471. }
  7472. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7473. {
  7474. //获取模板
  7475. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7476. //载入模板
  7477. var designer = new WorkbookDesigner
  7478. {
  7479. Workbook = new Workbook(tempPath)
  7480. };
  7481. var dic = new Dictionary<string, string>();
  7482. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7483. {
  7484. var list = new List<string>();
  7485. try
  7486. {
  7487. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7488. foreach (var item in spilitArr)
  7489. {
  7490. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7491. var depCode = spDotandEmpty[2].Substring(0, 3);
  7492. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7493. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7494. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7495. list.Add(depName);
  7496. list.Add(arrName);
  7497. }
  7498. list = list.Distinct().ToList();
  7499. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7500. }
  7501. catch (Exception)
  7502. {
  7503. dic.Add("ReturnCode", "行程录入不正确!");
  7504. }
  7505. }
  7506. else
  7507. {
  7508. dic.Add("ReturnCode", "未录入行程!");
  7509. }
  7510. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7511. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7512. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7513. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7514. {
  7515. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7516. dic.Add("Day", sp.Days.ToString());
  7517. }
  7518. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7519. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7520. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7521. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7522. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7523. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7524. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7525. designer.SetDataSource("Name", Names);
  7526. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7527. designer.SetDataSource("Day", dic["Day"] + "天");
  7528. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7529. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7530. int startIndex = 10;
  7531. const int startIndexcopy = 10;
  7532. if (dac2.Count == dac3.Count)//国家 币种 金额
  7533. {
  7534. for (int i = 0; i < dac2.Count; i++)
  7535. {
  7536. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7537. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7538. }
  7539. }
  7540. var dtdac1 = new DataTable();
  7541. var place = new List<string>();
  7542. dtdac1.Columns.AddRange(new DataColumn[] {
  7543. new(){ ColumnName = "city"},
  7544. new(){ ColumnName = "curr"},
  7545. new(){ ColumnName = "criterion"},
  7546. new(){ ColumnName = "number",DataType = typeof(int)},
  7547. new(){ ColumnName = "day",DataType = typeof(int)},
  7548. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7549. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7550. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7551. });
  7552. var dtdac2 = new DataTable();
  7553. dtdac2.Columns.AddRange(new DataColumn[] {
  7554. new(){ ColumnName = "city"},
  7555. new(){ ColumnName = "curr"},
  7556. new(){ ColumnName = "criterion"},
  7557. new(){ ColumnName = "number",DataType = typeof(int)},
  7558. new(){ ColumnName = "day",DataType = typeof(int)},
  7559. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7560. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7561. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7562. });
  7563. dtdac1.TableName = "tb1";
  7564. dtdac2.TableName = "tb2";
  7565. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7566. foreach (var item in dac1)
  7567. {
  7568. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7569. if (place.Contains(item.Place))
  7570. {
  7571. continue;
  7572. }
  7573. DataRow row = dtdac1.NewRow();
  7574. row["city"] = item.Place;
  7575. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7576. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7577. row["curr"] = currency;
  7578. row["rate"] = rate.ToString("#0.0000");
  7579. row["criterion"] = item.Cost.ToString("#0.00");
  7580. row["number"] = 1;
  7581. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7582. //row["costRMB"] = rbmPrice;
  7583. dtdac1.Rows.Add(row);
  7584. place.Add(item.Place);
  7585. }
  7586. place = new List<string>();
  7587. foreach (var item in dac2)
  7588. {
  7589. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7590. if (place.Contains(item.Place))
  7591. {
  7592. continue;
  7593. }
  7594. DataRow row = dtdac2.NewRow();
  7595. row["city"] = item.Place;
  7596. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7597. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7598. row["curr"] = currency;
  7599. row["rate"] = rate.ToString("#0.0000");
  7600. row["criterion"] = item.Cost.ToString("#0.00");
  7601. row["number"] = 1;
  7602. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7603. //row["cost"] = item.SubTotal;
  7604. //row["costRMB"] = rbmPrice;
  7605. dtdac2.Rows.Add(row);
  7606. place.Add(item.Place);
  7607. //dac2totalPrice += rbmPrice;
  7608. }
  7609. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7610. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7611. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7612. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7613. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7614. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7615. string cell4Str1 = string.Empty;
  7616. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7617. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7618. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7619. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7620. string cellStr = $" 5.其他费用(";
  7621. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7622. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7623. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7624. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7625. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7626. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7627. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7628. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7629. foreach (var otherInfo in dac5)
  7630. {
  7631. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7632. }
  7633. #endregion
  7634. if (cellStr.Length > 8)
  7635. {
  7636. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7637. }
  7638. cellStr += ")";
  7639. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7640. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7641. decimal pxFee = dac4.Sum(it => it.Cost);
  7642. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7643. string celllastStr1 = "";
  7644. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7645. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7646. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7647. celllastStr1 += $",国际旅费 元";
  7648. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7649. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7650. designer.SetDataSource("cell4Str", cell4Str);
  7651. designer.SetDataSource("cellStr", cellStr);
  7652. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7653. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7654. designer.SetDataSource("celllastStr", celllastStr);
  7655. Workbook wb = designer.Workbook;
  7656. var sheet = wb.Worksheets[0];
  7657. //绑定datatable数据集
  7658. designer.SetDataSource(dtdac1);
  7659. designer.SetDataSource(dtdac2);
  7660. designer.Process();
  7661. var rowStart = dtdac1.Rows.Count;
  7662. while (rowStart > 0)
  7663. {
  7664. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7665. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7666. startIndex++;
  7667. rowStart--;
  7668. }
  7669. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7670. startIndex += 1; //总计行
  7671. rowStart = dtdac2.Rows.Count;
  7672. while (rowStart > 0)
  7673. {
  7674. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7675. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7676. startIndex++;
  7677. rowStart--;
  7678. }
  7679. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7680. wb.CalculateFormula(true);
  7681. //模板文件名
  7682. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7683. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7684. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7685. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7686. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7687. }
  7688. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7689. {
  7690. //获取模板
  7691. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7692. //载入模板
  7693. var doc = new Document(tempPath);
  7694. var builder = new DocumentBuilder(doc);
  7695. var dic = new Dictionary<string, string>
  7696. {
  7697. { "GroupName", _DelegationInfo.TeamName },
  7698. { "ClientUnit", _DelegationInfo.ClientUnit }
  7699. };
  7700. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7701. string missionLeaderJob = "";//负责人job
  7702. //int groupNumber = 0; //团人数
  7703. if (DeleClientList.Count > 0)
  7704. {
  7705. missionLeader = DeleClientList[0]?.Name ?? "";
  7706. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7707. }
  7708. dic.Add("MissionLeader", missionLeader); //团负责人
  7709. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7710. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7711. #region MyRegion
  7712. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7713. //{
  7714. // List<string> list = new List<string>();
  7715. // try
  7716. // {
  7717. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7718. // foreach (var item in spilitArr)
  7719. // {
  7720. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7721. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7722. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7723. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7724. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7725. // list.Add(depName);
  7726. // list.Add(arrName);
  7727. // }
  7728. // list = list.Distinct().ToList();
  7729. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7730. // }
  7731. // catch (Exception)
  7732. // {
  7733. // dic.Add("ReturnCode", "行程录入不正确!");
  7734. // }
  7735. //}
  7736. //else
  7737. //{
  7738. // dic.Add("ReturnCode", "未录入行程!");
  7739. //}
  7740. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7741. dic.Add("ReturnCode", string.Join("、", countrys));
  7742. #endregion
  7743. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7744. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7745. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7746. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7747. //{
  7748. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7749. // dic.Add("Day", sp.Days.ToString());
  7750. //}
  7751. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7752. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7753. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7754. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7755. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7756. //培训人员名单
  7757. int cultivateRowIndex = 7;
  7758. foreach (var item in DeleClientList)
  7759. {
  7760. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7761. builder.Write(item.Name);
  7762. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7763. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7764. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7765. string birthDay = "";
  7766. if (item.Birthday != null)
  7767. {
  7768. DateTime dt = Convert.ToDateTime(item.Birthday);
  7769. birthDay = $"{dt.Year}.{dt.Month}";
  7770. }
  7771. builder.Write(birthDay);
  7772. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7773. builder.Write(item.Company);
  7774. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7775. builder.Write(item.Job);
  7776. cultivateRowIndex++;
  7777. }
  7778. //删除多余行
  7779. //cultivateRowIndex -= 2;
  7780. int delRows = 10 + 7 - cultivateRowIndex;
  7781. if (delRows > 0)
  7782. {
  7783. for (int i = 0; i < delRows; i++)
  7784. {
  7785. table1.Rows.RemoveAt(cultivateRowIndex);
  7786. //cultivateRowIndex++;
  7787. }
  7788. }
  7789. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7790. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7791. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7792. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7793. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7794. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7795. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7796. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7797. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7798. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7799. //其他费用
  7800. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7801. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7802. //其他费用合计
  7803. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7804. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7805. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7806. //公务舱合计
  7807. //国际旅费
  7808. //string outsideJJ = "";
  7809. //string allPriceJJ = "";
  7810. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7811. {
  7812. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7813. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7814. }
  7815. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7816. {
  7817. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7818. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7819. }
  7820. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7821. {
  7822. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7823. dic.Add("AirFeeTotal", airFeeTotalStr);
  7824. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7825. dic.Add("FeeTotal", feeTotalStr);
  7826. }
  7827. foreach (var key in dic.Keys)
  7828. {
  7829. builder.MoveToBookmark(key);
  7830. builder.Write(dic[key]);
  7831. }
  7832. //模板文件名
  7833. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7834. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7835. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7836. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7837. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7838. }
  7839. }
  7840. else if (dto.ExportType == 2) //表格
  7841. {
  7842. //利用键值对存放数据
  7843. Dictionary<string, string> dic = new Dictionary<string, string>();
  7844. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7845. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7846. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7847. dic.Add("Day", sp.Days.ToString());
  7848. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7849. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7850. {
  7851. //获取模板
  7852. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7853. //载入模板
  7854. var doc = new Document(tempPath);
  7855. var builder = new DocumentBuilder(doc);
  7856. dic.Add("TeamName", _DelegationInfo.TeamName);
  7857. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7858. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7859. string missionLeaderName = "",
  7860. missionLeaderJob = "";
  7861. if (DeleClientList.Count > 0)
  7862. {
  7863. missionLeaderName = DeleClientList[0].Name;
  7864. missionLeaderJob = DeleClientList[0].Job;
  7865. }
  7866. dic.Add("MissionLeaderName", missionLeaderName);
  7867. dic.Add("MissionLeaderJob", missionLeaderJob);
  7868. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7869. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7870. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7871. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7872. int rowCount = 10;//总人数行
  7873. int startRowIndex = 7; //起始行
  7874. for (int i = 0; i < DeleClientList.Count; i++)
  7875. {
  7876. builder.MoveToCell(0, startRowIndex, 0, 0);
  7877. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7878. builder.MoveToCell(0, startRowIndex, 1, 0);
  7879. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7880. builder.Write(sex);//性别
  7881. builder.MoveToCell(0, startRowIndex, 2, 0);
  7882. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7883. builder.MoveToCell(0, startRowIndex, 3, 0);
  7884. builder.Write(DeleClientList[i].Company);//工作单位
  7885. builder.MoveToCell(0, startRowIndex, 4, 0);
  7886. builder.Write(DeleClientList[i].Job);//职务及级别
  7887. builder.MoveToCell(0, startRowIndex, 5, 0);
  7888. builder.Write("");//人员属性
  7889. builder.MoveToCell(0, startRowIndex, 6, 0);
  7890. builder.Write("");//上次出国时间
  7891. startRowIndex++;
  7892. }
  7893. int nullRow = rowCount - DeleClientList.Count;//空行
  7894. for (int i = 0; i < nullRow; i++)
  7895. {
  7896. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7897. }
  7898. foreach (var key in dic.Keys)
  7899. {
  7900. builder.MoveToBookmark(key);
  7901. builder.Write(dic[key]);
  7902. }
  7903. //模板文件名
  7904. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7905. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7906. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7907. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7908. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7909. }
  7910. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7911. {
  7912. //获取模板
  7913. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7914. //载入模板
  7915. var doc = new Document(tempPath);
  7916. var builder = new DocumentBuilder(doc);
  7917. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7918. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7919. dic.Add("Names", Names);
  7920. int accommodationRows = 12;
  7921. //int foodandotherRows = 12;
  7922. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7923. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7924. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7925. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7926. int accommodationStartIndex = 6;
  7927. decimal dac1totalPrice = 0.00M;
  7928. foreach (var dac in dac1)
  7929. {
  7930. if (dac.SubTotal == 0)
  7931. {
  7932. continue;
  7933. }
  7934. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7935. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7936. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7937. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7938. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7939. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7940. builder.Write(currency);//币种
  7941. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7942. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7943. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7944. builder.Write("");//人数
  7945. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7946. builder.Write("");//天数
  7947. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7948. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7949. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7950. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7951. builder.Write(rate.ToString("#0.0000"));//汇率
  7952. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7953. decimal rbmPrice = rate * dac.SubTotal;
  7954. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7955. accommodationStartIndex++;
  7956. dac1totalPrice += rbmPrice;
  7957. }
  7958. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7959. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7960. builder.Write("小计");
  7961. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7962. builder.Write(dac1totalPrice.ToString("#0.00"));
  7963. accommodationStartIndex++;
  7964. int nullRow = accommodationRows - dac1.Count;
  7965. //删除空行
  7966. //if (nullRow > 0)
  7967. //{
  7968. // int rowIndex = accommodationStartIndex;
  7969. // for (int i = 0; i < nullRow; i++)
  7970. // {
  7971. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7972. // row.Remove();
  7973. // rowIndex++;
  7974. // }
  7975. //}
  7976. if (dac2.Count == dac3.Count)//国家 币种 金额
  7977. {
  7978. for (int i = 0; i < dac2.Count; i++)
  7979. {
  7980. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7981. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7982. }
  7983. }
  7984. int foodandotherStartIndex = 19;//
  7985. decimal dac2totalPrice = 0.00M;
  7986. foreach (var dac in dac2)
  7987. {
  7988. if (dac.SubTotal == 0)
  7989. {
  7990. continue;
  7991. }
  7992. //foodandotherStartIndex = 12;
  7993. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7994. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7995. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7996. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7997. builder.Write(currency);//币种
  7998. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7999. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8000. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8001. builder.Write("");//人数
  8002. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8003. builder.Write("");//天数
  8004. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8005. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8006. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8007. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8008. builder.Write(rate.ToString("#0.0000"));//汇率
  8009. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8010. decimal rbmPrice = rate * dac.SubTotal;
  8011. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8012. foodandotherStartIndex++;
  8013. dac2totalPrice += rbmPrice;
  8014. }
  8015. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8016. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8017. //删除空行
  8018. //if (dac2.Count < foodandotherRows)
  8019. //{
  8020. // while (table2.Rows.Count > dac2.Count)
  8021. // {
  8022. // table2.Rows.RemoveAt(dac2.Count);
  8023. // }
  8024. //}
  8025. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8026. string otherFeeStr = "";
  8027. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8028. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8029. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8030. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8031. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8032. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8033. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8034. foreach (var otherInfo in dac5)
  8035. {
  8036. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8037. }
  8038. #endregion
  8039. if (otherFeeStr.Length > 0)
  8040. {
  8041. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8042. otherFeeStr = $"({otherFeeStr})";
  8043. dic.Add("OtherFeeStr", otherFeeStr);
  8044. }
  8045. foreach (var key in dic.Keys)
  8046. {
  8047. builder.MoveToBookmark(key);
  8048. builder.Write(dic[key]);
  8049. }
  8050. //模板文件名
  8051. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8052. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8053. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8054. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8055. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8056. }
  8057. }
  8058. else if (dto.ExportType == 3)
  8059. {
  8060. if (dto.SubTypeId == 1) //团组成员名单
  8061. {
  8062. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  8063. //获取模板
  8064. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  8065. //载入模板
  8066. var doc = new Document(tempPath);
  8067. var builder = new DocumentBuilder(doc);
  8068. //获取word里所有表格
  8069. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8070. //获取所填表格的序数
  8071. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8072. var rowStart = tableOne.Rows[0]; //获取第1行
  8073. //循环赋值
  8074. for (int i = 0; i < DeleClientList.Count; i++)
  8075. {
  8076. builder.MoveToCell(0, i + 1, 0, 0);
  8077. builder.Write(DeleClientList[i].Name);
  8078. builder.MoveToCell(0, i + 1, 1, 0);
  8079. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8080. builder.Write(sex);
  8081. builder.MoveToCell(0, i + 1, 2, 0);
  8082. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  8083. builder.MoveToCell(0, i + 1, 3, 0);
  8084. builder.Write(DeleClientList[i].Company);
  8085. builder.MoveToCell(0, i + 1, 4, 0);
  8086. builder.Write(DeleClientList[i].Job);
  8087. }
  8088. //删除多余行
  8089. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  8090. {
  8091. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  8092. }
  8093. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  8094. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  8095. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  8096. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8097. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8098. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8099. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8100. }
  8101. }
  8102. return Ok(JsonView(400, "操作失败!", ""));
  8103. }
  8104. catch (Exception ex)
  8105. {
  8106. return Ok(JsonView(400, ex.Message, ""));
  8107. }
  8108. }
  8109. /// <summary>
  8110. /// 获取三公费用标准city
  8111. /// </summary>
  8112. /// <param name="placeData"></param>
  8113. /// <param name="nationalTravelFeeId"></param>
  8114. /// <returns></returns>
  8115. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8116. {
  8117. string _city = string.Empty;
  8118. if (placeData.Count < 1) return _city;
  8119. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8120. if (data == null) return _city;
  8121. string country = data.Country;
  8122. string city = data.City;
  8123. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8124. else _city = city;
  8125. return _city;
  8126. }
  8127. ///// <summary>
  8128. ///// 团组模块 - 出入境费用 - 明细表导出
  8129. ///// </summary>
  8130. ///// <returns></returns>
  8131. //[HttpPost]
  8132. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8133. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  8134. //{
  8135. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  8136. // if (data.Code != 0)
  8137. // {
  8138. // return Ok(JsonView(false, data.Msg));
  8139. // }
  8140. // return Ok(JsonView(true, data.Msg, data.Data));
  8141. //}
  8142. /// <summary>
  8143. /// 团组模块 - 出入境费用 - 一键清空
  8144. /// </summary>
  8145. /// <returns></returns>
  8146. [HttpPost]
  8147. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8149. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  8150. {
  8151. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  8152. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8153. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8154. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  8155. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8156. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  8157. .SetColumns(x => new Grp_DayOtherPrice
  8158. {
  8159. IsDel = 1,
  8160. DeleteUserId = dto.UserId,
  8161. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8162. })
  8163. .ExecuteCommandAsync();
  8164. if (_view.Code == 0)
  8165. {
  8166. return Ok(JsonView(true, "操作成功"));
  8167. }
  8168. return Ok(JsonView(false, "操作失败"));
  8169. }
  8170. /// <summary>
  8171. /// 团组模块 - 出入境费用 - 子项删除
  8172. /// </summary>
  8173. /// <returns></returns>
  8174. [HttpPost]
  8175. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8177. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  8178. {
  8179. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8180. if (data.Code != 0)
  8181. {
  8182. return Ok(JsonView(false, data.Msg));
  8183. }
  8184. return Ok(JsonView(true, "操作成功!", data.Data));
  8185. }
  8186. /// <summary>
  8187. /// 删除三公其他费用
  8188. /// </summary>
  8189. /// <param name="dto"></param>
  8190. /// <returns></returns>
  8191. [HttpPost]
  8192. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8193. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  8194. {
  8195. var jw = JsonView(false, "删除失败!");
  8196. var data = new Grp_DayOtherPrice()
  8197. {
  8198. Id = dto.Id,
  8199. IsDel = 1,
  8200. DeleteUserId = dto.DeleteUserId,
  8201. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8202. };
  8203. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8204. if (del > 0)
  8205. {
  8206. jw.Code = 200;
  8207. jw.Msg = "删除成功!";
  8208. }
  8209. return Ok(jw);
  8210. }
  8211. /// <summary>
  8212. /// 团组模块 - 出入境国家费用标准 List
  8213. /// </summary>
  8214. /// <returns></returns>
  8215. [HttpPost]
  8216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8217. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  8218. {
  8219. int provinceId = dto.ProvinceId;
  8220. if (provinceId < 1) provinceId = 122; //默认四川省数据
  8221. var nftData = await _sqlSugar
  8222. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  8223. JoinType.Left, ntf.Currency == sd1.Id,
  8224. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8225. JoinType.Left, ntf.ProvinceId == c.Id
  8226. ))
  8227. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8228. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  8229. {
  8230. Id = ntf.Id,
  8231. ProvinceId = ntf.ProvinceId,
  8232. ProvinceName = c.Name_CN,
  8233. Continent = ntf.Continent,
  8234. Country = ntf.Country,
  8235. City = ntf.City,
  8236. Currency = ntf.Currency,
  8237. CurrencyCode = sd1.Name,
  8238. CurrencyName = sd1.Remark,
  8239. RoomCost = ntf.RoomCost,
  8240. FoodCost = ntf.FoodCost,
  8241. PublicCost = ntf.PublicCost,
  8242. LastUpdateUserId = ntf.LastUpdateUserId,
  8243. LastUpdateUserName = u.CnName,
  8244. LastUpdateTime = ntf.LastUpdateTime
  8245. })
  8246. .ToListAsync();
  8247. return Ok(JsonView(true, "查询成功!", nftData));
  8248. }
  8249. /// <summary>
  8250. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  8251. /// </summary>
  8252. /// <returns></returns>
  8253. [HttpPost]
  8254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8255. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  8256. {
  8257. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  8258. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  8259. List<string> countryData = new List<string>();
  8260. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  8261. countryData = countryData.Distinct().ToList();
  8262. List<dynamic> dataSource = new List<dynamic>();
  8263. foreach (var item in countryData)
  8264. {
  8265. var cityData1 = new List<string>();
  8266. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  8267. var countryData2 = new
  8268. {
  8269. CountryName = item,
  8270. CityData = cityData1
  8271. };
  8272. if (!dataSource.Contains(countryData2))
  8273. {
  8274. dataSource.Add(countryData2);
  8275. }
  8276. }
  8277. return Ok(JsonView(true, "查询成功!", dataSource));
  8278. }
  8279. /// <summary>
  8280. /// 团组模块 - 出入境国家费用标准 Page List
  8281. /// </summary>
  8282. /// <returns></returns>
  8283. [HttpPost]
  8284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8285. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  8286. {
  8287. int portId = dto.PortType,
  8288. pageIndex = dto.PageIndex,
  8289. pageSize = dto.PageSize;
  8290. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8291. if (pageIndex == 0) pageIndex = 1;
  8292. if (pageSize == 0) pageSize = 10;
  8293. RefAsync<int> total = 0;
  8294. var nationalTravelFeeData = await _sqlSugar
  8295. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  8296. JoinType.Left, ntf.Currency == sd1.Id,
  8297. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8298. JoinType.Left, ntf.ProvinceId == sd2.Id
  8299. ))
  8300. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  8301. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  8302. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  8303. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  8304. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  8305. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  8306. {
  8307. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  8308. Id = ntf.Id,
  8309. ProvinceId = ntf.ProvinceId,
  8310. ProvinceName = sd2.Name_CN,
  8311. Continent = ntf.Continent,
  8312. Country = ntf.Country,
  8313. City = ntf.City,
  8314. Currency = ntf.Currency,
  8315. CurrencyCode = sd1.Name,
  8316. CurrencyName = sd1.Remark,
  8317. RoomCost = ntf.RoomCost,
  8318. FoodCost = ntf.FoodCost,
  8319. PublicCost = ntf.PublicCost,
  8320. LastUpdateUserId = ntf.LastUpdateUserId,
  8321. LastUpdateUserName = u.CnName,
  8322. LastUpdateTime = ntf.LastUpdateTime,
  8323. Remark = ntf.Remark
  8324. })
  8325. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8326. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8327. }
  8328. /// <summary>
  8329. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8330. /// </summary>
  8331. /// <returns></returns>
  8332. [HttpPost]
  8333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8334. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8335. {
  8336. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8337. int portId = dto.PortType;
  8338. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8339. string whereSql = string.Empty;
  8340. if (!string.IsNullOrEmpty(dto.Country))
  8341. {
  8342. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8343. }
  8344. if (!string.IsNullOrEmpty(dto.City))
  8345. {
  8346. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8347. }
  8348. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8349. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8350. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8351. From Grp_NationalTravelFee gntf
  8352. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8353. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8354. Where gntf.Isdel = 0 {0} ", whereSql);
  8355. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8356. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8357. }
  8358. /// <summary>
  8359. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8360. /// </summary>
  8361. /// <returns></returns>
  8362. [HttpPost]
  8363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8364. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  8365. {
  8366. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  8367. }
  8368. /// <summary>
  8369. /// 团组模块 - 出入境国家费用标准 - Del
  8370. /// </summary>
  8371. /// <returns></returns>
  8372. [HttpPost]
  8373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8374. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  8375. {
  8376. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  8377. {
  8378. Id = dto.Id,
  8379. DeleteUserId = dto.DeleteUserId,
  8380. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8381. IsDel = 1
  8382. };
  8383. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  8384. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  8385. .WhereColumns(it => new { it.Id })
  8386. .ExecuteCommandAsync();
  8387. if (delStatus <= 0)
  8388. {
  8389. return Ok(JsonView(false, "删除失败!"));
  8390. }
  8391. return Ok(JsonView(true, "操作成功!"));
  8392. }
  8393. /// <summary>
  8394. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  8395. /// 注:Get 请求Headers 加 Token
  8396. /// </summary>
  8397. /// <param name="groupId"></param>
  8398. /// <returns></returns>
  8399. [HttpGet("{groupId}")]
  8400. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8401. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  8402. {
  8403. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8404. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8405. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8406. data.ForEach(x =>
  8407. {
  8408. x.CreateUserId = _currUserInfo.UserId;
  8409. });
  8410. if (data.Any())
  8411. {
  8412. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8413. if (add > 0)
  8414. {
  8415. return Ok(JsonView(true, "操作成功!"));
  8416. }
  8417. }
  8418. return Ok(JsonView(false, "未操作!"));
  8419. }
  8420. #endregion
  8421. #region 团组经理模块 出入境费用-草稿
  8422. /// <summary>
  8423. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8424. /// </summary>
  8425. /// <returns></returns>
  8426. [HttpGet]
  8427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8428. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8429. {
  8430. var provData = await _groupRepository.ProvinceBasicSource();
  8431. return Ok(JsonView(true, "查询成功!", provData));
  8432. }
  8433. /// <summary>
  8434. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8435. /// </summary>
  8436. /// <returns></returns>
  8437. [HttpGet("{provinceId}")]
  8438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8439. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8440. {
  8441. //验证城市归属并给默认值
  8442. if (provinceId < 1) provinceId = 122;
  8443. /*
  8444. * 122 四川
  8445. * 108 贵州
  8446. * 103 重庆
  8447. * 132 云南
  8448. */
  8449. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8450. return Ok(JsonView(true, "查询成功!", new
  8451. {
  8452. WordTypeData = wordTypeData,
  8453. ExcelTypeData = excelTypeData,
  8454. }));
  8455. }
  8456. /// <summary>
  8457. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8458. /// </summary>
  8459. /// <returns></returns>
  8460. [HttpPost]
  8461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8462. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8463. {
  8464. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8465. .Where(x => x.IsDel == 0)
  8466. .OrderByDescending(x => x.CreateTime)
  8467. .Select(x => new { x.Id, x.DraftName })
  8468. .ToListAsync();
  8469. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8470. //SetDataInfoView
  8471. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8472. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8473. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8474. int provinceId = dto.ProvinceId;
  8475. if (provinceId < 1) provinceId = 122;
  8476. /*
  8477. * 122 四川
  8478. * 108 贵州
  8479. * 103 重庆
  8480. * 132 云南
  8481. */
  8482. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8483. //默认币种显示
  8484. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8485. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8486. return Ok(JsonView(true, "查询成功!", new
  8487. {
  8488. DraftNameDatas = draftNameDatas,
  8489. CurrencyData = _CurrencyData,
  8490. WordTypeData = wordTypeData,
  8491. ExcelTypeData = excelTypeData,
  8492. CurrencyInit = _currencyInfos,
  8493. ViewPermissionData = viewPermissionData
  8494. }));
  8495. }
  8496. /// <summary>
  8497. /// 团组模块 - 出入境费用-草稿
  8498. /// 实时汇率 tips
  8499. /// 机票费用 tips
  8500. /// </summary>
  8501. /// <returns></returns>
  8502. [HttpPost]
  8503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8504. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8505. {
  8506. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8507. return Ok(JsonView(true, "查询成功!", new
  8508. {
  8509. //GroupNameData = groupNameData.Data,
  8510. //visaData = visaData.Data,
  8511. //airData = airData.Data,
  8512. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8513. }));
  8514. }
  8515. /// <summary>
  8516. /// 团组模块 - 出入境费用-草稿
  8517. /// 签证费用 tips
  8518. /// </summary>
  8519. /// <returns></returns>
  8520. [HttpPost]
  8521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8522. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8523. {
  8524. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8525. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8526. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8527. .Select(x => x.NationalTravelFeeId)
  8528. .Distinct()
  8529. .ToListAsync();
  8530. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8531. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8532. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8533. .Select(x => x.Country)
  8534. .Distinct()
  8535. .ToArrayAsync();
  8536. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8537. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8538. return Ok(JsonView(true, "查询成功!", new
  8539. {
  8540. totalAmt,
  8541. remark
  8542. }));
  8543. }
  8544. /// <summary>
  8545. /// 团组模块 - 出入境费用-草稿 - Info
  8546. /// </summary>
  8547. /// <returns></returns>
  8548. [HttpPost]
  8549. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8551. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8552. {
  8553. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8554. }
  8555. /// <summary>
  8556. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8557. /// </summary>
  8558. /// <returns></returns>
  8559. [HttpPost]
  8560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8561. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8562. {
  8563. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8564. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8565. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8566. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8567. foreach (var userId in dto.UserIds)
  8568. {
  8569. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8570. }
  8571. if (permissions.Any())
  8572. {
  8573. _sqlSugar.BeginTran();
  8574. try
  8575. {
  8576. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8577. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8578. if (result < 1)
  8579. {
  8580. _sqlSugar.RollbackTran();
  8581. return Ok(JsonView(false));
  8582. }
  8583. }
  8584. catch (Exception ex)
  8585. {
  8586. _sqlSugar.RollbackTran();
  8587. return Ok(JsonView(false, ex.Message));
  8588. }
  8589. _sqlSugar.CommitTran();
  8590. return Ok(JsonView(true));
  8591. }
  8592. return Ok(JsonView(false));
  8593. }
  8594. /// <summary>
  8595. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8596. /// </summary>
  8597. /// <returns></returns>
  8598. [HttpPost]
  8599. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8601. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8602. {
  8603. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8604. if (data.Code != 0)
  8605. {
  8606. return Ok(JsonView(false, data.Msg));
  8607. }
  8608. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8609. //汇率信息记录
  8610. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8611. return Ok(JsonView(true, data.Msg, data.Data));
  8612. }
  8613. /// <summary>
  8614. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8615. /// </summary>
  8616. /// <param name="dto"></param>
  8617. /// <returns></returns>
  8618. [HttpPost]
  8619. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8621. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8622. {
  8623. try
  8624. {
  8625. var id = dto.Id;
  8626. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8627. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8628. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8629. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8630. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8631. 3 团组成员名单 1 团组成员名单", ""));
  8632. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8633. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8634. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8635. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8636. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8637. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8638. //数据源
  8639. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8640. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8641. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8642. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8643. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8644. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8645. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8646. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8647. .Select((x, a, b) => new
  8648. {
  8649. x.Index,
  8650. itemName = a.Name,
  8651. CurrencyStr = b.Name,
  8652. x.Cost,
  8653. x.SubTotal,
  8654. x.Remark
  8655. })
  8656. .OrderBy((x) => x.Index)
  8657. .ToList(); //其他款项费用
  8658. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8659. var peiceItemCurrencys = new List<string>();
  8660. if (_DayAndCosts.Any())
  8661. {
  8662. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8663. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8664. }
  8665. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8666. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8667. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8668. {
  8669. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8670. }
  8671. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8672. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8673. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8674. if (dto.ExportType == 1) //明细表
  8675. {
  8676. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8677. {
  8678. //获取模板
  8679. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8680. //载入模板
  8681. Document doc = new Document(tempPath);
  8682. DocumentBuilder builder = new DocumentBuilder(doc);
  8683. //利用键值对存放数据
  8684. Dictionary<string, string> dic = new Dictionary<string, string>();
  8685. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8686. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8687. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8688. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8689. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8690. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8691. //境内费用(其他费用)
  8692. if (_EnterExitCosts.ChoiceOne == 1)
  8693. {
  8694. string row1_1 = "";
  8695. if (_EnterExitCosts.Visa > 0)
  8696. {
  8697. //insidePayTotal += _EnterExitCosts.Visa;
  8698. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8699. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8700. //{
  8701. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8702. //}
  8703. }
  8704. string row1_2 = "";
  8705. if (_EnterExitCosts.YiMiao > 0)
  8706. {
  8707. //insidePayTotal += _EnterExitCosts.YiMiao;
  8708. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8709. }
  8710. if (_EnterExitCosts.HeSuan > 0)
  8711. {
  8712. //insidePayTotal += _EnterExitCosts.HeSuan;
  8713. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8714. }
  8715. if (_EnterExitCosts.Service > 0)
  8716. {
  8717. //insidePayTotal += _EnterExitCosts.Service;
  8718. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8719. }
  8720. string row1_3 = "";
  8721. if (_EnterExitCosts.Safe > 0)
  8722. {
  8723. //insidePayTotal += _EnterExitCosts.Safe;
  8724. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8725. }
  8726. if (_EnterExitCosts.Ticket > 0)
  8727. {
  8728. //insidePayTotal += _EnterExitCosts.Ticket;
  8729. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8730. }
  8731. string row1 = "";
  8732. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8733. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8734. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8735. row1 += $"备注:{_EnterExitCosts.Remark}";
  8736. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8737. dic.Add("Row1Str", row1);
  8738. }
  8739. string airTotalStr = string.Empty,
  8740. airPriceStr = string.Empty;
  8741. //经济舱
  8742. if (_EnterExitCosts.SumJJC == 1)
  8743. {
  8744. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8745. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8746. }
  8747. //公务舱
  8748. if (_EnterExitCosts.SumGWC == 1)
  8749. {
  8750. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8751. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8752. }
  8753. //头等舱
  8754. if (_EnterExitCosts.SumTDC == 1)
  8755. {
  8756. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8757. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8758. }
  8759. //汇率描述
  8760. string rateStr = "";
  8761. if (peiceItemCurrencyInfos.Any())
  8762. {
  8763. rateStr = "\r\n汇率描述:";
  8764. foreach (var item in peiceItemCurrencyInfos)
  8765. {
  8766. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8767. }
  8768. }
  8769. string twoItemRemark = "备注:";
  8770. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8771. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8772. dic.Add("AirTotalStr", airTotalStr);
  8773. dic.Add("AirPriceStr", airPriceStr);
  8774. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8775. dic.Add("TwoItemRemark", twoItemRemark);
  8776. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8777. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8778. int table1Row = 0,
  8779. table2Row = 0,
  8780. table3Row = 0,
  8781. table4Row = 0,
  8782. table5Row = 0;
  8783. //住宿费
  8784. if (_EnterExitCosts.ChoiceThree == 1)
  8785. {
  8786. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8787. table1Row = dac1.Count;
  8788. #region 填充word表格内容
  8789. for (int i = 0; i < dac1.Count; i++)
  8790. {
  8791. var dac = dac1[i];
  8792. if (dac == null) continue;
  8793. builder.MoveToCell(0, i, 0, 0);
  8794. builder.Write("第" + dac.Days.ToString() + "晚:");
  8795. builder.MoveToCell(0, i, 1, 0);
  8796. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8797. //builder.Write(dac.Place == null ? "" : dac.Place);
  8798. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8799. builder.MoveToCell(0, i, 2, 0);
  8800. builder.Write("费用标准:");
  8801. string curr = "";
  8802. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8803. if (currData != null)
  8804. {
  8805. curr = currData.Name;
  8806. }
  8807. builder.MoveToCell(0, i, 3, 0);
  8808. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8809. builder.MoveToCell(0, i, 4, 0);
  8810. builder.Write("费用小计:");
  8811. builder.MoveToCell(0, i, 5, 0);
  8812. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8813. }
  8814. #endregion
  8815. }
  8816. else dic.Add("SubZS", "0.00");
  8817. //删除多余行
  8818. while (table1.Rows.Count > table1Row)
  8819. {
  8820. table1.Rows.RemoveAt(table1Row);
  8821. }
  8822. //伙食费
  8823. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8824. if (_EnterExitCosts.ChoiceFour == 1)
  8825. {
  8826. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8827. table2Row = dac2.Count;
  8828. #region 填充word表格内容
  8829. for (int i = 0; i < dac2.Count; i++)
  8830. {
  8831. var dac = dac2[i];
  8832. if (dac == null) continue;
  8833. builder.MoveToCell(1, i, 0, 0);
  8834. builder.Write("第" + dac.Days.ToString() + "天:");
  8835. builder.MoveToCell(1, i, 1, 0);
  8836. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8837. builder.MoveToCell(1, i, 2, 0);
  8838. builder.Write("费用标准:");
  8839. string curr = "";
  8840. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8841. if (currData != null)
  8842. {
  8843. curr = currData.Name;
  8844. }
  8845. builder.MoveToCell(1, i, 3, 0);
  8846. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8847. builder.MoveToCell(1, i, 4, 0);
  8848. builder.Write("费用小计:");
  8849. builder.MoveToCell(1, i, 5, 0);
  8850. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8851. }
  8852. #endregion
  8853. }
  8854. else dic.Add("SubHS", "0.00");
  8855. //删除多余行
  8856. while (table2.Rows.Count > table2Row)
  8857. {
  8858. table2.Rows.RemoveAt(table2Row);
  8859. }
  8860. //公杂费
  8861. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8862. if (_EnterExitCosts.ChoiceFive == 1)
  8863. {
  8864. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8865. table3Row = dac3.Count;
  8866. #region 填充word表格内容
  8867. for (int i = 0; i < dac3.Count; i++)
  8868. {
  8869. var dac = dac3[i];
  8870. if (dac == null) continue;
  8871. builder.MoveToCell(2, i, 0, 0);
  8872. builder.Write("第" + dac.Days.ToString() + "天:");
  8873. builder.MoveToCell(2, i, 1, 0);
  8874. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8875. builder.MoveToCell(2, i, 2, 0);
  8876. builder.Write("费用标准:");
  8877. string curr = "";
  8878. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8879. if (currData != null)
  8880. {
  8881. curr = currData.Name;
  8882. }
  8883. builder.MoveToCell(2, i, 3, 0);
  8884. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8885. builder.MoveToCell(2, i, 4, 0);
  8886. builder.Write("费用小计:");
  8887. builder.MoveToCell(2, i, 5, 0);
  8888. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8889. }
  8890. //删除多余行
  8891. while (table3.Rows.Count > table3Row)
  8892. {
  8893. table3.Rows.RemoveAt(table3Row);
  8894. }
  8895. #endregion
  8896. }
  8897. else dic.Add("SubGZF", "0.00");
  8898. //删除多余行
  8899. while (table3.Rows.Count > table3Row)
  8900. {
  8901. table3.Rows.RemoveAt(table3Row);
  8902. }
  8903. //培训费
  8904. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8905. if (_EnterExitCosts.ChoiceSix == 1)
  8906. {
  8907. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8908. dic.Add("SubPX", pxStr);
  8909. table4Row = dac4.Count;
  8910. #region 填充word表格内容
  8911. for (int i = 0; i < dac4.Count; i++)
  8912. {
  8913. var dac = dac4[i];
  8914. if (dac == null) continue;
  8915. builder.MoveToCell(3, i, 0, 0);
  8916. builder.Write("第" + dac.Days.ToString() + "天:");
  8917. builder.MoveToCell(3, i, 1, 0);
  8918. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8919. builder.MoveToCell(3, i, 2, 0);
  8920. builder.Write("费用标准:");
  8921. string curr = "";
  8922. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8923. if (currData != null)
  8924. {
  8925. curr = currData.Name;
  8926. }
  8927. builder.MoveToCell(3, i, 3, 0);
  8928. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8929. builder.MoveToCell(3, i, 4, 0);
  8930. builder.Write("费用小计:");
  8931. builder.MoveToCell(3, i, 5, 0);
  8932. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8933. }
  8934. #endregion
  8935. }
  8936. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8937. //删除多余行
  8938. while (table4.Rows.Count > table4Row)
  8939. {
  8940. table4.Rows.RemoveAt(table4Row);
  8941. }
  8942. //其他费用
  8943. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8944. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8945. {
  8946. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8947. dic.Add("titleQi", qtStr);
  8948. table5Row = dac5.Count;
  8949. #region 填充word表格内容
  8950. for (int i = 0; i < dac5.Count; i++)
  8951. {
  8952. var dac = dac5[i];
  8953. if (dac == null) continue;
  8954. builder.MoveToCell(4, i, 0, 0);
  8955. builder.Write("第" + dac.Index.ToString() + "项:");
  8956. builder.MoveToCell(4, i, 1, 0);
  8957. builder.Write(dac.itemName);
  8958. builder.MoveToCell(4, i, 2, 0);
  8959. builder.Write("费用标准:");
  8960. builder.MoveToCell(4, i, 3, 0);
  8961. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8962. builder.MoveToCell(4, i, 4, 0);
  8963. builder.Write("费用小计:");
  8964. builder.MoveToCell(4, i, 5, 0);
  8965. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8966. builder.MoveToCell(4, i, 6, 0);
  8967. builder.Write("备注:");
  8968. builder.MoveToCell(4, i, 7, 0);
  8969. builder.Write(dac.Remark);
  8970. }
  8971. #endregion
  8972. }
  8973. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8974. //删除多余行
  8975. while (table5.Rows.Count > table5Row)
  8976. {
  8977. table5.Rows.RemoveAt(table5Row);
  8978. }
  8979. //加上其他费用
  8980. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8981. decimal subJJC = 0.00M,
  8982. subGWC = 0.00M,
  8983. subTDC = 0.00M;
  8984. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8985. string totalLabel = string.Format("全部费用总计:");
  8986. //经济舱
  8987. if (_EnterExitCosts.SumJJC == 1)
  8988. {
  8989. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8990. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8991. }
  8992. //公务舱
  8993. if (_EnterExitCosts.SumGWC == 1)
  8994. {
  8995. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8996. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8997. }
  8998. //头等舱
  8999. if (_EnterExitCosts.SumTDC == 1)
  9000. {
  9001. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  9002. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  9003. }
  9004. //TotalLabel
  9005. dic.Add("TotalLabel", totalLabel);
  9006. #region 填充word模板书签内容
  9007. foreach (var key in dic.Keys)
  9008. {
  9009. Bookmark bookmark = doc.Range.Bookmarks[key];
  9010. if (bookmark != null)
  9011. {
  9012. builder.MoveToBookmark(key);
  9013. builder.Write(dic[key]);
  9014. }
  9015. }
  9016. #endregion
  9017. //文件名
  9018. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  9019. strFileName = CommonFun.ValidFileName(strFileName);
  9020. AsposeHelper.removewatermark_v2180();
  9021. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9022. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9023. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9024. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9025. }
  9026. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  9027. {
  9028. //获取模板
  9029. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  9030. //载入模板
  9031. Document doc = new Document(tempPath);
  9032. DocumentBuilder builder = new DocumentBuilder(doc);
  9033. Dictionary<string, string> dic = new Dictionary<string, string>();
  9034. string returnCodeLabel = string.Empty;
  9035. if (nationalTravelFeeData.Any())
  9036. {
  9037. List<string> list = new List<string>();
  9038. foreach (var item in nationalTravelFeeData)
  9039. {
  9040. list.Add($"{item.Country}({item.City})");
  9041. }
  9042. list = list.Distinct().ToList();
  9043. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9044. }
  9045. var countryLabel = string.Empty;
  9046. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9047. if (countryData.Any())
  9048. {
  9049. countryLabel = string.Join("、", countryData);
  9050. }
  9051. dic.Add("ReturnCodeAir", returnCodeLabel);
  9052. dic.Add("VisitStartDate", "-");
  9053. dic.Add("VisitEndDate", "-");
  9054. dic.Add("Day", "-");
  9055. dic.Add("VisitCountry", countryLabel);
  9056. dic.Add("ClientUnit", "-");
  9057. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  9058. //dic.Add("Names", Names);
  9059. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9060. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9061. decimal dac1totalPrice = 0.00M;
  9062. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  9063. foreach (var dac in dac1)
  9064. {
  9065. if (dac.SubTotal == 0.00M)
  9066. {
  9067. continue;
  9068. }
  9069. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  9070. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  9071. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  9072. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9073. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  9074. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9075. builder.Write(currency);//币种
  9076. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  9077. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9078. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  9079. builder.Write("");//人数
  9080. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  9081. builder.Write("");//天数
  9082. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  9083. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9084. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  9085. decimal rate = 0.00M;
  9086. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9087. builder.Write(rate.ToString("#0.0000"));//汇率
  9088. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  9089. decimal rbmPrice = dac.SubTotal;
  9090. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9091. accommodationStartIndex++;
  9092. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9093. }
  9094. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9095. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  9096. {
  9097. table1.Rows.RemoveAt(i - 1);
  9098. foodandotherStartIndex--;
  9099. }
  9100. if (dac2.Count == dac3.Count)//国家 币种 金额
  9101. {
  9102. for (int i = 0; i < dac2.Count; i++)
  9103. {
  9104. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9105. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9106. }
  9107. }
  9108. decimal dac2totalPrice = 0.00M;
  9109. foreach (var dac in dac2)
  9110. {
  9111. if (dac.SubTotal == 0)
  9112. {
  9113. continue;
  9114. }
  9115. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  9116. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9117. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  9118. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9119. builder.Write(currency);//币种
  9120. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  9121. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9122. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  9123. builder.Write("");//人数
  9124. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  9125. builder.Write("");//天数
  9126. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  9127. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9128. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  9129. decimal rate = 0.00M;
  9130. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9131. builder.Write(rate.ToString("#0.0000"));//汇率
  9132. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  9133. decimal rbmPrice = dac.SubTotal;
  9134. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9135. foodandotherStartIndex++;
  9136. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9137. }
  9138. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  9139. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  9140. {
  9141. table1.Rows.RemoveAt(i - 1);
  9142. }
  9143. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9144. string otherFeeStr = "";
  9145. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  9146. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  9147. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  9148. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  9149. foreach (var otherInfo in dac5)
  9150. {
  9151. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  9152. }
  9153. #endregion
  9154. if (otherFeeStr.Length > 0)
  9155. {
  9156. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  9157. otherFeeStr = $"({otherFeeStr})";
  9158. dic.Add("OtherFeeStr", otherFeeStr);
  9159. }
  9160. //总计
  9161. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  9162. //国际旅费
  9163. string outsideAir = string.Empty;
  9164. string allPriceAir = string.Empty;
  9165. if (_EnterExitCosts.SumJJC == 1)
  9166. {
  9167. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9168. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  9169. }
  9170. if (_EnterExitCosts.SumGWC == 1)
  9171. {
  9172. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  9173. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9174. }
  9175. if (_EnterExitCosts.SumTDC == 1)
  9176. {
  9177. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  9178. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  9179. }
  9180. dic.Add("InTravelPrice", $"({outsideAir})");
  9181. dic.Add("FinalSumPrice", $"({allPriceAir})");
  9182. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  9183. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  9184. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  9185. foreach (var key in dic.Keys)
  9186. {
  9187. builder.MoveToBookmark(key);
  9188. builder.Write(dic[key]);
  9189. }
  9190. //模板文件名
  9191. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9192. strFileName = CommonFun.ValidFileName(strFileName);
  9193. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9194. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9195. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9196. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9197. }
  9198. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  9199. {
  9200. //获取模板
  9201. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  9202. //载入模板
  9203. WorkbookDesigner designer = new WorkbookDesigner();
  9204. designer.Workbook = new Workbook(tempPath);
  9205. Dictionary<string, string> dic = new Dictionary<string, string>();
  9206. string returnCodeLabel = string.Empty;
  9207. if (nationalTravelFeeData.Any())
  9208. {
  9209. List<string> list = new List<string>();
  9210. foreach (var item in nationalTravelFeeData)
  9211. {
  9212. list.Add($"{item.Country}({item.City})");
  9213. }
  9214. list = list.Distinct().ToList();
  9215. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9216. }
  9217. var countryLabel = string.Empty;
  9218. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9219. if (countryData.Any())
  9220. {
  9221. countryLabel = string.Join("、", countryData);
  9222. }
  9223. dic.Add("ReturnCodeAir", returnCodeLabel);
  9224. dic.Add("VisitStartDate", "-");
  9225. dic.Add("VisitEndDate", "-");
  9226. dic.Add("Day", "0");
  9227. dic.Add("VisitCountry", countryLabel);
  9228. dic.Add("ClientUnit", "-");
  9229. designer.SetDataSource("ClientUnit", "-");
  9230. designer.SetDataSource("VisitCountry", countryLabel);
  9231. designer.SetDataSource("Group", "-");
  9232. designer.SetDataSource("ClientUnitTitle", "-");
  9233. designer.SetDataSource("Name", "-");
  9234. designer.SetDataSource("VisitStartDate", "-");
  9235. designer.SetDataSource("Day", "0");
  9236. designer.SetDataSource("ReturnCode", returnCodeLabel);
  9237. designer.SetDataSource("ReturnCodeAir", "-");
  9238. int startIndex = 10;
  9239. const int startIndexcopy = 10;
  9240. if (dac2.Count == dac3.Count)//国家 币种 金额
  9241. {
  9242. for (int i = 0; i < dac2.Count; i++)
  9243. {
  9244. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9245. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9246. }
  9247. }
  9248. DataTable dtdac1 = new DataTable();
  9249. List<string> place = new List<string>();
  9250. dtdac1.Columns.AddRange(new DataColumn[] {
  9251. new DataColumn(){ ColumnName = "city"},
  9252. new DataColumn(){ ColumnName = "curr"},
  9253. new DataColumn(){ ColumnName = "criterion"},
  9254. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9255. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9256. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9257. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9258. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  9259. });
  9260. DataTable dtdac2 = new DataTable();
  9261. dtdac2.Columns.AddRange(new DataColumn[] {
  9262. new DataColumn(){ ColumnName = "city"},
  9263. new DataColumn(){ ColumnName = "curr"},
  9264. new DataColumn(){ ColumnName = "criterion"},
  9265. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9266. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9267. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9268. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9269. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  9270. });
  9271. dtdac1.TableName = "tb1";
  9272. dtdac2.TableName = "tb2";
  9273. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  9274. foreach (var item in dac1)
  9275. {
  9276. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9277. if (place.Contains(item.Place))
  9278. {
  9279. continue;
  9280. }
  9281. DataRow row = dtdac1.NewRow();
  9282. row["city"] = item.Place;
  9283. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9284. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9285. row["curr"] = currency;
  9286. row["rate"] = rate.ToString("#0.0000");
  9287. row["criterion"] = item.Cost.ToString("#0.00");
  9288. row["number"] = 1;
  9289. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9290. //row["costRMB"] = rbmPrice;
  9291. dtdac1.Rows.Add(row);
  9292. place.Add(item.Place);
  9293. }
  9294. place = new List<string>();
  9295. foreach (var item in dac2)
  9296. {
  9297. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9298. if (place.Contains(item.Place))
  9299. {
  9300. continue;
  9301. }
  9302. DataRow row = dtdac2.NewRow();
  9303. row["city"] = item.Place;
  9304. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9305. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9306. row["curr"] = currency;
  9307. row["rate"] = rate.ToString("#0.0000");
  9308. row["criterion"] = item.Cost.ToString("#0.00");
  9309. row["number"] = 1;
  9310. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9311. //row["cost"] = item.SubTotal;
  9312. //row["costRMB"] = rbmPrice;
  9313. dtdac2.Rows.Add(row);
  9314. place.Add(item.Place);
  9315. //dac2totalPrice += rbmPrice;
  9316. }
  9317. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9318. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9319. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9320. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9321. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9322. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9323. string cell4Str1 = string.Empty;
  9324. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9325. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9326. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9327. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9328. string cellStr = $" 5.其他费用(";
  9329. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9330. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9331. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9332. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9333. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9334. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9335. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9336. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9337. foreach (var otherInfo in dac5)
  9338. {
  9339. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9340. }
  9341. #endregion
  9342. if (cellStr.Length > 8)
  9343. {
  9344. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9345. }
  9346. cellStr += ")";
  9347. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9348. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9349. decimal pxFee = dac4.Sum(it => it.Cost);
  9350. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9351. string celllastStr1 = "";
  9352. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9353. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9354. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9355. celllastStr1 += $",国际旅费 元";
  9356. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9357. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9358. designer.SetDataSource("cell4Str", cell4Str);
  9359. designer.SetDataSource("cellStr", cellStr);
  9360. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9361. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9362. designer.SetDataSource("celllastStr", celllastStr);
  9363. Workbook wb = designer.Workbook;
  9364. var sheet = wb.Worksheets[0];
  9365. //绑定datatable数据集
  9366. designer.SetDataSource(dtdac1);
  9367. designer.SetDataSource(dtdac2);
  9368. designer.Process();
  9369. var rowStart = dtdac1.Rows.Count;
  9370. while (rowStart > 0)
  9371. {
  9372. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  9373. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9374. startIndex++;
  9375. rowStart--;
  9376. }
  9377. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  9378. startIndex += 1; //总计行
  9379. rowStart = dtdac2.Rows.Count;
  9380. while (rowStart > 0)
  9381. {
  9382. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  9383. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9384. startIndex++;
  9385. rowStart--;
  9386. }
  9387. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  9388. wb.CalculateFormula(true);
  9389. //模板文件名
  9390. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9391. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9392. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9393. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9394. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9395. }
  9396. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  9397. {
  9398. //获取模板
  9399. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  9400. //载入模板
  9401. Document doc = new Document(tempPath);
  9402. DocumentBuilder builder = new DocumentBuilder(doc);
  9403. Dictionary<string, string> dic = new Dictionary<string, string>();
  9404. dic.Add("GroupName", "-");
  9405. dic.Add("ClientUnit", "-");
  9406. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9407. //string missionLeaderJob = "";//负责人job
  9408. //int groupNumber = 0; //团人数
  9409. dic.Add("MissionLeader", "-"); //团负责人
  9410. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9411. dic.Add("GroupNumber", "0"); //团人数
  9412. dic.Add("Day", "0");
  9413. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9414. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9415. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9416. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9417. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9418. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9419. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9420. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9421. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9422. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9423. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9424. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9425. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9426. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9427. //其他费用
  9428. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9429. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9430. //其他费用合计
  9431. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9432. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9433. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9434. //公务舱合计
  9435. //国际旅费
  9436. //string outsideJJ = "";
  9437. //string allPriceJJ = "";
  9438. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9439. {
  9440. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9441. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9442. }
  9443. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9444. {
  9445. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9446. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9447. }
  9448. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9449. {
  9450. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9451. dic.Add("AirFeeTotal", airFeeTotalStr);
  9452. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9453. dic.Add("FeeTotal", feeTotalStr);
  9454. }
  9455. foreach (var key in dic.Keys)
  9456. {
  9457. builder.MoveToBookmark(key);
  9458. builder.Write(dic[key]);
  9459. }
  9460. //模板文件名
  9461. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9462. strFileName = CommonFun.ValidFileName(strFileName);
  9463. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9464. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9465. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9466. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9467. }
  9468. }
  9469. else if (dto.ExportType == 2) //表格
  9470. {
  9471. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9472. }
  9473. else if (dto.ExportType == 3)
  9474. {
  9475. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9476. }
  9477. return Ok(JsonView(400, "只可导出明细表!", ""));
  9478. }
  9479. catch (Exception ex)
  9480. {
  9481. return Ok(JsonView(400, ex.Message, ""));
  9482. }
  9483. }
  9484. /// <summary>
  9485. /// 获取三公费用标准city
  9486. /// </summary>
  9487. /// <param name="placeData"></param>
  9488. /// <param name="nationalTravelFeeId"></param>
  9489. /// <returns></returns>
  9490. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9491. {
  9492. string _city = string.Empty;
  9493. if (!placeData.Any()) return _city;
  9494. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9495. if (data == null) return _city;
  9496. string country = data.Country;
  9497. string city = data.City;
  9498. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9499. else _city = city;
  9500. return _city;
  9501. }
  9502. /// <summary>
  9503. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9504. /// </summary>
  9505. /// <returns></returns>
  9506. [HttpPost]
  9507. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9509. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9510. {
  9511. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9512. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9513. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9514. if (_view.Code == 0)
  9515. {
  9516. return Ok(JsonView(true, "操作成功"));
  9517. }
  9518. return Ok(JsonView(false, "操作失败"));
  9519. }
  9520. /// <summary>
  9521. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9522. /// </summary>
  9523. /// <returns></returns>
  9524. [HttpPost]
  9525. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9527. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9528. {
  9529. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9530. if (data.Code != 0)
  9531. {
  9532. return Ok(JsonView(false, data.Msg));
  9533. }
  9534. return Ok(JsonView(true, "操作成功!", data.Data));
  9535. }
  9536. /// <summary>
  9537. /// 三公其他费用草稿 删除
  9538. /// </summary>
  9539. /// <param name="dto"></param>
  9540. /// <returns></returns>
  9541. [HttpPost]
  9542. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9543. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9544. {
  9545. var jw = JsonView(false, "删除失败!");
  9546. var data = new Grp_DayOtherPriceDraft()
  9547. {
  9548. Id = dto.Id,
  9549. IsDel = 1,
  9550. DeleteUserId = dto.DeleteUserId,
  9551. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9552. };
  9553. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9554. if (del > 0)
  9555. {
  9556. jw.Code = 200;
  9557. jw.Msg = "删除成功!";
  9558. }
  9559. return Ok(jw);
  9560. }
  9561. /// <summary>
  9562. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9563. /// </summary>
  9564. /// <returns></returns>
  9565. [HttpPost]
  9566. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9567. {
  9568. var jw = JsonView(false);
  9569. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9570. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9571. jw.Code = StatusCodes.Status200OK;
  9572. jw.Msg = "操作成功!";
  9573. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9574. return Ok(jw);
  9575. }
  9576. /// <summary>
  9577. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9578. /// </summary>
  9579. /// <param name="dto"></param>
  9580. /// <returns></returns>
  9581. [HttpPost]
  9582. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9583. {
  9584. int userId = dto.UserId,
  9585. portId = dto.PortType,
  9586. groupId = dto.GroupId,
  9587. draftId = dto.DraftId;
  9588. _portTypeData.Add(1);
  9589. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9590. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9591. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9592. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9593. _sqlSugar.BeginTran();
  9594. try
  9595. {
  9596. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9597. if (draftDatas == null)
  9598. {
  9599. _sqlSugar.RollbackTran();
  9600. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9601. }
  9602. //验证可覆盖已有数据 两边创建人需为同一人;
  9603. int draftCreateUserId = draftDatas.CreateUserId,
  9604. formalCreateUserId = 0;
  9605. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9606. if (formalData != null)
  9607. {
  9608. formalCreateUserId = formalData.CreateUserId;
  9609. if (draftCreateUserId != formalCreateUserId)
  9610. {
  9611. _sqlSugar.RollbackTran();
  9612. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9613. }
  9614. }
  9615. //默认添加查看、编辑权限(创建人、自己)
  9616. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9617. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9618. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9619. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9620. newExterData.DiId = groupId;
  9621. newExterData.CreateUserId = userId;
  9622. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9623. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9624. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9625. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9626. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9627. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9628. //数据如果存在执行删除
  9629. if (enterExitCostInfo != null)
  9630. {
  9631. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9632. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9633. .Where(x => x.Id == enterExitCostInfo.Id)
  9634. .ExecuteCommand();
  9635. _sqlSugar.Updateable<Grp_DayAndCost>()
  9636. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9637. .Where(x => x.DiId == groupId)
  9638. .ExecuteCommand();
  9639. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9640. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9641. .Where(x => x.Diid == groupId)
  9642. .ExecuteCommand();
  9643. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9644. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9645. .Where(x => x.GroupId == groupId)
  9646. .ExecuteCommand();
  9647. }
  9648. //执行insert
  9649. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9650. if (insertId < 1)
  9651. {
  9652. _sqlSugar.RollbackTran();
  9653. return Ok(JsonView(false, "草稿数据导入失败!"));
  9654. }
  9655. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9656. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9657. #region 默认添加权限
  9658. #endregion
  9659. _sqlSugar.CommitTran();
  9660. //执行操作之后
  9661. //生成默认文件pdf并且通知人员
  9662. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9663. {
  9664. DiId = groupId,
  9665. ExportType = 1,
  9666. SubTypeId = 1005
  9667. }, "pdf");
  9668. //发送通知
  9669. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9670. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9671. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9672. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9673. //汇率信息记录
  9674. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9675. return Ok(JsonView(true));
  9676. }
  9677. catch (Exception ex)
  9678. {
  9679. _sqlSugar.RollbackTran();
  9680. return Ok(JsonView(false, ex.Message));
  9681. }
  9682. }
  9683. #endregion
  9684. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9685. /// <summary>
  9686. /// 获取币种基础数据(含逻辑处理)
  9687. /// </summary>
  9688. /// <returns></returns>
  9689. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9690. {
  9691. return await GeneralMethod.EnterExitCostInitRate();
  9692. }
  9693. /// <summary>
  9694. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9695. /// </summary>
  9696. /// <returns></returns>
  9697. [HttpPost]
  9698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9699. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9700. {
  9701. //验证城市归属并给默认值
  9702. int provinceId = dto.ProvinceId;
  9703. if (provinceId < 1) provinceId = 122;
  9704. var dataSource = await _sqlSugar
  9705. .Queryable<Sys_SetData>()
  9706. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9707. .ToListAsync();
  9708. var fileTypes = new List<EecSetDataInfoView>();
  9709. //三公费用-Word明细类型
  9710. var wordTypeData = dataSource
  9711. .Where(it => it.STid == 72)
  9712. .Select(x => new EecSetDataInfoView
  9713. {
  9714. ParentId = 1,
  9715. Id = x.Id,
  9716. Name = x.Name
  9717. })
  9718. .ToArray();
  9719. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9720. var excelTypeData = dataSource
  9721. .Where(it => it.STid == 73)
  9722. .Select(x => new EecSetDataInfoView
  9723. {
  9724. ParentId = 2,
  9725. Id = x.Id,
  9726. Name = x.Name
  9727. })
  9728. .ToArray();
  9729. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9730. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9731. fileTypes.Add(groupNameList);
  9732. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9733. //默认币种显示
  9734. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9735. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9736. return Ok(JsonView(true, "查询成功!", new
  9737. {
  9738. FileTypeData = fileTypes,
  9739. CurrencyInit = _currencyInfos,
  9740. viewPermissionData = viewPermissionData
  9741. }));
  9742. }
  9743. /// <summary>
  9744. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9745. /// </summary>
  9746. /// <returns></returns>
  9747. [HttpPost]
  9748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9749. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9750. {
  9751. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9752. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9753. RefAsync<int> total = 0;
  9754. int diId = 0;
  9755. var status = int.TryParse(dto.GroupName, out diId);
  9756. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9757. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9758. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9759. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9760. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9761. .OrderByDescending(x => x.VisitStartDate)
  9762. .Select(x => new EnterExitCostMobileGroupView()
  9763. {
  9764. Id = x.Id,
  9765. GroupName = x.TeamName,
  9766. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9767. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9768. ProvinceId = x.CityId
  9769. })
  9770. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9771. //处理省份Id
  9772. if (data.Any())
  9773. {
  9774. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9775. if (provCityDatas.Any())
  9776. {
  9777. foreach (var item in data)
  9778. {
  9779. var provinceId = item.ProvinceId;
  9780. var isDefualtVal = true;
  9781. if (provinceId > 0)
  9782. {
  9783. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9784. if (parentId != null)
  9785. {
  9786. isDefualtVal = false;
  9787. item.ProvinceId = (int)parentId;
  9788. }
  9789. }
  9790. if (isDefualtVal)
  9791. {
  9792. item.ProvinceId = 122; //默认四川
  9793. }
  9794. }
  9795. }
  9796. }
  9797. //处理是否显示
  9798. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9799. {
  9800. foreach (var item in data)
  9801. {
  9802. item.IsView = true;
  9803. }
  9804. }
  9805. return Ok(JsonView(true, "查询成功!", data, total));
  9806. }
  9807. /// <summary>
  9808. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9809. /// </summary>
  9810. /// <returns></returns>
  9811. [HttpPost]
  9812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9813. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9814. {
  9815. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9816. RefAsync<int> total = 0;
  9817. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9818. .Where(x => x.IsDel == 0 && x.STid == 66)
  9819. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9820. .Select(x => new
  9821. {
  9822. id = x.Id,
  9823. name = x.Name,
  9824. remark = x.Remark,
  9825. })
  9826. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9827. return Ok(JsonView(true, "查询成功!", data, total));
  9828. }
  9829. /// <summary>
  9830. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9831. /// </summary>
  9832. /// <returns></returns>
  9833. [HttpPost]
  9834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9835. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9836. {
  9837. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9838. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9839. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9840. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9841. var groupOtherRateData = groupRateData.TeamRates;
  9842. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9843. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9844. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9845. groupOtherRateData = groupOtherRateData
  9846. .Select(x => new TeamRateDescAddCurrencyIdView
  9847. {
  9848. CurrencyId = x.CurrencyId,
  9849. CurrencyName = x.CurrencyName,
  9850. CurrencyCode = x.CurrencyCode,
  9851. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9852. }).ToList();
  9853. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9854. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9855. }
  9856. /// <summary>
  9857. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9858. /// </summary>
  9859. /// <returns></returns>
  9860. [HttpPost]
  9861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9862. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9863. {
  9864. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9865. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9866. var tipsData = new List<int>() { 1, 2, 3 };
  9867. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9868. if (dto.TipsType == 1)
  9869. {
  9870. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9871. }
  9872. else if (dto.TipsType == 2)
  9873. {
  9874. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9875. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9876. }
  9877. else if (dto.TipsType == 3)
  9878. {
  9879. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9880. return Ok(JsonView(true, "查询成功!", airData));
  9881. }
  9882. return Ok(JsonView(false));
  9883. }
  9884. /// <summary>
  9885. /// 团组模块 - 出入境国家费用标准-移动端 List
  9886. /// </summary>
  9887. /// <returns></returns>
  9888. [HttpPost]
  9889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9890. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9891. {
  9892. Stopwatch sw = new Stopwatch();
  9893. sw.Start();
  9894. int provinceId = dto.ProvinceId;
  9895. if (provinceId < 1) provinceId = 122; // 默认四川
  9896. RefAsync<int> total = 0;
  9897. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9898. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9899. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9900. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9901. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9902. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9903. .Select((ntf, sd, u, sd1) => new
  9904. {
  9905. Id = ntf.Id,
  9906. Area = $"{ntf.Country}-{ntf.City}",
  9907. Currency = ntf.Currency,
  9908. CurrencyCode = sd.Name,
  9909. CurrencyName = sd.Remark,
  9910. RoomCost = ntf.RoomCost,
  9911. FoodCost = ntf.FoodCost,
  9912. PublicCost = ntf.PublicCost,
  9913. TrainCost = ntf.TrainCost,
  9914. LastUpdateUserId = ntf.LastUpdateUserId,
  9915. LastUpdateUserName = u.CnName,
  9916. LastUpdateTime = ntf.LastUpdateTime
  9917. })
  9918. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9919. sw.Stop();
  9920. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9921. }
  9922. /// <summary>
  9923. /// 团组模块 - 出入境费用-移动端 - Info
  9924. /// </summary>
  9925. /// <returns></returns>
  9926. [HttpPost]
  9927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9928. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9929. {
  9930. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9931. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9932. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9933. return Ok(data);
  9934. }
  9935. /// <summary>
  9936. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9937. /// </summary>
  9938. /// <returns></returns>
  9939. [HttpPost]
  9940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9941. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9942. {
  9943. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9944. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9945. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9946. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9947. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9948. mobileInfo.DiId = dto.DiId;
  9949. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9950. if (eecInfo == null) return Ok(mobileInfo);
  9951. //验证查看权限
  9952. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9953. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9954. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9955. mobileInfo.IsAssignPerm = isSet;
  9956. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9957. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9958. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9959. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9960. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9961. {
  9962. SubId = dac.Id,
  9963. DiId = dac.DiId,
  9964. Type = dac.Type,
  9965. Days = dac.Days,
  9966. NationalTravelFeeId = dac.NationalTravelFeeId,
  9967. Arae = $"{ntf.Country}-{ntf.City}",
  9968. Cost = dac.Cost,
  9969. Currency = dac.Currency,
  9970. CurrencyName = sd.Name,
  9971. SubTotal = dac.SubTotal,
  9972. })
  9973. .ToList();
  9974. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9975. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9976. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9977. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9978. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9979. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9980. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9981. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9982. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9983. //其他款项
  9984. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9985. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9986. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9987. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9988. .OrderBy((dop, sd1, sd2) => dop.Index)
  9989. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9990. {
  9991. SubId = dop.Id,
  9992. DiId = dop.Diid,
  9993. Index = dop.Index,
  9994. SetDataId = dop.SetDataId,
  9995. SetDataName = sd1.Name,
  9996. Cost = dop.Cost,
  9997. Currency = dop.Currency,
  9998. CurrencyName = sd2.Remark,
  9999. SubTotal = dop.SubTotal,
  10000. Remark = dop.Remark,
  10001. })
  10002. .ToArray();
  10003. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10004. return Ok(mobileInfo);
  10005. }
  10006. /// <summary>
  10007. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  10008. /// </summary>
  10009. /// <returns></returns>
  10010. [HttpPost]
  10011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10012. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  10013. {
  10014. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10015. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10016. //验证查看权限
  10017. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  10018. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  10019. var userIds = await _sqlSugar
  10020. .Queryable<Grp_EnterExitCostPermission>()
  10021. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  10022. .Select(x => x.UserId)
  10023. .ToArrayAsync();
  10024. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  10025. var perUsersView = new List<dynamic>();
  10026. foreach (var item in perUsers)
  10027. {
  10028. bool isView1 = false;
  10029. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10030. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10031. }
  10032. return Ok(JsonView(perUsersView));
  10033. }
  10034. /// <summary>
  10035. /// 团组模块 - 出入境费用-移动端 - SubInfo
  10036. /// </summary>
  10037. /// <returns></returns>
  10038. [HttpPost]
  10039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10040. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  10041. {
  10042. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10043. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10044. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10045. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10046. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10047. //验证查看权限
  10048. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  10049. //if (!isView) return Ok(JsonView(false, msg));
  10050. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10051. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10052. var subType = dto.SubType;
  10053. if (subType == 1) //1:境内费用
  10054. {
  10055. var oneData = new ChoiceOneMobileSubInfoView()
  10056. {
  10057. Id = eecInfo.Id,
  10058. ChoiceOne = eecInfo.ChoiceOne,
  10059. ChoiceOneTotalCost = eecInfo.InsidePay,
  10060. Visa = eecInfo.Visa,
  10061. VisaRemark = eecInfo.VisaRemark,
  10062. YiMiao = eecInfo.YiMiao,
  10063. HeSuan = eecInfo.HeSuan,
  10064. Service = eecInfo.Service,
  10065. Ticket = eecInfo.Ticket,
  10066. Safe = eecInfo.Safe,
  10067. FirstItemRemark = eecInfo.FirstItemRemark
  10068. };
  10069. return Ok(JsonView(oneData));
  10070. }
  10071. else if (subType == 2) //2:国际旅费
  10072. {
  10073. var twoData = new ChoiceTwoMobileSubInfoView()
  10074. {
  10075. Id = eecInfo.Id,
  10076. ChoiceTwoJJ = eecInfo.SumJJC,
  10077. OutsideJJPay = eecInfo.OutsideJJPay,
  10078. ChoiceTwoGW = eecInfo.SumGWC,
  10079. OutsideGWPay = eecInfo.OutsideGWPay,
  10080. ChoiceTwoTD = eecInfo.SumTDC,
  10081. OutsideTDPay = eecInfo.OutsideTDPay,
  10082. AirJJ = eecInfo.AirJJ,
  10083. AirGW = eecInfo.AirGW,
  10084. AirTD = eecInfo.AirTD,
  10085. CityTranffic = eecInfo.CityTranffic,
  10086. TwoItemRemark = eecInfo.TwoItemRemark
  10087. };
  10088. return Ok(JsonView(twoData));
  10089. }
  10090. else if (subType == 3) //3:住宿费
  10091. {
  10092. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10093. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10094. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10095. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  10096. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10097. {
  10098. SubId = dac.Id,
  10099. DiId = dac.DiId,
  10100. Type = dac.Type,
  10101. Days = dac.Days,
  10102. NationalTravelFeeId = dac.NationalTravelFeeId,
  10103. Arae = $"{ntf.Country}-{ntf.City}",
  10104. Cost = dac.Cost,
  10105. Currency = dac.Currency,
  10106. CurrencyName = sd.Name,
  10107. SubTotal = dac.SubTotal,
  10108. })
  10109. .ToArray();
  10110. var data = new ChoiceMobileSubInfo3To6View()
  10111. {
  10112. ParentId = eecInfo.Id,
  10113. Choice = eecInfo.ChoiceThree,
  10114. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10115. Details = dayAndCostDatas
  10116. };
  10117. return Ok(JsonView(data));
  10118. }
  10119. else if (subType == 4) //4:伙食费
  10120. {
  10121. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10122. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10123. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10124. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  10125. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10126. {
  10127. SubId = dac.Id,
  10128. DiId = dac.DiId,
  10129. Type = dac.Type,
  10130. Days = dac.Days,
  10131. NationalTravelFeeId = dac.NationalTravelFeeId,
  10132. Arae = $"{ntf.Country}-{ntf.City}",
  10133. Cost = dac.Cost,
  10134. Currency = dac.Currency,
  10135. CurrencyName = sd.Name,
  10136. SubTotal = dac.SubTotal,
  10137. })
  10138. .ToArray();
  10139. var data = new ChoiceMobileSubInfo3To6View()
  10140. {
  10141. ParentId = eecInfo.Id,
  10142. Choice = eecInfo.ChoiceFour,
  10143. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10144. Details = dayAndCostDatas
  10145. };
  10146. return Ok(JsonView(data));
  10147. }
  10148. else if (subType == 5) //5:公杂费
  10149. {
  10150. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10151. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10152. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10153. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  10154. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10155. {
  10156. SubId = dac.Id,
  10157. DiId = dac.DiId,
  10158. Type = dac.Type,
  10159. Days = dac.Days,
  10160. NationalTravelFeeId = dac.NationalTravelFeeId,
  10161. Arae = $"{ntf.Country}-{ntf.City}",
  10162. Cost = dac.Cost,
  10163. Currency = dac.Currency,
  10164. CurrencyName = sd.Name,
  10165. SubTotal = dac.SubTotal,
  10166. })
  10167. .ToArray();
  10168. var data = new ChoiceMobileSubInfo3To6View()
  10169. {
  10170. ParentId = eecInfo.Id,
  10171. Choice = eecInfo.ChoiceFive,
  10172. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10173. Details = dayAndCostDatas
  10174. };
  10175. return Ok(JsonView(data));
  10176. }
  10177. else if (subType == 6) //6:培训费
  10178. {
  10179. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10180. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10181. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10182. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  10183. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10184. {
  10185. SubId = dac.Id,
  10186. DiId = dac.DiId,
  10187. Type = dac.Type,
  10188. Days = dac.Days,
  10189. NationalTravelFeeId = dac.NationalTravelFeeId,
  10190. Arae = $"{ntf.Country}-{ntf.City}",
  10191. Cost = dac.Cost,
  10192. Currency = dac.Currency,
  10193. CurrencyName = sd.Name,
  10194. SubTotal = dac.SubTotal,
  10195. })
  10196. .ToArray();
  10197. var data = new ChoiceMobileSubInfo3To6View()
  10198. {
  10199. ParentId = eecInfo.Id,
  10200. Choice = eecInfo.ChoiceSix,
  10201. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10202. Details = dayAndCostDatas
  10203. };
  10204. return Ok(JsonView(data));
  10205. }
  10206. else if (subType == 7) //7:其他
  10207. {
  10208. //其他款项
  10209. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10210. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10211. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10212. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10213. .OrderBy((dop, sd1, sd2) => dop.Index)
  10214. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10215. {
  10216. SubId = dop.Id,
  10217. DiId = dop.Diid,
  10218. Index = dop.Index,
  10219. SetDataId = dop.SetDataId,
  10220. SetDataName = sd1.Name,
  10221. Cost = dop.Cost,
  10222. Currency = dop.Currency,
  10223. CurrencyName = sd2.Name,
  10224. SubTotal = dop.SubTotal,
  10225. Remark = dop.Remark,
  10226. })
  10227. .ToArray();
  10228. var data = new ChoiceSevenMobileSubInfoView()
  10229. {
  10230. ParentId = eecInfo.Id,
  10231. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10232. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10233. Details = otherData
  10234. };
  10235. return Ok(JsonView(data));
  10236. }
  10237. return Ok(JsonView(false));
  10238. }
  10239. #region op
  10240. ///// <summary>
  10241. ///// 移动端更新费用消息通知
  10242. ///// </summary>
  10243. ///// <param name="diid"></param>
  10244. ///// <param name="id"></param>
  10245. ///// <param name="currUserId"></param>
  10246. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  10247. //{
  10248. // try
  10249. // {
  10250. // ////生成默认文件pdf并且通知人员
  10251. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10252. // //{
  10253. // // DiId = diid,
  10254. // // ExportType = 1,
  10255. // // SubTypeId = 1005
  10256. // //}, "pdf");
  10257. // ////发送通知
  10258. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10259. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10260. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10261. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  10262. // ////汇率信息记录
  10263. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10264. // }
  10265. // catch (Exception ex)
  10266. // {
  10267. // //记录日志
  10268. // throw;
  10269. // }
  10270. //}
  10271. /// <summary>
  10272. /// 验证出入境费用数据是否存在
  10273. /// 不存在添加
  10274. /// </summary>
  10275. /// <param name="diId"></param>
  10276. /// <param name="currUserId"></param>
  10277. /// <returns></returns>
  10278. /// <exception cref="CustomException"></exception>
  10279. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  10280. {
  10281. var parentId = 0;
  10282. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10283. if (info != null)
  10284. {
  10285. parentId = info.Id;
  10286. }
  10287. else
  10288. {
  10289. var currencys = await EnterExitCostMobileGetCurrencyInit();
  10290. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10291. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10292. parentId = addId;
  10293. }
  10294. return parentId;
  10295. }
  10296. /// <summary>
  10297. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  10298. /// </summary>
  10299. /// <returns></returns>
  10300. [HttpPost]
  10301. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10302. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  10303. {
  10304. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10305. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10306. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10307. //验证编辑权限
  10308. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10309. //if (!isEdit) return Ok(JsonView(false, msg));
  10310. var permissions = new List<Grp_EnterExitCostPermission>();
  10311. foreach (var userId in dto.UserIds)
  10312. {
  10313. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10314. }
  10315. if (permissions.Any())
  10316. {
  10317. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10318. {
  10319. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10320. }
  10321. _sqlSugar.BeginTran();
  10322. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10323. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10324. if (result < 1)
  10325. {
  10326. _sqlSugar.RollbackTran();
  10327. return Ok(JsonView(false));
  10328. }
  10329. _sqlSugar.CommitTran();
  10330. return Ok(JsonView(true));
  10331. }
  10332. return Ok(JsonView(false));
  10333. }
  10334. /// <summary>
  10335. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10336. /// </summary>
  10337. /// <returns></returns>
  10338. [HttpPost]
  10339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10340. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10341. {
  10342. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10343. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10344. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10345. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10346. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10347. int id = dto.Id;
  10348. if (id <= 0) //add
  10349. {
  10350. //int provinceId = dto.ProvinceId;
  10351. int groupId = dto.DiId;
  10352. //if (provinceId < 1) provinceId = 122;
  10353. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10354. info.LastUpdateUserId = dto.CurrUserId;
  10355. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10356. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10357. if (add < 1) return Ok(JsonView(false));
  10358. id = add;
  10359. }
  10360. else //update
  10361. {
  10362. ////验证编辑权限
  10363. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10364. //if (!isEdit) return Ok(JsonView(false, msg));
  10365. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  10366. {
  10367. CurrencyRemark = currencyStr,
  10368. LastUpdateUserId = dto.CurrUserId,
  10369. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10370. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  10371. if (upd < 1) return Ok(JsonView(false));
  10372. }
  10373. #region 汇率变更时更改币种相关费用
  10374. var opDayCosts = new List<Grp_DayAndCost>();
  10375. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  10376. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10377. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  10378. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10379. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10380. .Select((dac, sd) => new
  10381. {
  10382. dac.Id,
  10383. dac.DiId,
  10384. CurrencyCode = sd.Name,
  10385. dac.Cost
  10386. })
  10387. .ToList();
  10388. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10389. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10390. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10391. .Select((dop, sd) => new
  10392. {
  10393. dop.Id,
  10394. dop.Diid,
  10395. CurrencyCode = sd.Name,
  10396. dop.Cost
  10397. })
  10398. .ToList();
  10399. if (dayCosts.Count > 0)
  10400. {
  10401. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10402. foreach (var dc in new_dayCosts)
  10403. {
  10404. var thisCurrency = dc.Key.ToUpper();
  10405. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10406. if (thisRate == 0.00M) continue;
  10407. foreach (var dcSub in dc)
  10408. {
  10409. opDayCosts.Add(new Grp_DayAndCost()
  10410. {
  10411. Id = dcSub.Id,
  10412. DiId = dcSub.DiId,
  10413. Cost = dcSub.Cost,
  10414. SubTotal = dcSub.Cost * thisRate,
  10415. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10416. });
  10417. }
  10418. }
  10419. if (opDayCosts.Count > 0)
  10420. {
  10421. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10422. }
  10423. }
  10424. if (dayOtherCosts.Count > 0)
  10425. {
  10426. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10427. foreach (var dc in new_dayOtherCosts)
  10428. {
  10429. var thisCurrency = dc.Key.ToUpper();
  10430. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10431. if (thisRate == 0.00M) continue;
  10432. foreach (var dcSub in dc)
  10433. {
  10434. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10435. {
  10436. Id = dcSub.Id,
  10437. Diid = dcSub.Diid,
  10438. Cost = dcSub.Cost,
  10439. SubTotal = dcSub.Cost * thisRate,
  10440. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10441. });
  10442. }
  10443. }
  10444. if (opDayOtherCosts.Count > 0)
  10445. {
  10446. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10447. }
  10448. }
  10449. #endregion
  10450. //消息通知
  10451. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10452. //汇率信息记录
  10453. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10454. return Ok(JsonView(new { parentId = id }));
  10455. }
  10456. /// <summary>
  10457. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10458. /// </summary>
  10459. /// <returns></returns>
  10460. [HttpPost]
  10461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10462. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10463. {
  10464. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10465. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10466. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10467. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10468. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10469. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  10470. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10471. int id = dto.Id;
  10472. if (id <= 0) //add
  10473. {
  10474. checkboxInfo.CreateUserId = dto.CurrUserId;
  10475. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10476. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10477. if (add < 1) return Ok(JsonView(false));
  10478. }
  10479. else //update
  10480. {
  10481. ////验证编辑权限
  10482. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10483. //if (!isEdit) return Ok(JsonView(false, msg));
  10484. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10485. .UpdateColumns(x => new
  10486. {
  10487. x.ChoiceOne,
  10488. x.ChoiceTwo,
  10489. x.SumJJC,
  10490. x.SumGWC,
  10491. x.SumTDC,
  10492. x.ChoiceThree,
  10493. x.ChoiceFour,
  10494. x.ChoiceFive,
  10495. x.ChoiceSix,
  10496. x.OtherExpenses_Checked
  10497. })
  10498. .Where(x => x.Id == id)
  10499. .ExecuteCommandAsync();
  10500. if (upd < 1) return Ok(JsonView(false));
  10501. }
  10502. return Ok(JsonView(new { parentId = id }));
  10503. }
  10504. /// <summary>
  10505. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10506. /// </summary>
  10507. /// <returns></returns>
  10508. [HttpPost]
  10509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10510. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10511. {
  10512. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10513. // if (provinceId < 1) provinceId = 122;
  10514. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10515. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10516. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10517. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10518. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10519. var checkboxInfo = new Grp_EnterExitCost()
  10520. {
  10521. Id = id,
  10522. //ProvinceId = provinceId,
  10523. DiId = diId,
  10524. CreateUserId = currUserId,
  10525. LastUpdateUserId = dto.CurrUserId,
  10526. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10527. };
  10528. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10529. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10530. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10531. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10532. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10533. if (id <= 0) //add
  10534. {
  10535. checkboxInfo.CreateUserId = dto.CurrUserId;
  10536. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10537. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10538. if (add < 1) return Ok(JsonView(false));
  10539. }
  10540. else //update
  10541. {
  10542. ////验证编辑权限
  10543. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10544. //if (!isEdit) return Ok(JsonView(false, msg));
  10545. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10546. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  10547. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  10548. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10549. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10550. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10551. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10552. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10553. .Where(x => x.Id == id)
  10554. .ExecuteCommandAsync();
  10555. if (upd < 1) return Ok(JsonView(false));
  10556. }
  10557. return Ok(JsonView(new { parentId = id }));
  10558. }
  10559. /// <summary>
  10560. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10561. /// </summary>
  10562. /// <returns></returns>
  10563. [HttpPost]
  10564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10565. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10566. {
  10567. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10568. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10569. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10570. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10571. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10572. info.FirstItemRemark = dto.FirstItemRemark;
  10573. info.LastUpdateUserId = dto.CurrUserId;
  10574. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10575. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10576. int id = dto.Id;
  10577. if (id <= 0) //add
  10578. {
  10579. info.CreateUserId = dto.CurrUserId;
  10580. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10581. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10582. if (add < 1) return Ok(JsonView(false));
  10583. id = add;
  10584. }
  10585. else //update
  10586. {
  10587. ////验证编辑权限
  10588. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10589. //if (!isEdit) return Ok(JsonView(false, msg));
  10590. var upd = await _sqlSugar.Updateable(info)
  10591. .UpdateColumns(x => new
  10592. {
  10593. x.ChoiceOne,
  10594. x.InsidePay,
  10595. x.VisaRemark,
  10596. x.Visa,
  10597. x.Service,
  10598. x.Safe,
  10599. x.Ticket,
  10600. x.HeSuan,
  10601. x.YiMiao,
  10602. x.FirstItemRemark,
  10603. x.LastUpdateUserId,
  10604. x.LastUpdateTime
  10605. })
  10606. .Where(x => x.Id == id)
  10607. .ExecuteCommandAsync();
  10608. if (upd < 1) return Ok(JsonView(false));
  10609. }
  10610. //消息通知
  10611. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10612. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10613. }
  10614. /// <summary>
  10615. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10616. /// </summary>
  10617. /// <returns></returns>
  10618. [HttpPost]
  10619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10620. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10621. {
  10622. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10623. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10624. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10625. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10626. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10627. info.DiId = dto.DiId;
  10628. //info.ProvinceId = dto.ProvinceId;
  10629. info.OutsideJJPay = dto.OutsideJJPay;
  10630. info.OutsideGWPay = dto.OutsideGWPay;
  10631. info.OutsideTDPay = dto.OutsideTDPay;
  10632. info.AirJJ = dto.AirJJ;
  10633. info.AirGW = dto.AirGW;
  10634. info.AirTD = dto.AirTD;
  10635. info.CityTranffic = dto.CityTranffic;
  10636. info.TwoItemRemark = dto.TwoItemRemark;
  10637. info.SumJJC = dto.ChoiceTwoJJ;
  10638. info.SumGWC = dto.ChoiceTwoGW;
  10639. info.SumTDC = dto.ChoiceTwoTD;
  10640. info.LastUpdateUserId = dto.CurrUserId;
  10641. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10642. int id = dto.Id;
  10643. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10644. if (id <= 0) //add i
  10645. {
  10646. info.CreateUserId = dto.CurrUserId;
  10647. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10648. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10649. if (addId <= 0) return Ok(JsonView(false));
  10650. id = addId;
  10651. }
  10652. else //update
  10653. {
  10654. ////验证编辑权限
  10655. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10656. //if (!isEdit) return Ok(JsonView(false, msg));
  10657. var upd = await _sqlSugar.Updateable(info)
  10658. .UpdateColumns(x => new
  10659. {
  10660. x.SumJJC,
  10661. x.OutsideJJPay,
  10662. x.SumGWC,
  10663. x.OutsideGWPay,
  10664. x.SumTDC,
  10665. x.OutsideTDPay,
  10666. x.AirJJ,
  10667. x.AirGW,
  10668. x.AirTD,
  10669. x.CityTranffic,
  10670. x.TwoItemRemark,
  10671. x.LastUpdateTime,
  10672. x.LastUpdateUserId
  10673. })
  10674. .Where(x => x.Id == id)
  10675. .ExecuteCommandAsync();
  10676. if (upd < 1) return Ok(JsonView(false));
  10677. }
  10678. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10679. gwcItemTotal = info.AirGW + info.CityTranffic;
  10680. tdcItemTotal = info.AirTD + info.CityTranffic;
  10681. //消息通知
  10682. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10683. return Ok(JsonView(new
  10684. {
  10685. parentId = id,
  10686. choiceTwoJJ = dto.ChoiceTwoJJ,
  10687. jjcItemTotal = jjcItemTotal,
  10688. choiceTwoGW = dto.ChoiceTwoGW,
  10689. gwcItemTotal = gwcItemTotal,
  10690. choiceTwoTD = dto.ChoiceTwoTD,
  10691. tdcItemTotal = tdcItemTotal
  10692. }));
  10693. }
  10694. /// <summary>
  10695. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10696. /// </summary>
  10697. /// <returns></returns>
  10698. [HttpPost]
  10699. [ApiExplorerSettings(IgnoreApi = true)]
  10700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10701. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10702. {
  10703. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10704. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10705. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10706. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10707. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10708. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10709. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10710. var infos = infos1.Select(x => new Grp_DayAndCost
  10711. {
  10712. Id = x.Id,
  10713. DiId = dto.DiId,
  10714. Type = dto.FeeType,
  10715. Days = x.Days,
  10716. NationalTravelFeeId = x.NationalTravelFeeId,
  10717. Cost = x.Cost,
  10718. Currency = x.Currency,
  10719. SubTotal = x.SubTotal,
  10720. CreateUserId = dto.CurrUserId
  10721. })
  10722. .ToList();
  10723. var adds = infos.Where(x => x.Id <= 0).ToList();
  10724. var upds = infos.Where(x => x.Id > 0).ToList();
  10725. if (adds.Count > 0)
  10726. {
  10727. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10728. if (add < 1) return Ok(JsonView(false));
  10729. }
  10730. if (upds.Count > 0)
  10731. {
  10732. var upd = await _sqlSugar.Updateable(adds)
  10733. .UpdateColumns(x => new
  10734. {
  10735. x.Days,
  10736. x.NationalTravelFeeId,
  10737. x.Cost,
  10738. x.Currency,
  10739. x.SubTotal
  10740. })
  10741. .WhereColumns(x => new { x.Id })
  10742. .ExecuteCommandAsync();
  10743. if (upd < 1) return Ok(JsonView(false));
  10744. }
  10745. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10746. //消息通知
  10747. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10748. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10749. return Ok(JsonView(new { itemTotal = itemTotal }));
  10750. }
  10751. /// <summary>
  10752. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10753. /// </summary>
  10754. /// <returns></returns>
  10755. [HttpPost]
  10756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10757. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10758. {
  10759. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10760. int subId = dto.SubId, feeType = dto.FeeType;
  10761. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10762. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10763. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10764. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10765. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10766. subInfo.Id = subId;
  10767. subInfo.DiId = dto.DiId;
  10768. if (feeType == 3) subInfo.Type = 1;
  10769. else if (feeType == 4) subInfo.Type = 2;
  10770. else if (feeType == 5) subInfo.Type = 3;
  10771. else if (feeType == 6) subInfo.Type = 4;
  10772. subInfo.CreateUserId = dto.CurrUserId;
  10773. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10774. if (parentId < 1) return Ok(JsonView(false));
  10775. //子表op
  10776. if (subId < 1)
  10777. {
  10778. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10779. if (subAdd < 1) return Ok(JsonView(false));
  10780. }
  10781. else
  10782. {
  10783. ////验证编辑权限
  10784. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10785. //if (!isEdit) return Ok(JsonView(false, msg));
  10786. var subUpd = await _sqlSugar.Updateable(subInfo)
  10787. .UpdateColumns(x => new
  10788. {
  10789. x.Days,
  10790. x.NationalTravelFeeId,
  10791. x.Cost,
  10792. x.Currency,
  10793. x.SubTotal
  10794. })
  10795. .WhereColumns(x => new { x.Id })
  10796. .ExecuteCommandAsync();
  10797. if (subUpd < 1) return Ok(JsonView(false));
  10798. }
  10799. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10800. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10801. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10802. }
  10803. /// <summary>
  10804. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10805. /// </summary>
  10806. /// <returns></returns>
  10807. [HttpPost]
  10808. [ApiExplorerSettings(IgnoreApi = true)]
  10809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10810. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10811. {
  10812. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10813. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10814. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10815. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10816. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10817. {
  10818. Id = x.Id,
  10819. Diid = dto.DiId,
  10820. SetDataId = x.SetDataId,
  10821. Index = x.Index,
  10822. Cost = x.Cost,
  10823. Currency = x.Currency,
  10824. SubTotal = x.SubTotal,
  10825. CreateUserId = dto.CurrUserId,
  10826. Remark = x.Remark
  10827. }).ToList();
  10828. var adds = infos.Where(x => x.Id <= 0).ToList();
  10829. var upds = infos.Where(x => x.Id > 0).ToList();
  10830. if (adds.Count > 0)
  10831. {
  10832. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10833. if (add < 1) return Ok(JsonView(false));
  10834. }
  10835. if (upds.Count > 0)
  10836. {
  10837. var upd = await _sqlSugar.Updateable(adds)
  10838. .UpdateColumns(x => new
  10839. {
  10840. x.Index,
  10841. x.SetDataId,
  10842. x.Cost,
  10843. x.Currency,
  10844. x.SubTotal,
  10845. x.Remark
  10846. })
  10847. .WhereColumns(x => new { x.Id })
  10848. .ExecuteCommandAsync();
  10849. if (upd < 1) return Ok(JsonView(false));
  10850. }
  10851. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10852. //消息通知
  10853. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10854. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10855. return Ok(JsonView(new { itemTotal = itemTotal }));
  10856. }
  10857. /// <summary>
  10858. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10859. /// </summary>
  10860. /// <returns></returns>
  10861. [HttpPost]
  10862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10863. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10864. {
  10865. int subId = dto.SubId;
  10866. int diId = dto.Diid;
  10867. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10868. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10869. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10870. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10871. subInfo.Id = subId;
  10872. subInfo.Diid = dto.Diid;
  10873. subInfo.CreateUserId = dto.CurrUserId;
  10874. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10875. if (parentId < 1) return Ok(JsonView(false));
  10876. #region 子表op
  10877. if (subId < 1)//add
  10878. {
  10879. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10880. if (subAdd < 1) return Ok(JsonView(false));
  10881. }
  10882. else //upd
  10883. {
  10884. ////验证编辑权限
  10885. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10886. //if (!isEdit) return Ok(JsonView(false, msg));
  10887. var subUpd = await _sqlSugar.Updateable(subInfo)
  10888. .UpdateColumns(x => new
  10889. {
  10890. x.Index,
  10891. x.SetDataId,
  10892. x.Cost,
  10893. x.Currency,
  10894. x.SubTotal,
  10895. x.Remark
  10896. })
  10897. .WhereColumns(x => new { x.Id })
  10898. .ExecuteCommandAsync();
  10899. if (subUpd < 1) return Ok(JsonView(false));
  10900. }
  10901. #endregion
  10902. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10903. //消息通知
  10904. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10905. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10906. }
  10907. /// <summary>
  10908. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10909. /// </summary>
  10910. /// <returns></returns>
  10911. [HttpPost]
  10912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10913. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10914. {
  10915. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10916. if (data.Code != 0)
  10917. {
  10918. return Ok(JsonView(false, data.Msg));
  10919. }
  10920. return Ok(JsonView(true, "操作成功!", data.Data));
  10921. }
  10922. /// <summary>
  10923. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10924. /// </summary>
  10925. /// <param name="dto"></param>
  10926. /// <returns></returns>
  10927. [HttpPost]
  10928. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10929. {
  10930. var data = new Grp_DayOtherPrice()
  10931. {
  10932. Id = dto.Id,
  10933. IsDel = 1,
  10934. DeleteUserId = dto.DeleteUserId,
  10935. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10936. };
  10937. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10938. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10939. return Ok(JsonView(false, "删除失败!"));
  10940. }
  10941. #endregion
  10942. #endregion
  10943. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10944. /// <summary>
  10945. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10946. /// </summary>
  10947. /// <returns></returns>
  10948. [HttpGet]
  10949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10950. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10951. {
  10952. var provData = await _groupRepository.ProvinceBasicSource();
  10953. return Ok(JsonView(true, "查询成功!", provData));
  10954. }
  10955. /// <summary>
  10956. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10957. /// </summary>
  10958. /// <returns></returns>
  10959. [HttpPost]
  10960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10961. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10962. {
  10963. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10964. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10965. RefAsync<int> total = 0;
  10966. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10967. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10968. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10969. .Select(x => new
  10970. {
  10971. Id = x.Id,
  10972. DraftName = x.DraftName,
  10973. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10974. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10975. .Any()
  10976. })
  10977. .OrderByDescending(x => x.Id)
  10978. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10979. return Ok(JsonView(true, "查询成功!", data, total));
  10980. }
  10981. /// <summary>
  10982. /// 出入境费用-草稿 移动端
  10983. /// 获取币种基础数据(含逻辑处理)
  10984. /// </summary>
  10985. /// <returns></returns>
  10986. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10987. {
  10988. return await GeneralMethod.EnterExitCostInitRate();
  10989. }
  10990. /// <summary>
  10991. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10992. /// </summary>
  10993. /// <returns></returns>
  10994. [HttpPost]
  10995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10996. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10997. {
  10998. //验证城市归属并给默认值
  10999. int provinceId = dto.ProvinceId;
  11000. if (provinceId < 1) provinceId = 122;
  11001. var dataSource = await _sqlSugar
  11002. .Queryable<Sys_SetData>()
  11003. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  11004. .ToListAsync();
  11005. //三公费用-Word明细类型
  11006. var wordTypeData = dataSource.Where(it => it.STid == 72)
  11007. .Select(x => new SetDataInfoView
  11008. {
  11009. Id = x.Id,
  11010. Name = x.Name,
  11011. Remark = x.Remark
  11012. })
  11013. .ToList();
  11014. //三公费用-Excel明细类型
  11015. var excelTypeData = dataSource.Where(it => it.STid == 73)
  11016. .Select(x => new SetDataInfoView
  11017. {
  11018. Id = x.Id,
  11019. Name = x.Name,
  11020. Remark = x.Remark
  11021. })
  11022. .ToList();
  11023. //默认币种显示
  11024. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  11025. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  11026. return Ok(JsonView(true, "查询成功!", new
  11027. {
  11028. WordTypeData = wordTypeData,
  11029. ExcelTypeData = excelTypeData,
  11030. CurrencyInit = _currencyInfos,
  11031. viewPermissionData = viewPermissionData
  11032. }));
  11033. }
  11034. /// <summary>
  11035. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  11036. /// </summary>
  11037. /// <returns></returns>
  11038. [HttpPost]
  11039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11040. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  11041. {
  11042. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11043. RefAsync<int> total = 0;
  11044. int diId = 0;
  11045. var status = int.TryParse(dto.GroupName, out diId);
  11046. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  11047. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  11048. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  11049. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  11050. .OrderByDescending(x => x.VisitStartDate)
  11051. .Select(x => new
  11052. {
  11053. Id = x.Id,
  11054. GroupName = x.TeamName
  11055. })
  11056. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11057. return Ok(JsonView(true, "查询成功!", data, total));
  11058. }
  11059. /// <summary>
  11060. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  11061. /// </summary>
  11062. /// <returns></returns>
  11063. [HttpPost]
  11064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11065. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  11066. {
  11067. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11068. RefAsync<int> total = 0;
  11069. var data = await _sqlSugar.Queryable<Sys_SetData>()
  11070. .Where(x => x.IsDel == 0 && x.STid == 66)
  11071. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  11072. .Select(x => new
  11073. {
  11074. id = x.Id,
  11075. name = x.Name,
  11076. remark = x.Remark,
  11077. })
  11078. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11079. return Ok(JsonView(true, "查询成功!", data, total));
  11080. }
  11081. /// <summary>
  11082. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  11083. /// </summary>
  11084. /// <returns></returns>
  11085. [HttpPost]
  11086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11087. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  11088. {
  11089. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11090. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11091. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  11092. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  11093. var groupOtherRateData = groupRateData.TeamRates;
  11094. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11095. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  11096. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  11097. groupOtherRateData = groupOtherRateData
  11098. .Select(x => new TeamRateDescAddCurrencyIdView
  11099. {
  11100. CurrencyId = x.CurrencyId,
  11101. CurrencyName = x.CurrencyName,
  11102. CurrencyCode = x.CurrencyCode,
  11103. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  11104. }).ToList();
  11105. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  11106. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  11107. }
  11108. /// <summary>
  11109. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  11110. /// </summary>
  11111. /// <returns></returns>
  11112. [HttpPost]
  11113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11114. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  11115. {
  11116. int portType = dto.PortType;
  11117. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11118. var tipsData = new List<int>() { 1, 2, 3 };
  11119. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  11120. if (dto.TipsType == 1)
  11121. {
  11122. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  11123. }
  11124. else if (dto.TipsType == 2)
  11125. {
  11126. if (portType == 2)
  11127. {
  11128. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11129. }
  11130. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11131. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11132. .Select(x => x.NationalTravelFeeId)
  11133. .Distinct()
  11134. .ToListAsync();
  11135. if (portType == 2)
  11136. {
  11137. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11138. }
  11139. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11140. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11141. .Select(x => x.Country)
  11142. .Distinct()
  11143. .ToArrayAsync();
  11144. if (portType == 2)
  11145. {
  11146. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11147. }
  11148. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11149. return Ok(JsonView(true, "查询成功!", new
  11150. {
  11151. totalAmt = totalAmt,
  11152. remark = remark
  11153. }));
  11154. }
  11155. else if (dto.TipsType == 3)
  11156. {
  11157. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  11158. }
  11159. return Ok(JsonView(false));
  11160. }
  11161. /// <summary>
  11162. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  11163. /// </summary>
  11164. /// <returns></returns>
  11165. [HttpPost]
  11166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11167. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  11168. {
  11169. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  11170. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11171. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11172. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  11173. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  11174. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  11175. var info = new Grp_EnterExitCostDraft()
  11176. {
  11177. ProvinceId = dto.ProvinceId,
  11178. DraftName = dto.DraftName,
  11179. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  11180. CreateUserId = dto.CurrUserId
  11181. };
  11182. _sqlSugar.BeginTran();
  11183. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11184. if (draftId < 1)
  11185. {
  11186. _sqlSugar.RollbackTran();
  11187. return Ok(JsonView(false, "草稿创建失败!"));
  11188. }
  11189. //添加默认权限
  11190. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  11191. _sqlSugar.CommitTran();
  11192. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  11193. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11194. mobileInfo.Id = draftId;
  11195. mobileInfo.DraftName = dto.DraftName;
  11196. mobileInfo.Currencys = rateInfos;
  11197. mobileInfo.IsAssignPerm = assignPerm;
  11198. return Ok(JsonView(mobileInfo));
  11199. }
  11200. /// <summary>
  11201. /// 出入境费用-草稿-移动端 查看编辑提示消息
  11202. /// </summary>
  11203. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  11204. /// <summary>
  11205. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  11206. /// </summary>
  11207. /// <returns></returns>
  11208. [HttpPost]
  11209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11210. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  11211. {
  11212. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11213. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11214. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11215. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11216. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  11217. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  11218. //验证查看编辑权限
  11219. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11220. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11221. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  11222. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  11223. mobileInfo.IsAssignPerm = assignPerm;
  11224. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11225. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11226. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11227. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11228. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11229. {
  11230. ParentId = dac.ParentId,
  11231. SubId = dac.Id,
  11232. Type = dac.Type,
  11233. Days = dac.Days,
  11234. NationalTravelFeeId = dac.NationalTravelFeeId,
  11235. Arae = $"{ntf.Country}-{ntf.City}",
  11236. Cost = dac.Cost,
  11237. Currency = dac.Currency,
  11238. CurrencyName = sd.Name,
  11239. SubTotal = dac.SubTotal,
  11240. })
  11241. .ToList();
  11242. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  11243. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  11244. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  11245. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  11246. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  11247. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  11248. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  11249. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  11250. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  11251. //其他款项
  11252. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11253. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11254. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11255. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11256. .OrderBy((dop, sd1, sd2) => dop.Index)
  11257. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11258. {
  11259. ParentId = dop.ParentId,
  11260. SubId = dop.Id,
  11261. Index = dop.Index,
  11262. SetDataId = dop.SetDataId,
  11263. SetDataName = sd1.Name,
  11264. Cost = dop.Cost,
  11265. Currency = dop.Currency,
  11266. CurrencyName = sd2.Remark,
  11267. SubTotal = dop.SubTotal,
  11268. Remark = dop.Remark,
  11269. })
  11270. .ToArray();
  11271. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  11272. return Ok(mobileInfo);
  11273. }
  11274. /// <summary>
  11275. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  11276. /// </summary>
  11277. /// <returns></returns>
  11278. [HttpPost]
  11279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11280. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  11281. {
  11282. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11283. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11284. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11285. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  11286. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  11287. //验证查看编辑权限
  11288. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11289. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11290. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11291. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  11292. var subType = dto.SubType;
  11293. if (subType == 1) //1:境内费用
  11294. {
  11295. var oneData = new ChoiceOneMobileSubInfoView()
  11296. {
  11297. Id = eecInfo.Id,
  11298. ChoiceOne = eecInfo.ChoiceOne,
  11299. ChoiceOneTotalCost = eecInfo.InsidePay,
  11300. Visa = eecInfo.Visa,
  11301. VisaRemark = eecInfo.VisaRemark,
  11302. YiMiao = eecInfo.YiMiao,
  11303. HeSuan = eecInfo.HeSuan,
  11304. Service = eecInfo.Service,
  11305. Ticket = eecInfo.Ticket,
  11306. Safe = eecInfo.Safe,
  11307. FirstItemRemark = eecInfo.FirstItemRemark
  11308. };
  11309. return Ok(JsonView(oneData));
  11310. }
  11311. else if (subType == 2) //2:国际旅费
  11312. {
  11313. var twoData = new ChoiceTwoMobileSubInfoView()
  11314. {
  11315. Id = eecInfo.Id,
  11316. ChoiceTwoJJ = eecInfo.SumJJC,
  11317. OutsideJJPay = eecInfo.OutsideJJPay,
  11318. ChoiceTwoGW = eecInfo.SumGWC,
  11319. OutsideGWPay = eecInfo.OutsideGWPay,
  11320. ChoiceTwoTD = eecInfo.SumTDC,
  11321. OutsideTDPay = eecInfo.OutsideTDPay,
  11322. AirJJ = eecInfo.AirJJ,
  11323. AirGW = eecInfo.AirGW,
  11324. AirTD = eecInfo.AirTD,
  11325. CityTranffic = eecInfo.CityTranffic,
  11326. TwoItemRemark = eecInfo.TwoItemRemark
  11327. };
  11328. return Ok(JsonView(twoData));
  11329. }
  11330. else if (subType == 3) //3:住宿费
  11331. {
  11332. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11333. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11334. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11335. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11336. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11337. {
  11338. ParentId = dac.ParentId,
  11339. SubId = dac.Id,
  11340. Type = dac.Type,
  11341. Days = dac.Days,
  11342. NationalTravelFeeId = dac.NationalTravelFeeId,
  11343. Arae = $"{ntf.Country}-{ntf.City}",
  11344. Cost = dac.Cost,
  11345. Currency = dac.Currency,
  11346. CurrencyName = sd.Name,
  11347. SubTotal = dac.SubTotal,
  11348. })
  11349. .ToArray();
  11350. var data = new ChoiceDraftMobileSubInfo3To6View()
  11351. {
  11352. ParentId = eecInfo.Id,
  11353. Choice = eecInfo.ChoiceThree,
  11354. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11355. Details = dayAndCostDatas
  11356. };
  11357. return Ok(JsonView(data));
  11358. }
  11359. else if (subType == 4) //4:伙食费
  11360. {
  11361. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11362. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11363. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11364. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  11365. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11366. {
  11367. ParentId = dac.ParentId,
  11368. SubId = dac.Id,
  11369. Type = dac.Type,
  11370. Days = dac.Days,
  11371. NationalTravelFeeId = dac.NationalTravelFeeId,
  11372. Arae = $"{ntf.Country}-{ntf.City}",
  11373. Cost = dac.Cost,
  11374. Currency = dac.Currency,
  11375. CurrencyName = sd.Name,
  11376. SubTotal = dac.SubTotal,
  11377. })
  11378. .ToArray();
  11379. var data = new ChoiceDraftMobileSubInfo3To6View()
  11380. {
  11381. ParentId = eecInfo.Id,
  11382. Choice = eecInfo.ChoiceFour,
  11383. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11384. Details = dayAndCostDatas
  11385. };
  11386. return Ok(JsonView(data));
  11387. }
  11388. else if (subType == 5) //5:公杂费
  11389. {
  11390. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11391. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11392. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11393. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  11394. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11395. {
  11396. ParentId = dac.ParentId,
  11397. SubId = dac.Id,
  11398. Type = dac.Type,
  11399. Days = dac.Days,
  11400. NationalTravelFeeId = dac.NationalTravelFeeId,
  11401. Arae = $"{ntf.Country}-{ntf.City}",
  11402. Cost = dac.Cost,
  11403. Currency = dac.Currency,
  11404. CurrencyName = sd.Name,
  11405. SubTotal = dac.SubTotal,
  11406. })
  11407. .ToArray();
  11408. var data = new ChoiceDraftMobileSubInfo3To6View()
  11409. {
  11410. ParentId = eecInfo.Id,
  11411. Choice = eecInfo.ChoiceFive,
  11412. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11413. Details = dayAndCostDatas
  11414. };
  11415. return Ok(JsonView(data));
  11416. }
  11417. else if (subType == 6) //6:培训费
  11418. {
  11419. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11420. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11421. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11422. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  11423. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11424. {
  11425. ParentId = dac.ParentId,
  11426. SubId = dac.Id,
  11427. Type = dac.Type,
  11428. Days = dac.Days,
  11429. NationalTravelFeeId = dac.NationalTravelFeeId,
  11430. Arae = $"{ntf.Country}-{ntf.City}",
  11431. Cost = dac.Cost,
  11432. Currency = dac.Currency,
  11433. CurrencyName = sd.Name,
  11434. SubTotal = dac.SubTotal,
  11435. })
  11436. .ToArray();
  11437. var data = new ChoiceDraftMobileSubInfo3To6View()
  11438. {
  11439. ParentId = eecInfo.Id,
  11440. Choice = eecInfo.ChoiceSix,
  11441. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11442. Details = dayAndCostDatas
  11443. };
  11444. return Ok(JsonView(data));
  11445. }
  11446. else if (subType == 7) //7:其他
  11447. {
  11448. //其他款项
  11449. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11450. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11451. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11452. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11453. .OrderBy((dop, sd1, sd2) => dop.Index)
  11454. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11455. {
  11456. ParentId = dop.ParentId,
  11457. SubId = dop.Id,
  11458. Index = dop.Index,
  11459. SetDataId = dop.SetDataId,
  11460. SetDataName = sd1.Name,
  11461. Cost = dop.Cost,
  11462. Currency = dop.Currency,
  11463. CurrencyName = sd2.Name,
  11464. SubTotal = dop.SubTotal,
  11465. Remark = dop.Remark,
  11466. })
  11467. .ToArray();
  11468. var data = new ChoiceSevenDraftMobileSubInfoView()
  11469. {
  11470. ParentId = eecInfo.Id,
  11471. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11472. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11473. Details = otherData
  11474. };
  11475. return Ok(JsonView(data));
  11476. }
  11477. return Ok(JsonView(false));
  11478. }
  11479. #region op
  11480. ///// <summary>
  11481. ///// 移动端更新费用消息通知
  11482. ///// </summary>
  11483. ///// <param name="draftId"></param>
  11484. ///// <param name="id"></param>
  11485. ///// <param name="currUserId"></param>
  11486. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11487. //{
  11488. // try
  11489. // {
  11490. // ////生成默认文件pdf并且通知人员
  11491. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11492. // //{
  11493. // // DiId = draftId,
  11494. // // ExportType = 1,
  11495. // // SubTypeId = 1005
  11496. // //}, "pdf");
  11497. // ////发送通知
  11498. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11499. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11500. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11501. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11502. // ////汇率信息记录
  11503. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11504. // }
  11505. // catch (Exception ex)
  11506. // {
  11507. // //记录日志
  11508. // throw;
  11509. // }
  11510. //}
  11511. /// <summary>
  11512. /// 验证出入境费用数据是否存在
  11513. /// 不存在添加
  11514. /// </summary>
  11515. /// <param name="draftId"></param>
  11516. /// <param name="currUserId"></param>
  11517. /// <returns></returns>
  11518. /// <exception cref="CustomException"></exception>
  11519. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11520. {
  11521. var parentId = 0;
  11522. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11523. if (info != null) parentId = info.Id;
  11524. else
  11525. {
  11526. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11527. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11528. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11529. parentId = addId;
  11530. }
  11531. return parentId;
  11532. }
  11533. /// <summary>
  11534. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11535. /// </summary>
  11536. /// <returns></returns>
  11537. [HttpPost]
  11538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11539. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11540. {
  11541. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11542. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11543. //验证查看权限
  11544. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11545. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11546. var userIds = await _sqlSugar
  11547. .Queryable<Grp_EnterExitCostDraftPermission>()
  11548. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11549. .Select(x => x.UserId)
  11550. .ToArrayAsync();
  11551. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11552. var perUsersView = new List<dynamic>();
  11553. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11554. var viewPermissionData = new List<PermissionViewUserview>();
  11555. if (feeBasePerm.Any())
  11556. {
  11557. foreach (var item in feeBasePerm)
  11558. {
  11559. if (item.Users.Any())
  11560. {
  11561. viewPermissionData.AddRange(item.Users);
  11562. }
  11563. }
  11564. }
  11565. foreach (var item in perUsers)
  11566. {
  11567. bool isView1 = false;
  11568. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11569. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11570. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11571. }
  11572. return Ok(JsonView(perUsersView));
  11573. }
  11574. /// <summary>
  11575. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11576. /// </summary>
  11577. /// <returns></returns>
  11578. [HttpPost]
  11579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11580. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11581. {
  11582. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11583. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11584. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11585. //验证查看编辑权限
  11586. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11587. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11588. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11589. foreach (var userId in dto.UserIds)
  11590. {
  11591. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11592. }
  11593. if (permissions.Any())
  11594. {
  11595. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11596. {
  11597. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11598. }
  11599. _sqlSugar.BeginTran();
  11600. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11601. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11602. if (result < 1)
  11603. {
  11604. _sqlSugar.RollbackTran();
  11605. return Ok(JsonView(false));
  11606. }
  11607. _sqlSugar.CommitTran();
  11608. return Ok(JsonView(true));
  11609. }
  11610. return Ok(JsonView(false));
  11611. }
  11612. /// <summary>
  11613. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11614. /// </summary>
  11615. /// <returns></returns>
  11616. [HttpPost]
  11617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11618. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11619. {
  11620. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11621. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11622. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11623. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11624. int id = dto.DraftId;
  11625. if (id <= 0) //add
  11626. {
  11627. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11628. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11629. if (add < 1) return Ok(JsonView(false));
  11630. id = add;
  11631. }
  11632. else //update
  11633. {
  11634. //验证查看编辑权限
  11635. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11636. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11637. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11638. if (upd < 1) return Ok(JsonView(false));
  11639. }
  11640. return Ok(JsonView(new { parentId = id }));
  11641. }
  11642. /// <summary>
  11643. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11644. /// </summary>
  11645. /// <returns></returns>
  11646. [HttpPost]
  11647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11648. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11649. {
  11650. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11651. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11652. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11653. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11654. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11655. int id = dto.DraftId;
  11656. if (id <= 0) //add
  11657. {
  11658. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11659. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11660. if (add < 1) return Ok(JsonView(false));
  11661. id = add;
  11662. }
  11663. else //update
  11664. {
  11665. //验证查看编辑权限
  11666. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11667. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11668. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11669. if (upd < 1) return Ok(JsonView(false));
  11670. }
  11671. #region 汇率变更时更改币种相关费用
  11672. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11673. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11674. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11675. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11676. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11677. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11678. .Select((dac, sd) => new
  11679. {
  11680. dac.Id,
  11681. dac.ParentId,
  11682. CurrencyCode = sd.Name,
  11683. dac.Cost
  11684. })
  11685. .ToList();
  11686. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11687. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11688. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11689. .Select((dop, sd) => new
  11690. {
  11691. dop.Id,
  11692. dop.ParentId,
  11693. CurrencyCode = sd.Name,
  11694. dop.Cost
  11695. })
  11696. .ToList();
  11697. if (dayCosts.Count > 0)
  11698. {
  11699. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11700. foreach (var dc in new_dayCosts)
  11701. {
  11702. var thisCurrency = dc.Key.ToUpper();
  11703. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11704. if (thisRate == 0.00M) continue;
  11705. foreach (var dcSub in dc)
  11706. {
  11707. opDayCosts.Add(new Grp_DayAndCostDraft()
  11708. {
  11709. Id = dcSub.Id,
  11710. ParentId = dcSub.ParentId,
  11711. Cost = dcSub.Cost,
  11712. SubTotal = dcSub.Cost * thisRate,
  11713. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11714. });
  11715. }
  11716. }
  11717. if (opDayCosts.Count > 0)
  11718. {
  11719. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11720. }
  11721. }
  11722. if (dayOtherCosts.Count > 0)
  11723. {
  11724. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11725. foreach (var dc in new_dayOtherCosts)
  11726. {
  11727. var thisCurrency = dc.Key.ToUpper();
  11728. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11729. if (thisRate == 0.00M) continue;
  11730. foreach (var dcSub in dc)
  11731. {
  11732. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11733. {
  11734. Id = dcSub.Id,
  11735. ParentId = dcSub.ParentId,
  11736. Cost = dcSub.Cost,
  11737. SubTotal = dcSub.Cost * thisRate,
  11738. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11739. });
  11740. }
  11741. }
  11742. if (opDayOtherCosts.Count > 0)
  11743. {
  11744. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11745. }
  11746. }
  11747. #endregion
  11748. ////消息通知
  11749. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11750. ////汇率信息记录
  11751. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11752. return Ok(JsonView(new { parentId = id }));
  11753. }
  11754. /// <summary>
  11755. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11756. /// </summary>
  11757. /// <returns></returns>
  11758. [HttpPost]
  11759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11760. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11761. {
  11762. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11763. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11764. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11765. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11766. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11767. int id = dto.DraftId;
  11768. if (id <= 0) //add
  11769. {
  11770. checkboxInfo.ProvinceId = dto.ProvinceId;
  11771. checkboxInfo.CreateUserId = dto.CurrUserId;
  11772. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11773. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11774. if (add < 1) return Ok(JsonView(false));
  11775. }
  11776. else //update
  11777. {
  11778. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11779. .UpdateColumns(x => new
  11780. {
  11781. x.ChoiceOne,
  11782. x.ChoiceTwo,
  11783. x.SumJJC,
  11784. x.SumGWC,
  11785. x.SumTDC,
  11786. x.ChoiceThree,
  11787. x.ChoiceFour,
  11788. x.ChoiceFive,
  11789. x.ChoiceSix,
  11790. x.OtherExpenses_Checked
  11791. })
  11792. .Where(x => x.Id == id)
  11793. .ExecuteCommandAsync();
  11794. if (upd < 1) return Ok(JsonView(false));
  11795. }
  11796. return Ok(JsonView(new { parentId = id }));
  11797. }
  11798. /// <summary>
  11799. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11800. /// </summary>
  11801. /// <returns></returns>
  11802. [HttpPost]
  11803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11804. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11805. {
  11806. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11807. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11808. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11809. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11810. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11811. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11812. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11813. var checkboxInfo = new Grp_EnterExitCostDraft()
  11814. {
  11815. Id = draftId,
  11816. ProvinceId = dto.ProvinceId,
  11817. CreateUserId = currUserId
  11818. };
  11819. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11820. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11821. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11822. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11823. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11824. if (draftId <= 0) //add
  11825. {
  11826. checkboxInfo.CreateUserId = dto.CurrUserId;
  11827. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11828. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11829. if (add < 1) return Ok(JsonView(false));
  11830. }
  11831. else //update
  11832. {
  11833. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11834. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11835. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11836. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11837. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11838. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11839. .Where(x => x.Id == draftId)
  11840. .ExecuteCommandAsync();
  11841. if (upd < 1) return Ok(JsonView(false));
  11842. }
  11843. return Ok(JsonView(new { parentId = draftId }));
  11844. }
  11845. /// <summary>
  11846. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11847. /// </summary>
  11848. /// <returns></returns>
  11849. [HttpPost]
  11850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11851. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11852. {
  11853. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11854. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11855. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11856. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11857. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11858. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11859. info.ProvinceId = dto.ProvinceId;
  11860. info.FirstItemRemark = dto.FirstItemRemark;
  11861. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11862. if (id <= 0) //add
  11863. {
  11864. info.CreateUserId = dto.CurrUserId;
  11865. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11866. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11867. if (add < 1) return Ok(JsonView(false));
  11868. id = add;
  11869. }
  11870. else //update
  11871. {
  11872. var upd = await _sqlSugar.Updateable(info)
  11873. .UpdateColumns(x => new
  11874. {
  11875. x.ChoiceOne,
  11876. x.InsidePay,
  11877. x.VisaRemark,
  11878. x.Visa,
  11879. x.Service,
  11880. x.Safe,
  11881. x.Ticket,
  11882. x.HeSuan,
  11883. x.YiMiao,
  11884. x.FirstItemRemark
  11885. })
  11886. .Where(x => x.Id == id)
  11887. .ExecuteCommandAsync();
  11888. if (upd < 1) return Ok(JsonView(false));
  11889. }
  11890. ////消息通知
  11891. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11892. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11893. }
  11894. /// <summary>
  11895. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11896. /// </summary>
  11897. /// <returns></returns>
  11898. [HttpPost]
  11899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11900. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11901. {
  11902. int id = dto.DraftId;
  11903. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11904. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11905. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11906. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11907. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11908. info.ProvinceId = dto.ProvinceId;
  11909. info.OutsideJJPay = dto.OutsideJJPay;
  11910. info.OutsideGWPay = dto.OutsideGWPay;
  11911. info.OutsideTDPay = dto.OutsideTDPay;
  11912. info.AirJJ = dto.AirJJ;
  11913. info.AirGW = dto.AirGW;
  11914. info.AirTD = dto.AirTD;
  11915. info.CityTranffic = dto.CityTranffic;
  11916. info.TwoItemRemark = dto.TwoItemRemark;
  11917. info.SumJJC = dto.ChoiceTwoJJ;
  11918. info.SumGWC = dto.ChoiceTwoGW;
  11919. info.SumTDC = dto.ChoiceTwoTD;
  11920. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11921. if (id <= 0) //add
  11922. {
  11923. info.CreateUserId = dto.CurrUserId;
  11924. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11925. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11926. if (addId <= 0) return Ok(JsonView(false));
  11927. id = addId;
  11928. }
  11929. else //update
  11930. {
  11931. var upd = await _sqlSugar.Updateable(info)
  11932. .UpdateColumns(x => new
  11933. {
  11934. x.SumJJC,
  11935. x.OutsideJJPay,
  11936. x.SumGWC,
  11937. x.OutsideGWPay,
  11938. x.SumTDC,
  11939. x.OutsideTDPay,
  11940. x.AirJJ,
  11941. x.AirGW,
  11942. x.AirTD,
  11943. x.CityTranffic,
  11944. x.TwoItemRemark
  11945. })
  11946. .Where(x => x.Id == id)
  11947. .ExecuteCommandAsync();
  11948. if (upd < 1) return Ok(JsonView(false));
  11949. }
  11950. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11951. gwcItemTotal = info.AirGW + info.CityTranffic;
  11952. tdcItemTotal = info.AirTD + info.CityTranffic;
  11953. ////消息通知
  11954. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11955. return Ok(JsonView(new
  11956. {
  11957. parentId = id,
  11958. choiceTwoJJ = dto.ChoiceTwoJJ,
  11959. jjcItemTotal = jjcItemTotal,
  11960. choiceTwoGW = dto.ChoiceTwoGW,
  11961. gwcItemTotal = gwcItemTotal,
  11962. choiceTwoTD = dto.ChoiceTwoTD,
  11963. tdcItemTotal = tdcItemTotal
  11964. }));
  11965. }
  11966. /// <summary>
  11967. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11968. /// </summary>
  11969. /// <returns></returns>
  11970. [HttpPost]
  11971. [ApiExplorerSettings(IgnoreApi = true)]
  11972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11973. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11974. {
  11975. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11976. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11977. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11978. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11979. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11980. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11981. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11982. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11983. {
  11984. Id = x.Id,
  11985. ParentId = dto.DraftId,
  11986. Type = dto.FeeType,
  11987. Days = x.Days,
  11988. NationalTravelFeeId = x.NationalTravelFeeId,
  11989. Cost = x.Cost,
  11990. Currency = x.Currency,
  11991. SubTotal = x.SubTotal,
  11992. CreateUserId = dto.CurrUserId
  11993. })
  11994. .ToList();
  11995. var adds = infos.Where(x => x.Id <= 0).ToList();
  11996. var upds = infos.Where(x => x.Id > 0).ToList();
  11997. if (adds.Count > 0)
  11998. {
  11999. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12000. if (add < 1) return Ok(JsonView(false));
  12001. }
  12002. if (upds.Count > 0)
  12003. {
  12004. var upd = await _sqlSugar.Updateable(adds)
  12005. .UpdateColumns(x => new
  12006. {
  12007. x.Days,
  12008. x.NationalTravelFeeId,
  12009. x.Cost,
  12010. x.Currency,
  12011. x.SubTotal
  12012. })
  12013. .WhereColumns(x => new { x.Id })
  12014. .ExecuteCommandAsync();
  12015. if (upd < 1) return Ok(JsonView(false));
  12016. }
  12017. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  12018. ////消息通知
  12019. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  12020. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12021. return Ok(JsonView(new { itemTotal = itemTotal }));
  12022. }
  12023. /// <summary>
  12024. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  12025. /// </summary>
  12026. /// <returns></returns>
  12027. [HttpPost]
  12028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12029. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  12030. {
  12031. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  12032. int subId = dto.SubId, feeType = dto.FeeType;
  12033. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12034. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12035. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12036. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12037. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  12038. subInfo.Id = subId;
  12039. subInfo.ParentId = dto.DraftId;
  12040. if (feeType == 3) subInfo.Type = 1;
  12041. else if (feeType == 4) subInfo.Type = 2;
  12042. else if (feeType == 5) subInfo.Type = 3;
  12043. else if (feeType == 6) subInfo.Type = 4;
  12044. subInfo.CreateUserId = dto.CurrUserId;
  12045. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  12046. if (parentId < 1) return Ok(JsonView(false));
  12047. //子表op
  12048. if (subId < 1)
  12049. {
  12050. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12051. if (subAdd < 1) return Ok(JsonView(false));
  12052. }
  12053. else
  12054. {
  12055. var subUpd = await _sqlSugar.Updateable(subInfo)
  12056. .UpdateColumns(x => new
  12057. {
  12058. x.Days,
  12059. x.NationalTravelFeeId,
  12060. x.Cost,
  12061. x.Currency,
  12062. x.SubTotal
  12063. })
  12064. .WhereColumns(x => new { x.Id })
  12065. .ExecuteCommandAsync();
  12066. if (subUpd < 1) return Ok(JsonView(false));
  12067. }
  12068. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  12069. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12070. }
  12071. /// <summary>
  12072. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  12073. /// </summary>
  12074. /// <returns></returns>
  12075. [HttpPost]
  12076. [ApiExplorerSettings(IgnoreApi = true)]
  12077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12078. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  12079. {
  12080. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12081. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12082. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12083. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  12084. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  12085. {
  12086. Id = x.Id,
  12087. ParentId = dto.DraftId,
  12088. SetDataId = x.SetDataId,
  12089. Index = x.Index,
  12090. Cost = x.Cost,
  12091. Currency = x.Currency,
  12092. SubTotal = x.SubTotal,
  12093. CreateUserId = dto.CurrUserId,
  12094. Remark = x.Remark
  12095. }).ToList();
  12096. var adds = infos.Where(x => x.Id <= 0).ToList();
  12097. var upds = infos.Where(x => x.Id > 0).ToList();
  12098. if (adds.Count > 0)
  12099. {
  12100. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12101. if (add < 1) return Ok(JsonView(false));
  12102. }
  12103. if (upds.Count > 0)
  12104. {
  12105. var upd = await _sqlSugar.Updateable(adds)
  12106. .UpdateColumns(x => new
  12107. {
  12108. x.Index,
  12109. x.SetDataId,
  12110. x.Cost,
  12111. x.Currency,
  12112. x.SubTotal,
  12113. x.Remark
  12114. })
  12115. .WhereColumns(x => new { x.Id })
  12116. .ExecuteCommandAsync();
  12117. if (upd < 1) return Ok(JsonView(false));
  12118. }
  12119. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  12120. //消息通知
  12121. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  12122. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12123. return Ok(JsonView(new { itemTotal = itemTotal }));
  12124. }
  12125. /// <summary>
  12126. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  12127. /// </summary>
  12128. /// <returns></returns>
  12129. [HttpPost]
  12130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12131. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  12132. {
  12133. int subId = dto.SubId, id = dto.DraftId;
  12134. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12135. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  12136. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12137. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  12138. subInfo.Id = subId;
  12139. subInfo.ParentId = id;
  12140. subInfo.CreateUserId = dto.CurrUserId;
  12141. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  12142. if (parentId < 1) return Ok(JsonView(false));
  12143. #region 子表op
  12144. if (subId < 1)//add
  12145. {
  12146. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12147. if (subAdd < 1) return Ok(JsonView(false));
  12148. }
  12149. else //upd
  12150. {
  12151. var subUpd = await _sqlSugar.Updateable(subInfo)
  12152. .UpdateColumns(x => new
  12153. {
  12154. x.Index,
  12155. x.SetDataId,
  12156. x.Cost,
  12157. x.Currency,
  12158. x.SubTotal,
  12159. x.Remark
  12160. })
  12161. .WhereColumns(x => new { x.Id })
  12162. .ExecuteCommandAsync();
  12163. if (subUpd < 1) return Ok(JsonView(false));
  12164. }
  12165. #endregion
  12166. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  12167. ////消息通知
  12168. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  12169. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12170. }
  12171. /// <summary>
  12172. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  12173. /// </summary>
  12174. /// <returns></returns>
  12175. [HttpPost]
  12176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12177. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12178. {
  12179. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  12180. if (data.Code != 0)
  12181. {
  12182. return Ok(JsonView(false, data.Msg));
  12183. }
  12184. return Ok(JsonView(true, "操作成功!", data.Data));
  12185. }
  12186. /// <summary>
  12187. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  12188. /// </summary>
  12189. /// <param name="dto"></param>
  12190. /// <returns></returns>
  12191. [HttpPost]
  12192. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  12193. {
  12194. var data = new Grp_DayOtherPriceDraft()
  12195. {
  12196. Id = dto.Id,
  12197. IsDel = 1,
  12198. DeleteUserId = dto.DeleteUserId,
  12199. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12200. };
  12201. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12202. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  12203. return Ok(JsonView(false, "删除失败!"));
  12204. }
  12205. #endregion
  12206. #endregion
  12207. #region 团组经理模块 出入境费用报价表
  12208. /// <summary>
  12209. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  12210. /// </summary>
  12211. /// <returns></returns>
  12212. [HttpPost]
  12213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12214. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  12215. {
  12216. var initRates = await GeneralMethod.EnterExitCostInitRate();
  12217. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  12218. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  12219. initRates.Insert(0, cnyInfo);
  12220. liveRates.Insert(0, cnyInfo);
  12221. return Ok(JsonView(true, "查询成功!", new
  12222. {
  12223. InitRates = initRates,
  12224. LiveRates = liveRates
  12225. }));
  12226. }
  12227. /// <summary>
  12228. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  12229. /// </summary>
  12230. /// <returns></returns>
  12231. [HttpPost]
  12232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12233. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  12234. {
  12235. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  12236. }
  12237. /// <summary>
  12238. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  12239. /// </summary>
  12240. /// <returns></returns>
  12241. [HttpPost]
  12242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12243. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  12244. {
  12245. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  12246. }
  12247. /// <summary>
  12248. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  12249. /// </summary>
  12250. /// <returns></returns>
  12251. [HttpPost]
  12252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12253. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  12254. {
  12255. int groupId = dto.DiId,
  12256. currUserId = dto.CurrUserId;
  12257. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  12258. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  12259. //验证报价数据是否存在
  12260. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  12261. if (isNull != null)
  12262. {
  12263. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  12264. if (!info1.Rates.Any())
  12265. {
  12266. var rates = await GeneralMethod.EnterExitCostInitRate();
  12267. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12268. info1.Rates = rates.ToArray();
  12269. }
  12270. return Ok(JsonView(info1));
  12271. }
  12272. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  12273. result.GroupId = groupId;
  12274. //处理报价名称
  12275. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  12276. if (groupInfo != null)
  12277. {
  12278. var visitCountry = groupInfo.VisitCountry;
  12279. if (!string.IsNullOrEmpty(visitCountry))
  12280. {
  12281. string quoteName = string.Empty;
  12282. if (visitCountry.Contains("|"))
  12283. {
  12284. var countrys = visitCountry.Split("|");
  12285. quoteName = string.Join("、", countrys);
  12286. }
  12287. else quoteName = visitCountry;
  12288. quoteName += $"团组报价表";
  12289. result.Name = quoteName;
  12290. }
  12291. }
  12292. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12293. if (info.Code != StatusCodes.Status200OK)
  12294. {
  12295. if (!result.Rates.Any())
  12296. {
  12297. var rates = await GeneralMethod.EnterExitCostInitRate();
  12298. result.Rates = rates.ToArray();
  12299. }
  12300. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  12301. }
  12302. var infoView = info.Data as EnterExitCostInfoView;
  12303. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  12304. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  12305. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  12306. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  12307. var eecRates = infoView.Currencys;
  12308. //默认添加人名币
  12309. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  12310. {
  12311. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12312. }
  12313. //处理团组人数
  12314. int pplNum = 1;
  12315. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  12316. var views = new List<QuoteSubItemInfo>();
  12317. #region 数据填充
  12318. var intTravelCosts = new List<QuoteSubItemInfo>();
  12319. #region 机票费用 1354
  12320. int intTravelIndex = 1;
  12321. if (infoView.SumJJC == 1)
  12322. {
  12323. intTravelCosts.Add(new QuoteSubItemInfo
  12324. {
  12325. ItemId = 1354,
  12326. Index = intTravelIndex,
  12327. FeeName = "经济舱",
  12328. UnitPrice = infoView.AirJJ,
  12329. Currency = "CNY",
  12330. Quantity = 1,
  12331. PplNum = 1,
  12332. TotalAmt = infoView.AirJJ,
  12333. Remark = "",
  12334. });
  12335. intTravelIndex++;
  12336. }
  12337. if (infoView.SumGWC == 1)
  12338. {
  12339. intTravelCosts.Add(new QuoteSubItemInfo
  12340. {
  12341. ItemId = 1354,
  12342. Index = intTravelIndex,
  12343. FeeName = "公务舱",
  12344. UnitPrice = infoView.AirGW,
  12345. Currency = "CNY",
  12346. Quantity = 1,
  12347. PplNum = 1,
  12348. TotalAmt = infoView.AirGW,
  12349. Remark = "",
  12350. });
  12351. intTravelIndex++;
  12352. }
  12353. if (infoView.SumTDC == 1)
  12354. {
  12355. intTravelCosts.Add(new QuoteSubItemInfo
  12356. {
  12357. ItemId = 1354,
  12358. Index = intTravelIndex,
  12359. FeeName = "头等舱",
  12360. UnitPrice = infoView.AirTD,
  12361. Currency = "CNY",
  12362. Quantity = 1,
  12363. PplNum = 1,
  12364. TotalAmt = infoView.AirTD,
  12365. Remark = "",
  12366. });
  12367. intTravelIndex++;
  12368. }
  12369. intTravelCosts.Add(new QuoteSubItemInfo
  12370. {
  12371. ItemId = 1354,
  12372. Index = intTravelIndex,
  12373. FeeName = "城市间交通费用",
  12374. UnitPrice = infoView.CityTranffic,
  12375. Currency = "CNY",
  12376. Quantity = 1,
  12377. PplNum = pplNum,
  12378. TotalAmt = infoView.CityTranffic * pplNum,
  12379. Remark = "",
  12380. });
  12381. views.AddRange(intTravelCosts);
  12382. #endregion
  12383. var accomCosts = new List<QuoteSubItemInfo>();
  12384. #region 住宿费 1355
  12385. if (infoView.QuarterageData.Any())
  12386. {
  12387. int accomIndex = 1;
  12388. int accomItemTypeId = 1355;
  12389. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  12390. foreach (var item in groupData)
  12391. {
  12392. string feeName = string.Empty;
  12393. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12394. if (countryInfo != null)
  12395. {
  12396. feeName = countryInfo.Country;
  12397. var city = countryInfo.City;
  12398. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12399. {
  12400. feeName += $"-{city}";
  12401. }
  12402. }
  12403. var hotelInfo = item.FirstOrDefault();
  12404. if (hotelInfo == null) continue;
  12405. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  12406. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12407. int quantity = item.ToList().Count;
  12408. accomCosts.Add(new QuoteSubItemInfo
  12409. {
  12410. ItemId = accomItemTypeId,
  12411. Index = accomIndex,
  12412. FeeName = feeName,
  12413. UnitPrice = hotelInfo.Cost,
  12414. Currency = thisCurrency,
  12415. Quantity = quantity,
  12416. PplNum = pplNum,
  12417. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  12418. Remark = "",
  12419. });
  12420. accomIndex++;
  12421. }
  12422. views.AddRange(accomCosts);
  12423. }
  12424. #endregion
  12425. var mealCosts = new List<QuoteSubItemInfo>();
  12426. #region 餐饮费 1356
  12427. if (infoView.BoardWagesData.Any())
  12428. {
  12429. var mealIndex = 1;
  12430. int mealItemTypeId = 1356;
  12431. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12432. foreach (var item in groupData)
  12433. {
  12434. string feeName = string.Empty;
  12435. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12436. if (countryInfo != null)
  12437. {
  12438. feeName = countryInfo.Country;
  12439. var city = countryInfo.City;
  12440. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12441. {
  12442. feeName += $"-{city}";
  12443. }
  12444. }
  12445. var mealInfo = item.FirstOrDefault();
  12446. if (mealInfo == null) continue;
  12447. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12448. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12449. int quantity = item.ToList().Count;
  12450. mealCosts.Add(new QuoteSubItemInfo
  12451. {
  12452. ItemId = mealItemTypeId,
  12453. Index = mealIndex,
  12454. FeeName = feeName,
  12455. UnitPrice = mealInfo.Cost,
  12456. Currency = thisCurrency,
  12457. Quantity = quantity,
  12458. PplNum = pplNum,
  12459. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12460. Remark = "",
  12461. });
  12462. mealIndex++;
  12463. }
  12464. views.AddRange(mealCosts);
  12465. }
  12466. #endregion
  12467. var miscCosts = new List<QuoteSubItemInfo>();
  12468. #region 公杂费 1364
  12469. if (infoView.MiscellaneousFeeData.Any())
  12470. {
  12471. var miscIndex = 1;
  12472. int miscItemTypeId = 1364;
  12473. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12474. foreach (var item in groupData)
  12475. {
  12476. string feeName = string.Empty;
  12477. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12478. if (countryInfo != null)
  12479. {
  12480. feeName = countryInfo.Country;
  12481. var city = countryInfo.City;
  12482. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12483. {
  12484. feeName += $"-{city}";
  12485. }
  12486. }
  12487. var miscInfo = item.FirstOrDefault();
  12488. if (miscInfo == null) continue;
  12489. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12490. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12491. int quantity = item.ToList().Count;
  12492. miscCosts.Add(new QuoteSubItemInfo
  12493. {
  12494. ItemId = miscItemTypeId,
  12495. Index = miscIndex,
  12496. FeeName = feeName,
  12497. UnitPrice = miscInfo.Cost,
  12498. Currency = thisCurrency,
  12499. Quantity = quantity,
  12500. PplNum = pplNum,
  12501. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12502. Remark = "",
  12503. });
  12504. miscIndex++;
  12505. }
  12506. views.AddRange(miscCosts);
  12507. }
  12508. #endregion
  12509. #region 签证+保险 1362
  12510. int visaInsIndex = 1;
  12511. int visaInsItemTypeId = 1362;
  12512. if (infoView.Visa > 0)
  12513. {
  12514. views.Add(new QuoteSubItemInfo()
  12515. {
  12516. ItemId = visaInsItemTypeId,
  12517. Index = visaInsIndex,
  12518. FeeName = $"签证",
  12519. UnitPrice = infoView.Visa,
  12520. Currency = $"CNY",
  12521. Quantity = 1,
  12522. PplNum = pplNum,
  12523. TotalAmt = infoView.Visa * pplNum,
  12524. Remark = "",
  12525. });
  12526. visaInsIndex++;
  12527. }
  12528. if (infoView.Safe > 0)
  12529. {
  12530. views.Add(new QuoteSubItemInfo()
  12531. {
  12532. ItemId = visaInsItemTypeId,
  12533. Index = visaInsIndex,
  12534. FeeName = $"保险",
  12535. UnitPrice = infoView.Safe,
  12536. Currency = $"CNY",
  12537. Quantity = 1,
  12538. PplNum = pplNum,
  12539. TotalAmt = infoView.Safe * pplNum,
  12540. Remark = "",
  12541. });
  12542. }
  12543. #endregion
  12544. #region 服务费 1363
  12545. int serviceFeeIndex = 1;
  12546. int serviceFeeItemTypeId = 1363;
  12547. if (infoView.Service > 0)
  12548. {
  12549. views.Add(new QuoteSubItemInfo()
  12550. {
  12551. ItemId = serviceFeeItemTypeId,
  12552. Index = serviceFeeIndex,
  12553. FeeName = $"服务费",
  12554. UnitPrice = infoView.Service,
  12555. Currency = $"CNY",
  12556. Quantity = 1,
  12557. PplNum = pplNum,
  12558. TotalAmt = infoView.Service * pplNum,
  12559. Remark = "",
  12560. });
  12561. }
  12562. #endregion
  12563. #endregion
  12564. if (result.FeeItems.Any())
  12565. {
  12566. result.FeeItems.Select(x =>
  12567. {
  12568. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12569. if (feeInfos.Any()) x.Infos = feeInfos;
  12570. return x;
  12571. }
  12572. ).OrderBy(x => x.Index)
  12573. .ToList();
  12574. if (!result.Rates.Any())
  12575. {
  12576. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12577. else
  12578. {
  12579. var rates = await GeneralMethod.EnterExitCostInitRate();
  12580. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12581. result.Rates = rates.ToArray();
  12582. }
  12583. }
  12584. }
  12585. return Ok(JsonView(result));
  12586. }
  12587. /// <summary>
  12588. /// 团组模块 - 出入境费用报价表 - Info
  12589. /// </summary>
  12590. /// <returns></returns>
  12591. [HttpPost]
  12592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12593. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12594. {
  12595. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12596. if (!info.Rates.Any())
  12597. {
  12598. var rates = await GeneralMethod.EnterExitCostInitRate();
  12599. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12600. info.Rates = rates.ToArray();
  12601. }
  12602. return Ok(JsonView(info));
  12603. }
  12604. /// <summary>
  12605. /// 团组模块 - 出入境费用报价表 - OP
  12606. /// </summary>
  12607. /// <returns></returns>
  12608. [HttpPost]
  12609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12610. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12611. {
  12612. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12613. }
  12614. /// <summary>
  12615. /// 团组模块 - 出入境费用报价表 - 删除 项
  12616. /// </summary>
  12617. /// <returns></returns>
  12618. [HttpPost]
  12619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12620. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12621. {
  12622. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12623. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12624. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12625. }
  12626. /// <summary>
  12627. /// 团组模块 - 出入境费用报价表 - 导出
  12628. /// </summary>
  12629. /// <returns></returns>
  12630. [HttpPost]
  12631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12632. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12633. {
  12634. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12635. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12636. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12637. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12638. var rates = info.Rates;
  12639. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12640. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12641. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12642. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12643. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12644. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12645. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12646. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12647. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12648. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12649. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12650. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12651. //获取模板
  12652. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12653. var designer = new WorkbookDesigner();
  12654. designer.Workbook = new Workbook(tempPath);
  12655. designer.SetDataSource("QuoteName", info.Name);
  12656. designer.SetDataSource("CompanyTitle", "公司名称");
  12657. designer.SetDataSource("CompanyLabel", "");
  12658. #region 国际旅费
  12659. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12660. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12661. {
  12662. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12663. var label = new StringBuilder();
  12664. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12665. if (infos.Any())
  12666. {
  12667. label.Append(infos.Sum(x => x.PplNum));
  12668. label.Append("人全程机票:");
  12669. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12670. label.AppendLine("元");
  12671. }
  12672. foreach (var item in intTravelCosts.Infos)
  12673. {
  12674. label.Append(item.FeeName);
  12675. label.Append(":");
  12676. label.Append(item.UnitPrice.TruncDecimals(2));
  12677. label.Append("元/人*");
  12678. label.Append(item.PplNum);
  12679. label.AppendLine("人");
  12680. }
  12681. if (label.HasValue())
  12682. {
  12683. label.Append("\r\n以上小计:");
  12684. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12685. label.Append("元");
  12686. }
  12687. designer.SetDataSource("IntTravelLabel", label.ToString());
  12688. }
  12689. #endregion
  12690. #region 住宿费
  12691. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12692. if (accomCosts != null && accomCosts.Infos.Any())
  12693. {
  12694. string currencyName = string.Empty,
  12695. countryName = string.Empty;
  12696. decimal rate = 1.0000M;
  12697. var label = new StringBuilder();
  12698. label.AppendLine("全程五星酒店,每人1间房");
  12699. foreach (var item in accomCosts.Infos)
  12700. {
  12701. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12702. string name = string.Empty, thisCountryName = string.Empty;
  12703. if (item.FeeName.Contains('-'))
  12704. {
  12705. var feeName = item.FeeName.Split('-');
  12706. thisCountryName = feeName[0];
  12707. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12708. name = feeName[1];
  12709. }
  12710. else name = item.FeeName;
  12711. string thisFeeName = string.Empty;
  12712. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12713. else thisFeeName = $"\r\n{name}:";
  12714. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12715. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12716. rate = rateInfo?.Rate ?? 1.0000M;
  12717. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12718. label.AppendLine(subLabel);
  12719. }
  12720. if (label.HasValue())
  12721. {
  12722. //以上小计:52440元(美金汇率:7.5 )
  12723. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12724. label.AppendLine(subLabel);
  12725. }
  12726. designer.SetDataSource("AccomLabel", label.ToString());
  12727. }
  12728. #endregion
  12729. #region 餐饮费
  12730. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12731. if (mealCosts != null && mealCosts.Infos.Any())
  12732. {
  12733. string currencyName = string.Empty;
  12734. decimal rate = 1.0000M;
  12735. var label = new StringBuilder();
  12736. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12737. foreach (var item in mealCosts.Infos)
  12738. {
  12739. string name = string.Empty;
  12740. if (item.FeeName.Contains('-'))
  12741. {
  12742. var feeName = item.FeeName.Split('-');
  12743. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12744. }
  12745. else name = $"\r\n{item.FeeName}:";
  12746. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12747. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12748. rate = rateInfo?.Rate ?? 1.0000M;
  12749. label.Append(name);
  12750. label.Append(item.UnitPrice.TruncDecimals(2));
  12751. label.Append(currencyName);
  12752. label.Append("/天*");
  12753. label.Append(item.Quantity.ToString("#0"));
  12754. label.Append('*');
  12755. label.Append(item.PplNum);
  12756. label.Append("人\r\n");
  12757. }
  12758. if (label.HasValue())
  12759. {
  12760. label.Append("\r\n以上小计:");
  12761. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12762. label.Append("元\r\n(");
  12763. label.Append("汇率:");
  12764. label.Append(rate.TruncDecimals(4));
  12765. label.Append(')');
  12766. }
  12767. designer.SetDataSource("MealLabel", label.ToString());
  12768. }
  12769. #endregion
  12770. #region 车辆安排
  12771. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12772. if (vehArranges != null && vehArranges.Infos.Any())
  12773. {
  12774. string currencyName = string.Empty;
  12775. //decimal rate = 1.0000M;
  12776. var label = new StringBuilder();
  12777. foreach (var item in vehArranges.Infos)
  12778. {
  12779. label.AppendLine();
  12780. label.AppendLine();
  12781. label.Append(item.FeeName);
  12782. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12783. }
  12784. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12785. }
  12786. #endregion
  12787. #region 邀请函发放对象
  12788. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12789. designer.SetDataSource("InviteToContent", "");
  12790. #endregion
  12791. #region 邀请函费
  12792. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12793. var is_label = new StringBuilder();
  12794. if (inviteCosts != null && inviteCosts.Infos.Any())
  12795. {
  12796. string currencyName = string.Empty;
  12797. decimal rate = 1.0000M;
  12798. foreach (var item in inviteCosts.Infos)
  12799. {
  12800. //乌兹别克斯坦:2000美金
  12801. currencyName = item.Currency;
  12802. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12803. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12804. is_label.AppendLine(label);
  12805. }
  12806. if (is_label.HasValue())
  12807. {
  12808. //以上小计:28500元(美金汇率:7.5)
  12809. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12810. is_label.AppendLine(label);
  12811. }
  12812. }
  12813. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12814. #endregion
  12815. #region 邀请函发放时间
  12816. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12817. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12818. #endregion
  12819. #region 公务活动(含翻译)
  12820. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12821. var oa_label = new StringBuilder();
  12822. if (officialActs != null && officialActs.Infos.Any())
  12823. {
  12824. string currencyName = string.Empty;
  12825. decimal rate = 1.0000M;
  12826. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12827. foreach (var item in officialActs.Infos)
  12828. {
  12829. //乌兹别克斯坦:1000美金/场
  12830. currencyName = item.Currency;
  12831. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12832. string label_remark = string.Empty;
  12833. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12834. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12835. }
  12836. label_content += "*总费用中未含超出公务活动价格";
  12837. //8场公务活动(以上小计:60000元)
  12838. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12839. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12840. oa_label.AppendLine(label_title);
  12841. oa_label.AppendLine(label_content);
  12842. }
  12843. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12844. #endregion
  12845. #region 签证+保险
  12846. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12847. var vi_label = new StringBuilder();
  12848. if (visaIns != null && visaIns.Infos.Any())
  12849. {
  12850. foreach (var item in visaIns.Infos)
  12851. {
  12852. //签证:500元/人
  12853. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12854. vi_label.AppendLine(label);
  12855. }
  12856. if (vi_label.HasValue())
  12857. {
  12858. //以上小计:6000元
  12859. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12860. vi_label.AppendLine(label);
  12861. }
  12862. }
  12863. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12864. #endregion
  12865. #region 服务费
  12866. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12867. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12868. #endregion
  12869. #region 公杂费
  12870. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12871. var pm_label = new StringBuilder();
  12872. if (pubMiscs != null && pubMiscs.Infos.Any())
  12873. {
  12874. string currencyName = string.Empty,
  12875. countryName = string.Empty;
  12876. decimal rate = 1.0000M;
  12877. foreach (var item in pubMiscs.Infos)
  12878. {
  12879. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12880. string name = string.Empty, thisCountryName = string.Empty;
  12881. if (item.FeeName.Contains('-'))
  12882. {
  12883. var feeName = item.FeeName.Split('-');
  12884. thisCountryName = feeName[0];
  12885. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12886. name = feeName[1];
  12887. }
  12888. else name = item.FeeName;
  12889. string thisFeeName = string.Empty;
  12890. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12891. else thisFeeName = $"\r\n{name}:";
  12892. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12893. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12894. rate = rateInfo?.Rate ?? 1.0000M;
  12895. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12896. pm_label.AppendLine(label);
  12897. }
  12898. if (pm_label.HasValue())
  12899. {
  12900. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12901. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12902. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12903. pm_label.AppendLine(string.Format("部分发放成员"));
  12904. }
  12905. }
  12906. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12907. #endregion
  12908. #region 税费
  12909. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12910. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12911. #endregion
  12912. #region 合计(单位:元)
  12913. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12914. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12915. #endregion
  12916. #region 汇率 Remark
  12917. var rate_label = new StringBuilder();
  12918. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12919. foreach (var item in rateGroups)
  12920. {
  12921. //美元汇率按\r\n1:7.5
  12922. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12923. rate_label.AppendLine(label);
  12924. }
  12925. designer.SetDataSource("RateLabel", rate_label.ToString());
  12926. #endregion
  12927. designer.Process();
  12928. //文件名
  12929. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12930. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12931. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12932. return Ok(JsonView(true, "成功", url));
  12933. }
  12934. #endregion
  12935. #region 签证费用录入
  12936. /// <summary>
  12937. /// 根据diid查询签证费用列表
  12938. /// </summary>
  12939. /// <param name="dto"></param>
  12940. /// <returns></returns>
  12941. [HttpPost]
  12942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12943. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12944. {
  12945. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12946. if (groupData.Code != 0)
  12947. {
  12948. return Ok(JsonView(false, groupData.Msg));
  12949. }
  12950. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12951. }
  12952. /// <summary>
  12953. /// 根据签证费用Id查询单条数据及c表数据
  12954. /// </summary>
  12955. /// <param name="dto"></param>
  12956. /// <returns></returns>
  12957. [HttpPost]
  12958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12959. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12960. {
  12961. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12962. if (groupData.Code != 0)
  12963. {
  12964. return Ok(JsonView(false, groupData.Msg));
  12965. }
  12966. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12967. }
  12968. /// <summary>
  12969. /// 签证费用删除
  12970. /// </summary>
  12971. /// <param name="dto"></param>
  12972. /// <returns></returns>
  12973. [HttpPost]
  12974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12975. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12976. {
  12977. _sqlSugar.BeginTran();
  12978. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12979. if (!res)
  12980. {
  12981. _sqlSugar.RollbackTran();
  12982. return Ok(JsonView(false, "删除失败"));
  12983. }
  12984. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12985. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12986. .SetColumns(a => new Grp_CreditCardPayment()
  12987. {
  12988. IsDel = 1,
  12989. DeleteUserId = dto.DeleteUserId,
  12990. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12991. })
  12992. .ExecuteCommand();
  12993. if (resSub < 1)
  12994. {
  12995. _sqlSugar.RollbackTran();
  12996. return Ok(JsonView(false, "删除失败"));
  12997. }
  12998. _sqlSugar.CommitTran();
  12999. return Ok(JsonView(true, "删除成功!"));
  13000. }
  13001. /// <summary>
  13002. /// 签证费用录入下拉框初始化
  13003. /// </summary>
  13004. /// <returns></returns>
  13005. [HttpPost]
  13006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13007. public async Task<IActionResult> VisaPriceAddSelect()
  13008. {
  13009. //支付方式
  13010. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  13011. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  13012. //币种
  13013. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  13014. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  13015. //乘客类型
  13016. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  13017. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  13018. //卡类型
  13019. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  13020. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  13021. //代办费类型
  13022. var agencyFeeTypeData = new List<dynamic>() {
  13023. new { id = 0 , Text = "未选择" },
  13024. new { id = 1 , Text = "小公务" },
  13025. new { id = 2 , Text = "大公务" },
  13026. };
  13027. //签证费用标准国家Data
  13028. var visaSql = string.Format(@"select
  13029. id,
  13030. case
  13031. when FeeType = 0 then Country+'(因公)'
  13032. when FeeType = 1 then Country+'(因私)'
  13033. else Country+'(未设置)'
  13034. end as 'country'
  13035. from Res_VisaFeeStandard where isdel = 0");
  13036. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  13037. var data = new
  13038. {
  13039. Payment = _Payment,
  13040. CurrencyList = _CurrencyList,
  13041. PassengerType = _PassengerType,
  13042. BankCard = _BankCard,
  13043. AgencyFeeType = agencyFeeTypeData,
  13044. CountryFeeData = visaCountryFeeData
  13045. };
  13046. return Ok(JsonView(true, "查询成功!", data));
  13047. }
  13048. /// <summary>
  13049. /// 签证费用录入操作(Status:1.新增,2.修改)
  13050. /// </summary>
  13051. /// <param name="dto"></param>
  13052. /// <returns></returns>
  13053. [HttpPost]
  13054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13055. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  13056. {
  13057. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  13058. if (groupData.Code != 0)
  13059. {
  13060. return Ok(JsonView(false, groupData.Msg));
  13061. }
  13062. #region 应用推送
  13063. try
  13064. {
  13065. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13066. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13067. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13068. //2024-10-21 新增LZ UID
  13069. var userIds = new List<int>() { 21 };
  13070. string title = $"系统通知";
  13071. string content = "";
  13072. var diId = dto.DiId;
  13073. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13074. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13075. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13076. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13077. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13078. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  13079. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13080. }
  13081. catch (Exception ex)
  13082. {
  13083. }
  13084. #endregion
  13085. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13086. }
  13087. #endregion
  13088. #region 签证提成录入
  13089. /// <summary>
  13090. /// 签证提成录入
  13091. /// 基础数据
  13092. /// </summary>
  13093. /// <returns></returns>
  13094. [HttpGet]
  13095. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13096. public async Task<IActionResult> VisaCommissionInit()
  13097. {
  13098. return Ok(await _visaCommissionRep.Init());
  13099. }
  13100. /// <summary>
  13101. /// 签证提成录入
  13102. /// Item
  13103. /// </summary>
  13104. /// <param name="_dto"></param>
  13105. /// <returns></returns>
  13106. [HttpPost]
  13107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13108. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  13109. {
  13110. var validator = new VisaCommissionItemDtoValidator();
  13111. var validatorRes = await validator.ValidateAsync(_dto);
  13112. if (!validatorRes.IsValid)
  13113. {
  13114. var sb = new StringBuilder();
  13115. foreach (var item in validatorRes.Errors)
  13116. {
  13117. sb.AppendLine(item.ErrorMessage);
  13118. }
  13119. return Ok(JsonView(false, sb.ToString()));
  13120. }
  13121. return Ok(await _visaCommissionRep.Item(_dto));
  13122. }
  13123. /// <summary>
  13124. /// 签证提成录入
  13125. /// Save
  13126. /// </summary>
  13127. /// <param name="_dto"></param>
  13128. /// <returns></returns>
  13129. [HttpPost]
  13130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13131. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  13132. {
  13133. //参数验证
  13134. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  13135. foreach (var item in _dto.Items)
  13136. {
  13137. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  13138. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  13139. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  13140. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  13141. }
  13142. return Ok(await _visaCommissionRep.Save(_dto));
  13143. }
  13144. /// <summary>
  13145. /// 签证提成录入
  13146. /// Create
  13147. /// </summary>
  13148. /// <param name="_dto"></param>
  13149. /// <returns></returns>
  13150. [HttpPost]
  13151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13152. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  13153. {
  13154. var validator = new VisaCommissionCreateDtoValidator();
  13155. var validatorRes = await validator.ValidateAsync(_dto);
  13156. if (!validatorRes.IsValid)
  13157. {
  13158. var sb = new StringBuilder();
  13159. foreach (var item in validatorRes.Errors)
  13160. {
  13161. sb.AppendLine(item.ErrorMessage);
  13162. }
  13163. return Ok(JsonView(false, sb.ToString()));
  13164. }
  13165. return Ok(await _visaCommissionRep.Create(_dto));
  13166. }
  13167. /// <summary>
  13168. /// 签证提成录入
  13169. /// Put(编辑)
  13170. /// </summary>
  13171. /// <param name="id"></param>
  13172. /// <param name="_dto"></param>
  13173. /// <returns></returns>
  13174. [HttpPut]
  13175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13176. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  13177. {
  13178. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13179. var validator = new VisaCommissionCreateDtoValidator();
  13180. var validatorRes = await validator.ValidateAsync(_dto);
  13181. if (!validatorRes.IsValid)
  13182. {
  13183. var sb = new StringBuilder();
  13184. foreach (var item in validatorRes.Errors)
  13185. {
  13186. sb.AppendLine(item.ErrorMessage);
  13187. }
  13188. return Ok(JsonView(false, sb.ToString()));
  13189. }
  13190. return Ok(await _visaCommissionRep.Edit(id, _dto));
  13191. }
  13192. /// <summary>
  13193. /// 签证提成录入
  13194. /// Del
  13195. /// </summary>
  13196. /// <param name="id"></param>
  13197. /// <param name="currUserId"></param>
  13198. /// <returns></returns>
  13199. [HttpPost]
  13200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13201. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  13202. {
  13203. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13204. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  13205. return Ok(await _visaCommissionRep.Del(id, currUserId));
  13206. }
  13207. #endregion
  13208. #region op费用录入
  13209. /// <summary>
  13210. /// 根据diid查询op费用列表
  13211. /// </summary>
  13212. /// <param name="dto"></param>
  13213. /// <returns></returns>
  13214. [HttpPost]
  13215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13216. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  13217. {
  13218. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  13219. if (groupData.Code != 0)
  13220. {
  13221. return Ok(JsonView(false, groupData.Msg));
  13222. }
  13223. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13224. }
  13225. /// <summary>
  13226. /// 根据op费用Id查询单条数据及c表数据
  13227. /// </summary>
  13228. /// <param name="dto"></param>
  13229. /// <returns></returns>
  13230. [HttpPost]
  13231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13232. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  13233. {
  13234. try
  13235. {
  13236. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  13237. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  13238. var data = new
  13239. {
  13240. CarTouristGuideGround = _groupData,
  13241. CreditCardPayment = _creditCardPayment
  13242. };
  13243. return Ok(JsonView(true, "查询成功!", data));
  13244. }
  13245. catch (Exception ex)
  13246. {
  13247. return Ok(JsonView(false, "程序错误!"));
  13248. }
  13249. }
  13250. /// <summary>
  13251. /// op费用删除
  13252. /// </summary>
  13253. /// <param name="dto"></param>
  13254. /// <returns></returns>
  13255. [HttpPost]
  13256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13257. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  13258. {
  13259. try
  13260. {
  13261. _sqlSugar.BeginTran();
  13262. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  13263. if (!res)
  13264. {
  13265. return Ok(JsonView(false, "删除失败"));
  13266. }
  13267. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  13268. {
  13269. IsDel = 1,
  13270. DeleteUserId = dto.DeleteUserId,
  13271. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13272. }).ExecuteCommandAsync();
  13273. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  13274. {
  13275. IsDel = 1,
  13276. DeleteUserId = dto.DeleteUserId,
  13277. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13278. }).ExecuteCommandAsync();
  13279. #region 删除超支相关数据
  13280. //删除导入的超支数据
  13281. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  13282. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  13283. {
  13284. IsDel = 1,
  13285. DeleteUserId = dto.DeleteUserId,
  13286. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13287. }).ExecuteCommand();
  13288. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  13289. {
  13290. IsDel = 1,
  13291. DeleteUserId = dto.DeleteUserId,
  13292. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13293. }).ExecuteCommand();
  13294. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  13295. {
  13296. IsDel = 1,
  13297. DeleteUserId = dto.DeleteUserId,
  13298. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13299. }).ExecuteCommand();
  13300. #endregion
  13301. _sqlSugar.CommitTran();
  13302. return Ok(JsonView(true, "删除成功!"));
  13303. }
  13304. catch (Exception ex)
  13305. {
  13306. _sqlSugar.RollbackTran();
  13307. return Ok(JsonView(false, "程序错误!" + ex.Message));
  13308. }
  13309. }
  13310. /// <summary>
  13311. /// op费用录入操作(Status:1.新增,2.修改)
  13312. /// </summary>
  13313. /// <param name="dto"></param>
  13314. /// <returns></returns>
  13315. [HttpPost]
  13316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13317. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  13318. {
  13319. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  13320. if (groupData.Code != 0)
  13321. {
  13322. return Ok(JsonView(false, groupData.Msg));
  13323. }
  13324. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13325. }
  13326. /// <summary>
  13327. /// 填写费用详细页面初始化绑定
  13328. /// </summary>
  13329. /// <param name="dto"></param>
  13330. /// <returns></returns>
  13331. [HttpPost]
  13332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13333. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  13334. {
  13335. try
  13336. {
  13337. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13338. if (groupData.Code != 0)
  13339. {
  13340. return Ok(JsonView(false, groupData.Msg));
  13341. }
  13342. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13343. }
  13344. catch (Exception ex)
  13345. {
  13346. return Ok(JsonView(false, ex.Message));
  13347. }
  13348. }
  13349. /// <summary>
  13350. /// 根据op费用Id查询详细数据
  13351. /// </summary>
  13352. /// <param name="dto"></param>
  13353. /// <returns></returns>
  13354. [HttpPost]
  13355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13356. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13357. {
  13358. try
  13359. {
  13360. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13361. if (groupData.Code != 0)
  13362. {
  13363. return Ok(JsonView(false, groupData.Msg));
  13364. }
  13365. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13366. }
  13367. catch (Exception ex)
  13368. {
  13369. return Ok(JsonView(false, ex.Message));
  13370. }
  13371. }
  13372. /// <summary>
  13373. /// OP费用录入填写详情
  13374. /// </summary>
  13375. /// <param name="dto"></param>
  13376. /// <returns></returns>
  13377. [HttpPost]
  13378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13379. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  13380. {
  13381. try
  13382. {
  13383. #region 参数校验
  13384. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  13385. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  13386. if (di == null) return Ok(JsonView(false, "团组错误!"));
  13387. #endregion
  13388. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  13389. if (groupData.Code != 0)
  13390. {
  13391. return Ok(JsonView(false, groupData.Msg));
  13392. }
  13393. //自动审核
  13394. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  13395. #region 尾款自动审核
  13396. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13397. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  13398. if (opinfos.PriceType == 1062)
  13399. {
  13400. var isAuto = false;
  13401. //找对应的首付款
  13402. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13403. .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))
  13404. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  13405. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  13406. x.PriceType == 1061 && x.DiId == dto.DiId);
  13407. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  13408. {
  13409. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  13410. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  13411. //合计中排除城市税
  13412. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  13413. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  13414. .Sum(x => x.Price * x.Count);
  13415. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  13416. if (balance >= opinfos.ServiceQuotedPrice)
  13417. {
  13418. isAuto = true;
  13419. }
  13420. }
  13421. if (isAuto)
  13422. {
  13423. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13424. .SetColumns(a => new Grp_CreditCardPayment
  13425. {
  13426. IsAuditGM = 3, //自动审核通过
  13427. AuditGMOperate = 4,
  13428. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13429. })
  13430. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  13431. .ExecuteCommand();
  13432. }
  13433. }
  13434. #endregion
  13435. #region 应用推送
  13436. try
  13437. {
  13438. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13439. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13440. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13441. //2024-10-21 新增LZ UID
  13442. var userIds = new List<int>() { 21 };
  13443. string title = $"系统通知";
  13444. var diId = dto.DiId;
  13445. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13446. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13447. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  13448. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13449. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  13450. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13451. }
  13452. catch (Exception ex)
  13453. {
  13454. }
  13455. #endregion
  13456. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13457. }
  13458. catch (Exception ex)
  13459. {
  13460. return Ok(JsonView(false, ex.Message));
  13461. }
  13462. }
  13463. /// <summary>
  13464. /// 获取三公详细所有城市
  13465. /// </summary>
  13466. /// <returns></returns>
  13467. [HttpGet]
  13468. public IActionResult OpCarCityResult()
  13469. {
  13470. var jw = JsonView(false);
  13471. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13472. {
  13473. x.Id,
  13474. x.Country,
  13475. x.City,
  13476. }).ToList();
  13477. if (data.Count > 0)
  13478. {
  13479. jw = JsonView(true, "获取成功!", data);
  13480. }
  13481. else
  13482. {
  13483. jw.Msg = "城市数据为空!";
  13484. jw.Data = Array.Empty<string>();
  13485. }
  13486. return Ok(jw);
  13487. }
  13488. /// <summary>
  13489. /// 导出地接费用明细
  13490. /// </summary>
  13491. /// <param name="dto"></param>
  13492. /// <returns></returns>
  13493. [HttpPost]
  13494. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13495. {
  13496. var jw = JsonView(false);
  13497. if (dto.Diid < 1)
  13498. {
  13499. jw.Msg = "请输入正确的diid!";
  13500. return Ok(jw);
  13501. }
  13502. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13503. if (group == null)
  13504. {
  13505. jw.Msg = "未找到团组信息!";
  13506. return Ok(jw);
  13507. }
  13508. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13509. if (localGuideArr.Count == 0)
  13510. {
  13511. jw.Msg = "该团组暂无地接信息!";
  13512. return Ok(jw);
  13513. }
  13514. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13515. var overspendSoure = new Dictionary<int, int>
  13516. {
  13517. { 91, 982 }, //车
  13518. { 92 , 1059} ,//导游
  13519. { 994 , 1073}, //翻译
  13520. { 988 , 1074 }, //早餐
  13521. { 93 , 1075 }, //午餐
  13522. { 989 , 1076 }, //晚餐
  13523. };
  13524. var Zips = new Dictionary<string, Stream>();
  13525. foreach (var groupArr in localGroup)
  13526. {
  13527. var keyValue = groupArr.Key;
  13528. if (int.TryParse(keyValue, out int cityid))
  13529. {
  13530. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13531. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13532. }
  13533. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13534. foreach (var item in groupArr)
  13535. {
  13536. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13537. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13538. new Grp_CarTouristGuideGroundReservationsContentExtend
  13539. {
  13540. Count = a.Count,
  13541. CreateTime = a.CreateTime,
  13542. CreateUserId = a.CreateUserId,
  13543. CTGGRId = a.CTGGRId,
  13544. Currency = a.Currency,
  13545. DatePrice = a.DatePrice,
  13546. DeleteTime = a.DeleteTime,
  13547. DeleteUserId = a.DeleteUserId,
  13548. DiId = a.DiId,
  13549. Id = a.Id,
  13550. IsDel = a.IsDel,
  13551. Price = a.Price,
  13552. PriceContent = a.PriceContent,
  13553. Remark = a.Remark,
  13554. SId = a.SId,
  13555. SidName = b.Name,
  13556. Units = a.Units,
  13557. }
  13558. ).ToList();
  13559. if (content.Count > 0)
  13560. {
  13561. contentArr.Add(content);
  13562. }
  13563. }
  13564. //open excel
  13565. //set excel
  13566. //save excel
  13567. try
  13568. {
  13569. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13570. IWorkbook workbook;
  13571. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13572. {
  13573. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13574. }
  13575. else
  13576. {
  13577. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13578. }
  13579. ISheet sheet = workbook.GetSheetAt(0);
  13580. var rowStartIndex = 2;
  13581. var clounmCount = 10;
  13582. var initStyleRow = sheet.GetRow(2);
  13583. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13584. //var overspendArrDetail =
  13585. var existsId = new List<CarCompare>();
  13586. var lastElem = arr.Last();
  13587. var thisSid = -1;
  13588. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13589. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13590. {
  13591. Name = "未知币种!",
  13592. Remark = "未知币种!",
  13593. };
  13594. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13595. Action cloneRowFn = () =>
  13596. {
  13597. rowStartIndex++;
  13598. var cloneRow = sheet.CreateRow(rowStartIndex);
  13599. // 复制样式
  13600. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13601. {
  13602. ICell sourceCell = initStyleRow.GetCell(i);
  13603. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13604. // 确保单元格存在样式
  13605. if (sourceCell.CellStyle != null)
  13606. {
  13607. targetCell.CellStyle = sourceCell.CellStyle;
  13608. }
  13609. }
  13610. };
  13611. var mergeRow = () =>
  13612. {
  13613. for (int i = 2; i < sheet.LastRowNum; i++)
  13614. {
  13615. var row = sheet.GetRow(i);
  13616. var cellFirst = row.GetCell(0);
  13617. var thisIndex = i + 1;
  13618. while (thisIndex < sheet.LastRowNum)
  13619. {
  13620. var nextRow = sheet.GetRow(thisIndex);
  13621. var nextCellFirst = nextRow.GetCell(0);
  13622. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13623. {
  13624. thisIndex++;
  13625. }
  13626. else
  13627. {
  13628. break;
  13629. }
  13630. }
  13631. thisIndex--;
  13632. if (thisIndex != i)
  13633. {
  13634. //合并row
  13635. var cellRangeAddress = new CellRangeAddress(
  13636. i, // 起始行索引(0-based)
  13637. thisIndex, // 结束行索引(0-based)
  13638. 0, // 起始列索引(0-based)
  13639. 0 // 结束列索引(0-based)
  13640. );
  13641. sheet.AddMergedRegion(cellRangeAddress);
  13642. i = thisIndex;
  13643. }
  13644. }
  13645. };
  13646. var chaoshiNumber = 0;
  13647. var totalNumber = 0.00M;
  13648. string lastStr = "";
  13649. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13650. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13651. {
  13652. b.IsAuditGM,
  13653. x.Id,
  13654. x.Area,
  13655. b.PayPercentage,
  13656. b.PayMoney,
  13657. }).ToList();
  13658. string yesPayment = "", noPayment = "";
  13659. foreach (var item in queryCarArrByCityAndDiid)
  13660. {
  13661. if (item.IsAuditGM == 1)
  13662. {
  13663. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13664. }
  13665. else
  13666. {
  13667. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13668. }
  13669. }
  13670. lastStr = yesPayment + noPayment;
  13671. foreach (var item in arr)
  13672. {
  13673. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13674. {
  13675. if (thisSid != item.SId)
  13676. {
  13677. if (thisSid == -1)
  13678. {
  13679. thisSid = item.SId;
  13680. }
  13681. else
  13682. {
  13683. //合并小计行
  13684. //创建合并区域的实例
  13685. var cellRangeAddress = new CellRangeAddress(
  13686. rowStartIndex, // 起始行索引(0-based)
  13687. rowStartIndex, // 结束行索引(0-based)
  13688. 0, // 起始列索引(0-based)
  13689. 3 // 结束列索引(0-based)
  13690. );
  13691. sheet.AddMergedRegion(cellRangeAddress);
  13692. var CellStyle = workbook.CreateCellStyle();
  13693. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13694. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13695. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13696. for (int i = 0; i <= clounmCount; i++)
  13697. {
  13698. if (i > 6)
  13699. {
  13700. var CellStyle1 = workbook.CreateCellStyle();
  13701. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13702. IFont Font = workbook.CreateFont(); // 创建字体
  13703. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13704. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13705. CellStyle1.SetFont(Font);
  13706. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13707. }
  13708. else
  13709. {
  13710. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13711. }
  13712. }
  13713. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13714. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13715. //超时合计
  13716. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13717. //超时数
  13718. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13719. //超时合计费用
  13720. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13721. thisSid = item.SId;
  13722. cloneRowFn();
  13723. chaoshiNumber = 0;
  13724. totalNumber = 0;
  13725. }
  13726. }
  13727. IRow row = sheet.GetRow(rowStartIndex);
  13728. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13729. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13730. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13731. if (isOpenOverspendSoure)
  13732. {
  13733. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13734. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13735. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13736. }
  13737. for (int i = 0; i <= clounmCount; i++)
  13738. {
  13739. var cell = row.GetCell(i);
  13740. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13741. if (cell == null)
  13742. {
  13743. cell = row.CreateCell(i);
  13744. }
  13745. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13746. fontRed.CloneStyleFrom(cell.CellStyle);
  13747. IFont Font = workbook.CreateFont(); // 创建字体
  13748. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13749. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13750. fontRed.SetFont(Font);
  13751. byte[] rgb = new byte[3] { 255, 242, 204 };
  13752. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13753. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13754. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13755. if (workbook is XSSFWorkbook)
  13756. {
  13757. BackgroundColor255_242_204.FillForegroundColor = 0;
  13758. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13759. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13760. }
  13761. else
  13762. {
  13763. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13764. }
  13765. if (i == 1 || i > 6)
  13766. {
  13767. if (i > 6)
  13768. {
  13769. fontRed.FillForegroundColor = 0;
  13770. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13771. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13772. }
  13773. cell.CellStyle = fontRed;
  13774. }
  13775. if (i > 2 && i < 7)
  13776. {
  13777. cell.CellStyle = BackgroundColor255_242_204;
  13778. }
  13779. cell.SetCellValue(setCellValue); //写入单元格
  13780. }
  13781. if (overspendSoure.ContainsKey(thisSid))
  13782. {
  13783. var overspendId = overspendSoure[thisSid];
  13784. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13785. }
  13786. cloneRowFn();
  13787. existsId.Add(new CarCompare
  13788. {
  13789. DataPrice = item.DatePrice.ObjToDate(),
  13790. Sid = item.SId
  13791. });
  13792. }
  13793. if (item.Equals(lastElem))
  13794. {
  13795. //合并小计行
  13796. //创建合并区域的实例
  13797. var cellRangeAddress = new CellRangeAddress(
  13798. rowStartIndex, // 起始行索引(0-based)
  13799. rowStartIndex, // 结束行索引(0-based)
  13800. 0, // 起始列索引(0-based)
  13801. 3 // 结束列索引(0-based)
  13802. );
  13803. sheet.AddMergedRegion(cellRangeAddress);
  13804. var CellStyle = workbook.CreateCellStyle();
  13805. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13806. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13807. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13808. for (int i = 0; i <= clounmCount; i++)
  13809. {
  13810. if (i > 6)
  13811. {
  13812. var CellStyle1 = workbook.CreateCellStyle();
  13813. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13814. IFont Font = workbook.CreateFont(); // 创建字体
  13815. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13816. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13817. CellStyle1.SetFont(Font);
  13818. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13819. }
  13820. else
  13821. {
  13822. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13823. }
  13824. }
  13825. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13826. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13827. //超时合计
  13828. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13829. //超时数
  13830. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13831. //超时合计费用
  13832. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13833. cloneRowFn();
  13834. // 创建合并区域的实例
  13835. cellRangeAddress = new CellRangeAddress(
  13836. rowStartIndex, // 起始行索引(0-based)
  13837. rowStartIndex, // 结束行索引(0-based)
  13838. 0, // 起始列索引(0-based)
  13839. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13840. );
  13841. // 添加合并区域
  13842. sheet.AddMergedRegion(cellRangeAddress);
  13843. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13844. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13845. }
  13846. }
  13847. mergeRow();
  13848. // 保存修改后的Excel文件到新文件
  13849. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13850. // new FileStream(newFilePath, FileMode.CreateNew)
  13851. using (var stream = new MemoryStream())
  13852. {
  13853. workbook.Write(stream, true);
  13854. stream.Flush();
  13855. stream.Seek(0, SeekOrigin.Begin);
  13856. var memoryStream = new MemoryStream();
  13857. stream.CopyTo(memoryStream);
  13858. memoryStream.Seek(0, SeekOrigin.Begin);
  13859. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13860. }
  13861. workbook.Close();
  13862. workbook.Dispose();
  13863. }
  13864. catch (Exception ex)
  13865. {
  13866. jw.Msg = "出现异常!" + ex.Message;
  13867. return Ok(jw);
  13868. }
  13869. }
  13870. if (Zips.Count > 0)
  13871. {
  13872. var io = new IOOperatorHelper();
  13873. var byts = io.ConvertZipStream(Zips);
  13874. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13875. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13876. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13877. }
  13878. else
  13879. {
  13880. jw.Msg = "暂无生成文件!";
  13881. }
  13882. return Ok(jw);
  13883. }
  13884. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13885. {
  13886. string outStr = string.Empty;
  13887. switch (i)
  13888. {
  13889. case 0:
  13890. outStr = arr[0].SidName;
  13891. break;
  13892. case 1:
  13893. outStr = arr[0].DataPriceStr;
  13894. break;
  13895. case 2:
  13896. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13897. break;
  13898. case 4:
  13899. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13900. break;
  13901. case 7:
  13902. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13903. {
  13904. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13905. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13906. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13907. }
  13908. break;
  13909. case 8:
  13910. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13911. {
  13912. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13913. }
  13914. break;
  13915. case 9:
  13916. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13917. {
  13918. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13919. }
  13920. break;
  13921. case 10:
  13922. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13923. {
  13924. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13925. }
  13926. break;
  13927. }
  13928. return outStr;
  13929. }
  13930. #region OP行程单
  13931. /// <summary>
  13932. /// OP行程单初始化
  13933. /// </summary>
  13934. /// <param name="dto"></param>
  13935. /// <returns></returns>
  13936. [HttpPost]
  13937. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13938. {
  13939. var jw = JsonView(false);
  13940. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13941. var group = groupList.First();
  13942. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13943. if (group == null)
  13944. {
  13945. jw.Msg = "暂无团组!";
  13946. return Ok(jw);
  13947. }
  13948. group = groupList.Find(x => x.Id == diid);
  13949. if (group == null)
  13950. {
  13951. jw.Msg = "请输入正确的团组ID!";
  13952. return Ok(jw);
  13953. }
  13954. string city = string.Empty;
  13955. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13956. if (blackCode.Count > 0)
  13957. {
  13958. var black = blackCode.First();
  13959. black.BlackCode = black.BlackCode ?? "";
  13960. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13961. if (blackSp.Length > 0)
  13962. {
  13963. try
  13964. {
  13965. var cityArrCode = new List<string>(20);
  13966. foreach (var item in blackSp)
  13967. {
  13968. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13969. var IndexSelect = itemSp[2];
  13970. var cityArrCodeLength = cityArrCode.Count - 1;
  13971. var startCity = IndexSelect.Substring(0, 3);
  13972. if (cityArrCodeLength > 0)
  13973. {
  13974. var arrEndCity = cityArrCode[cityArrCodeLength];
  13975. if (arrEndCity != startCity)
  13976. {
  13977. cityArrCode.Add(startCity.ToUpper());
  13978. }
  13979. }
  13980. else
  13981. {
  13982. cityArrCode.Add(startCity.ToUpper());
  13983. }
  13984. var endCity = IndexSelect.Substring(3, 3);
  13985. cityArrCode.Add(endCity.ToUpper());
  13986. }
  13987. var cityThree = string.Empty;
  13988. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13989. cityThree = cityThree.TrimEnd(',');
  13990. if (string.IsNullOrWhiteSpace(cityThree))
  13991. {
  13992. throw new
  13993. Exception("error");
  13994. }
  13995. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13996. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13997. foreach (var item in cityArrCode)
  13998. {
  13999. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  14000. if (find != null)
  14001. {
  14002. city += find.City + "/";
  14003. }
  14004. else
  14005. {
  14006. city += item + "三字码未收入/";
  14007. }
  14008. }
  14009. city = city.TrimEnd('/');
  14010. }
  14011. catch (Exception e)
  14012. {
  14013. city = "黑屏代码格式不正确!";
  14014. }
  14015. }
  14016. }
  14017. else
  14018. {
  14019. city = "未录入黑屏代码";
  14020. }
  14021. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  14022. {
  14023. Date = x.Date,
  14024. Days = x.Days,
  14025. Diffgroup = x.Diffgroup,
  14026. Diid = x.Diid,
  14027. Traffic_First = x.Traffic_First,
  14028. Traffic_Second = x.Traffic_Second,
  14029. Trip = x.Trip,
  14030. WeekDay = x.WeekDay,
  14031. Id = x.Id
  14032. }).ToList();
  14033. jw.Data = new
  14034. {
  14035. groupList = groupList.Select(x => new
  14036. {
  14037. x.Id,
  14038. x.TeamName,
  14039. x.TourCode
  14040. }).ToList(),
  14041. groupInfo = new
  14042. {
  14043. group.VisitDays,
  14044. group.TourCode,
  14045. group.VisitPNumber,
  14046. group.TeamName,
  14047. city
  14048. },
  14049. OpTravelList
  14050. };
  14051. jw.Code = 200;
  14052. jw.Msg = "操作成功!";
  14053. return Ok(jw);
  14054. }
  14055. /// <summary>
  14056. /// 删除团组行程单
  14057. /// </summary>
  14058. /// <returns></returns>
  14059. [HttpPost]
  14060. public IActionResult DelTravel(DelOpTravelDto dto)
  14061. {
  14062. var jw = JsonView(false);
  14063. if (dto.UserId <= 0 || dto.Diid <= 0)
  14064. {
  14065. jw.Msg = "请输入正确的参数!";
  14066. return Ok(jw);
  14067. }
  14068. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  14069. .SetColumns(x => new Grp_TravelList
  14070. {
  14071. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  14072. DeleteUserId = dto.UserId,
  14073. IsDel = 1,
  14074. }).ExecuteCommand();
  14075. jw = JsonView(true);
  14076. return Ok(jw);
  14077. }
  14078. /// <summary>
  14079. /// 行程单保存
  14080. /// </summary>
  14081. /// <returns></returns>
  14082. [HttpPost]
  14083. public IActionResult TravelSave(TravelSaveDto dto)
  14084. {
  14085. var jw = JsonView(false);
  14086. if (dto.Arr.Count > 0)
  14087. {
  14088. try
  14089. {
  14090. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  14091. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  14092. .ToList();
  14093. _sqlSugar.BeginTran();
  14094. foreach (var item in dto.Arr)
  14095. {
  14096. if (item.Id == 0)
  14097. {
  14098. throw new Exception("请传入正确的Id");
  14099. }
  14100. //比较上一次的差异
  14101. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  14102. if (findTravel != null)
  14103. {
  14104. item.Trip = item.Trip.Replace("[++]", string.Empty);
  14105. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  14106. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  14107. }
  14108. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  14109. .SetColumns(x => new Grp_TravelList
  14110. {
  14111. Trip = item.Trip
  14112. }).ExecuteCommand();
  14113. }
  14114. _sqlSugar.CommitTran();
  14115. jw = JsonView(true);
  14116. }
  14117. catch (Exception ex)
  14118. {
  14119. _sqlSugar.RollbackTran();
  14120. jw.Msg = "程序异常!" + ex.Message;
  14121. }
  14122. }
  14123. else
  14124. {
  14125. jw.Msg = "请传入正确的参数!";
  14126. }
  14127. return Ok(jw);
  14128. }
  14129. private static string CheckStr(string original, string changed)
  14130. {
  14131. // 创建diff_match_patch对象
  14132. var dmp = new diff_match_patch();
  14133. // 计算差异
  14134. List<Diff> diffs = dmp.diff_main(original, changed);
  14135. // 清理和合并差异
  14136. dmp.diff_cleanupSemantic(diffs);
  14137. // 使用StringBuilder构建最终的字符串
  14138. var finalString = new StringBuilder();
  14139. // 输出差异结果,并构建变动后的字符串
  14140. foreach (Diff diff in diffs)
  14141. {
  14142. switch (diff.operation)
  14143. {
  14144. case Operation.EQUAL:
  14145. // 相等的部分,直接添加到最终字符串
  14146. finalString.Append(diff.text);
  14147. break;
  14148. case Operation.INSERT:
  14149. // 插入的部分,添加标记并添加到最终字符串
  14150. finalString.Append("[++]" + diff.text + "[++]");
  14151. break;
  14152. case Operation.DELETE:
  14153. // 删除的部分,不添加到最终字符串
  14154. //finalString.Append("[++]" + diff.text + "[++]");
  14155. break;
  14156. }
  14157. }
  14158. // 输出变动后的字符串
  14159. return finalString.ToString();
  14160. }
  14161. private class tagContent
  14162. {
  14163. public DateTime Date { get; set; }
  14164. public string StartTag { get; set; }
  14165. public string EndTag { get; set; }
  14166. public string Content { get; set; }
  14167. public static int tagLength { get { return 3; } }
  14168. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  14169. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  14170. public bool IsFinally { get; set; }
  14171. }
  14172. private static List<string> ExtractContentBetweenTags(string input, string tag)
  14173. {
  14174. var results = new List<string>();
  14175. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  14176. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  14177. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  14178. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  14179. string[] strValueArr = new string[1];
  14180. foreach (System.Text.RegularExpressions.Match match in matches)
  14181. {
  14182. var strValue = match.Groups[1].Value;
  14183. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  14184. }
  14185. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  14186. return results;
  14187. }
  14188. /// <summary>
  14189. /// 导出行程单
  14190. /// </summary>
  14191. /// <param name="dto"></param>
  14192. /// <returns></returns>
  14193. [HttpPost]
  14194. public IActionResult ExportTravel(ExportTravelDto dto)
  14195. {
  14196. var jw = JsonView(false);
  14197. jw.Data = "";
  14198. int diid = 0;
  14199. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  14200. if (Find == null)
  14201. {
  14202. jw.Msg = "请选择正确的团组!";
  14203. return Ok(jw);
  14204. }
  14205. else
  14206. {
  14207. diid = Find.Id;
  14208. }
  14209. //数据源
  14210. var _travelList = new List<Grp_TravelList>();
  14211. DataTable dtBlack = null;
  14212. try
  14213. {
  14214. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  14215. }
  14216. catch (Exception)
  14217. {
  14218. jw.Msg = "机票黑屏代码有误!";
  14219. return Ok(jw);
  14220. }
  14221. string CityStr = string.Empty;
  14222. if (dtBlack.Rows.Count == 0)
  14223. {
  14224. jw.Msg = "机票黑屏代码有误!";
  14225. return Ok(jw);
  14226. }
  14227. else
  14228. {
  14229. foreach (DataRow row in dtBlack.Rows)
  14230. {
  14231. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14232. {
  14233. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  14234. return Ok(jw);
  14235. }
  14236. }
  14237. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  14238. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  14239. }
  14240. // 指定的文字
  14241. var targetTextDic = new Dictionary<string, List<string>>();
  14242. //创建数据源Table
  14243. var dtSource = new DataTable();
  14244. dtSource.Columns.Add("Days", typeof(string));
  14245. dtSource.Columns.Add("Date", typeof(string));
  14246. dtSource.Columns.Add("Week", typeof(string));
  14247. dtSource.Columns.Add("Traffic", typeof(string));
  14248. dtSource.Columns.Add("Trip", typeof(string));
  14249. //获取数据,放到datatable
  14250. foreach (var item in _travelList)
  14251. {
  14252. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  14253. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  14254. .Replace(tagContent.TagFormat.Item2, string.Empty)
  14255. .Replace("[++]", string.Empty);
  14256. DataRow dr = dtSource.NewRow();
  14257. dr["Days"] = item.Days;
  14258. dr["Date"] = item.Date;
  14259. dr["Week"] = item.WeekDay;
  14260. dr["Traffic"] = item.Traffic_First
  14261. + "\r\n"
  14262. + item.Traffic_Second;
  14263. dr["Trip"] = item.Trip;
  14264. dtSource.Rows.Add(dr);
  14265. }
  14266. var dic = new Dictionary<string, string>
  14267. {
  14268. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  14269. { "City", CityStr },
  14270. { "Days", Find.VisitDays.ToString() },
  14271. { "DeleCode", Find.TourCode },
  14272. { "Pnum", Find.VisitPNumber.ToString() }
  14273. };
  14274. //模板路径
  14275. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  14276. //载入模板
  14277. Document doc = null;
  14278. DocumentBuilder builder = null;
  14279. try
  14280. {
  14281. //载入模板
  14282. doc = new Document(tempPath);
  14283. builder = new DocumentBuilder(doc);
  14284. }
  14285. catch (Exception)
  14286. {
  14287. jw.Msg = "模板位置不存在!";
  14288. return Ok(jw);
  14289. }
  14290. foreach (var key in dic.Keys)
  14291. {
  14292. Bookmark bookmark = doc.Range.Bookmarks[key];
  14293. if (bookmark != null)
  14294. {
  14295. builder.MoveToBookmark(key);
  14296. builder.Write(dic[key]);
  14297. }
  14298. }
  14299. //获取word里所有表格
  14300. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14301. //获取所填表格的序数
  14302. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14303. try
  14304. {
  14305. //循环赋值
  14306. for (int i = 0; i < dtSource.Rows.Count; i++)
  14307. {
  14308. builder.MoveToCell(0, i + 1, 0, 0);
  14309. builder.Write(dtSource.Rows[i]["Days"].ToString());
  14310. builder.MoveToCell(0, i + 1, 1, 0);
  14311. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  14312. builder.MoveToCell(0, i + 1, 2, 0);
  14313. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  14314. var trip = dtSource.Rows[i]["Trip"].ToString();
  14315. builder.MoveToCell(0, i + 1, 3, 0);
  14316. builder.Write(trip);
  14317. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  14318. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14319. // 获取特定索引的段落
  14320. Paragraph paragraph = (Paragraph)paragraphs[0];
  14321. Run run = paragraph.Runs[0];
  14322. Aspose.Words.Font font = run.Font;
  14323. font.Name = "黑体";
  14324. //设置双休红色
  14325. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  14326. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14327. paragraph = (Paragraph)paragraphs[1];
  14328. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  14329. {
  14330. run = paragraph.Runs[0];
  14331. font = run.Font;
  14332. font.Color = Color.Red;
  14333. }
  14334. }
  14335. }
  14336. catch (Exception ex)
  14337. {
  14338. }
  14339. //删除多余行
  14340. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  14341. {
  14342. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  14343. }
  14344. var targetTextList = new List<string>();
  14345. // 遍历文档中的表格
  14346. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14347. {
  14348. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14349. {
  14350. var cellIndex = 0;
  14351. foreach (Cell cell in row.Cells)
  14352. {
  14353. if (cellIndex == 1 && row.Cells.Count == 4)
  14354. {
  14355. foreach (var target in targetTextDic.Keys)
  14356. {
  14357. if (cell.GetText().Contains(target))
  14358. {
  14359. targetTextList = targetTextDic[target];
  14360. break;
  14361. }
  14362. }
  14363. }
  14364. // 遍历单元格中的所有段落
  14365. foreach (Paragraph paragraph in cell.Paragraphs)
  14366. {
  14367. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  14368. var runs = new List<Run>();
  14369. foreach (Run run in paragraph.Runs)
  14370. {
  14371. runs.Add(run);
  14372. }
  14373. foreach (Run run in runs)
  14374. {
  14375. foreach (var targetText in targetTextList)
  14376. {
  14377. // 检查文字是否包含指定文字
  14378. if (run.Text.Contains(targetText))
  14379. {
  14380. // 将包含的部分设置为红色
  14381. HighlightText(run, targetText, Color.Red);
  14382. }
  14383. }
  14384. }
  14385. }
  14386. cellIndex++;
  14387. }
  14388. }
  14389. }
  14390. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  14391. if (!Directory.Exists(savePath))
  14392. {
  14393. try
  14394. {
  14395. Directory.CreateDirectory(savePath);
  14396. }
  14397. catch
  14398. {
  14399. }
  14400. }
  14401. string path = savePath + Find.TeamName + "出访日程";
  14402. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  14403. try
  14404. {
  14405. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  14406. string postfix = ".docx";
  14407. if (dto.IsPDF == 1)
  14408. {
  14409. saveFormat = Aspose.Words.SaveFormat.Pdf;
  14410. postfix = ".pdf";
  14411. }
  14412. doc.Save(path + postfix, saveFormat);
  14413. jw = JsonView(true, "导出成功", ftpPath + postfix);
  14414. }
  14415. catch (Exception)
  14416. {
  14417. jw = JsonView(false);
  14418. }
  14419. return Ok(jw);
  14420. }
  14421. /// <summary>
  14422. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  14423. /// </summary>
  14424. /// <param name="num"></param>
  14425. /// <returns></returns>
  14426. static string GetNum(string num)
  14427. {
  14428. string str = "";
  14429. switch (num)
  14430. {
  14431. case "1":
  14432. str = "一";
  14433. break;
  14434. case "2":
  14435. str = "二";
  14436. break;
  14437. case "3":
  14438. str = "三";
  14439. break;
  14440. case "4":
  14441. str = "四";
  14442. break;
  14443. case "5":
  14444. str = "五";
  14445. break;
  14446. case "6":
  14447. str = "六";
  14448. break;
  14449. case "7":
  14450. str = "七";
  14451. break;
  14452. case "8":
  14453. str = "八";
  14454. break;
  14455. case "9":
  14456. str = "九";
  14457. break;
  14458. case "10":
  14459. str = "十";
  14460. break;
  14461. case "11":
  14462. str = "十一";
  14463. break;
  14464. case "12":
  14465. str = "十二";
  14466. break;
  14467. case "一":
  14468. str = "1";
  14469. break;
  14470. case "二":
  14471. str = "2";
  14472. break;
  14473. case "三":
  14474. str = "3";
  14475. break;
  14476. case "四":
  14477. str = "4";
  14478. break;
  14479. case "五":
  14480. str = "5";
  14481. break;
  14482. case "六":
  14483. str = "6";
  14484. break;
  14485. case "七":
  14486. str = "7";
  14487. break;
  14488. case "八":
  14489. str = "8";
  14490. break;
  14491. case "九":
  14492. str = "9";
  14493. break;
  14494. case "十":
  14495. str = "10";
  14496. break;
  14497. case "十一":
  14498. str = "11";
  14499. break;
  14500. case "十二":
  14501. str = "12";
  14502. break;
  14503. }
  14504. return str;
  14505. }
  14506. /// <summary>
  14507. /// 高亮包含指定文字的部分
  14508. /// </summary>
  14509. /// <param name="run"></param>
  14510. /// <param name="targetText"></param>
  14511. /// <param name="color"></param>
  14512. static void HighlightText(Run run, string targetText, Color color)
  14513. {
  14514. string text = run.Text;
  14515. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14516. if (startIndex >= 0)
  14517. {
  14518. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14519. // 前部分
  14520. if (startIndex > 0)
  14521. {
  14522. Run beforeRun = (Run)run.Clone(true);
  14523. beforeRun.Text = text.Substring(0, startIndex);
  14524. parentParagraph.InsertBefore(beforeRun, run);
  14525. }
  14526. // 匹配部分
  14527. Run matchRun = (Run)run.Clone(true);
  14528. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14529. matchRun.Font.Color = color;
  14530. parentParagraph.InsertBefore(matchRun, run);
  14531. // 后部分
  14532. if (startIndex + targetText.Length < text.Length)
  14533. {
  14534. Run afterRun = (Run)run.Clone(true);
  14535. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14536. parentParagraph.InsertBefore(afterRun, run);
  14537. }
  14538. // 删除原始Run
  14539. run.Remove();
  14540. }
  14541. }
  14542. #endregion
  14543. #endregion
  14544. #region 团组成本
  14545. /// <summary>
  14546. /// 团组成本数据初始化
  14547. /// </summary>
  14548. /// <param name="dto"></param>
  14549. /// <returns></returns>
  14550. [HttpPost]
  14551. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14552. {
  14553. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14554. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14555. WHEN COUNT(*) >= 0 THEN 'True'
  14556. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14557. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14558. ").ToList(); //团组列表
  14559. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14560. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14561. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14562. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14563. if (groupinfoValue != null)
  14564. {
  14565. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14566. var spArr = new string[1] { countryArr };
  14567. if (countryArr.Contains("|"))
  14568. {
  14569. spArr = countryArr.Split("|");
  14570. }
  14571. else if (countryArr.Contains("、"))
  14572. {
  14573. spArr = countryArr.Split("、");
  14574. }
  14575. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14576. {
  14577. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14578. if (dbQueryCountry != null)
  14579. {
  14580. visaCountryInfoArr.Add(dbQueryCountry);
  14581. }
  14582. }
  14583. }
  14584. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14585. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14586. #region 屏蔽黑屏代码生成
  14587. //var create = _GroupCostRepository.
  14588. // CreateGroupCostByBlackCode(dto.Diid);
  14589. //if (groupCost.Count == 0 && create.Code == 0)
  14590. //{
  14591. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14592. //}
  14593. #endregion
  14594. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14595. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14596. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14597. groupCostMap = groupCostMap.Select(x =>
  14598. {
  14599. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14600. {
  14601. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14602. }
  14603. return x;
  14604. }).ToList();
  14605. //GroupCostParameter.Add(new
  14606. // Grp_GroupCostParameter());
  14607. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14608. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14609. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14610. return Ok(JsonView(new
  14611. {
  14612. groupList,
  14613. groupInfo,
  14614. groupChecks,
  14615. groupCost = groupCostMap,
  14616. hotelNumber,
  14617. GroupCostParameter = GroupCostParameterMap,
  14618. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14619. {
  14620. x.VisaCountry,
  14621. x.VisaPrice,
  14622. x.Id,
  14623. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14624. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14625. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14626. x.VisaTime, // 一般签证时间
  14627. x.PettyBusinessAgencyFee, //小公务代办费
  14628. x.GrandBusinessAgencyFee //大公务代办费
  14629. }).ToList(),
  14630. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14631. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14632. hotelIsTrue,
  14633. groupModuleOperators
  14634. }));
  14635. }
  14636. /// <summary>
  14637. /// 团组成本信息保存
  14638. /// </summary>
  14639. /// <param name="dto"></param>
  14640. /// <returns></returns>
  14641. [HttpPost]
  14642. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14643. {
  14644. if (dto.Diid <= 0 || dto.Userid <= 0)
  14645. {
  14646. return Ok(JsonView(false));
  14647. }
  14648. JsonView jw = null;
  14649. bool isTrue = false;
  14650. #region 复制团组成本
  14651. //if (dto.Diid == 2581)
  14652. //{
  14653. // dto.Diid = 2599;
  14654. // dto.CheckBoxs.ForEach(x =>
  14655. // {
  14656. // x.Diid = 2599;
  14657. // });
  14658. // dto.GroupCosts.ForEach(x =>
  14659. // {
  14660. // x.Diid = 2599;
  14661. // });
  14662. // dto.CostTypeHotelNumbers.ForEach(x =>
  14663. // {
  14664. // x.Diid = 2599;
  14665. // });
  14666. // dto.GroupCostParameters.ForEach(x =>
  14667. // {
  14668. // x.DiId = 2599;
  14669. // });
  14670. //}
  14671. #endregion
  14672. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14673. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14674. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14675. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14676. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14677. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14678. try
  14679. {
  14680. _sqlSugar.BeginTran();
  14681. isTrue = await _GroupCostRepository.
  14682. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14683. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14684. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14685. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14686. _sqlSugar.CommitTran();
  14687. jw = JsonView(true, "保存成功!", isTrue);
  14688. }
  14689. catch (Exception)
  14690. {
  14691. _sqlSugar.RollbackTran();
  14692. jw = JsonView(false);
  14693. }
  14694. return Ok(jw);
  14695. }
  14696. /// <summary>
  14697. /// 复制团组成本信息
  14698. /// </summary>
  14699. /// <param name="dto"></param>
  14700. /// <returns></returns>
  14701. [HttpPost]
  14702. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14703. {
  14704. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14705. {
  14706. return Ok(JsonView(false, "参数有误!"));
  14707. }
  14708. #region 复制团组成本
  14709. dto.Diid = dto.ToGroupId;
  14710. dto.CheckBoxs.ForEach(x =>
  14711. {
  14712. x.Diid = dto.ToGroupId;
  14713. });
  14714. dto.GroupCosts.ForEach(x =>
  14715. {
  14716. x.Diid = dto.ToGroupId;
  14717. });
  14718. dto.CostTypeHotelNumbers.ForEach(x =>
  14719. {
  14720. x.Diid = dto.ToGroupId;
  14721. });
  14722. dto.GroupCostParameters.ForEach(x =>
  14723. {
  14724. x.DiId = dto.ToGroupId;
  14725. });
  14726. #endregion
  14727. JsonView jw = null;
  14728. bool isTrue = false;
  14729. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14730. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14731. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14732. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14733. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14734. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14735. try
  14736. {
  14737. _sqlSugar.BeginTran();
  14738. isTrue = await _GroupCostRepository.
  14739. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14740. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14741. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14742. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14743. _sqlSugar.CommitTran();
  14744. jw = JsonView(true, "保存成功!", isTrue);
  14745. }
  14746. catch (Exception)
  14747. {
  14748. _sqlSugar.RollbackTran();
  14749. jw = JsonView(false);
  14750. }
  14751. return Ok(jw);
  14752. }
  14753. /// <summary>
  14754. /// 司兼导数据
  14755. /// </summary>
  14756. /// <param name="dto"></param>
  14757. /// <returns></returns>
  14758. [HttpPost]
  14759. public IActionResult GetCarGuides(CarGuidesDto dto)
  14760. {
  14761. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14762. return Ok(JsonView(true, "获取成功!", Data));
  14763. }
  14764. /// <summary>
  14765. /// 导游数据
  14766. /// </summary>
  14767. /// <param name="dto"></param>
  14768. /// <returns></returns>
  14769. [HttpPost]
  14770. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14771. {
  14772. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14773. // 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
  14774. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14775. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14776. return Ok(JsonView(true, "获取成功!", Data));
  14777. }
  14778. /// <summary>
  14779. /// 成本车数据
  14780. /// </summary>
  14781. /// <param name="dto"></param>
  14782. /// <returns></returns>
  14783. [HttpPost]
  14784. public IActionResult GetCarInfo(CarGuidesDto dto)
  14785. {
  14786. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14787. return Ok(JsonView(true, "获取成功!", Data));
  14788. }
  14789. /// <summary>
  14790. /// 景点数据
  14791. /// </summary>
  14792. /// <param name="dto"></param>
  14793. /// <returns></returns>
  14794. [HttpPost]
  14795. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14796. {
  14797. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14798. return Ok(JsonView(true, "获取成功!", Data));
  14799. }
  14800. /// <summary>
  14801. /// 成本通知
  14802. /// </summary>
  14803. /// <param name="dto"></param>
  14804. /// <returns></returns>
  14805. [HttpPost]
  14806. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14807. {
  14808. if (dto.Diid < 0)
  14809. {
  14810. return Ok(JsonView(false));
  14811. }
  14812. JsonView jw;
  14813. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14814. if (GroupCostParameter != null)
  14815. {
  14816. int IsShare = 0;
  14817. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14818. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14819. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14820. string msg = string.Empty;
  14821. if (isTrue)
  14822. {
  14823. if (IsShare == 0)
  14824. {
  14825. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14826. }
  14827. else
  14828. {
  14829. #region 企微通知对应岗位用户
  14830. try
  14831. {
  14832. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14833. }
  14834. catch (Exception)
  14835. {
  14836. }
  14837. #endregion
  14838. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14839. }
  14840. jw = JsonView(isTrue, msg, new { IsShare });
  14841. }
  14842. else
  14843. {
  14844. msg = "修改失败!";
  14845. jw = JsonView(isTrue, msg);
  14846. }
  14847. }
  14848. else
  14849. {
  14850. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14851. }
  14852. return Ok(jw);
  14853. }
  14854. /// <summary>
  14855. /// 导出报价单
  14856. /// </summary>
  14857. /// <param name="dto"></param>
  14858. /// <returns></returns>
  14859. [HttpPost]
  14860. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14861. {
  14862. if (dto.Diid == 0)
  14863. {
  14864. return Ok(JsonView(false, "请传递团组id"));
  14865. }
  14866. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14867. if (deleInfo.Code != 0)
  14868. {
  14869. return Ok(JsonView(false, "团组信息查询失败!"));
  14870. }
  14871. var di = deleInfo.Data as DelegationInfoWebView;
  14872. if (di != null)
  14873. {
  14874. di.TeamName = di.TeamName.Replace("|", "、");
  14875. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14876. //文件名
  14877. string strFileName = di.TeamName + "-收款账单.doc";
  14878. //获取模板
  14879. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14880. //载入模板
  14881. Document doc = new Document(tmppath);
  14882. decimal TotalPrice = 0.00M;
  14883. string itemStr = string.Empty;
  14884. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14885. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14886. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14887. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14888. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14889. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14890. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14891. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14892. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14893. foreach (var cost in groupCostType)
  14894. {
  14895. var List = cost.ToList();
  14896. if (cost.Key == "A")
  14897. {
  14898. foreach (var ListItem in List)
  14899. {
  14900. if (ListItem.number > 0)
  14901. {
  14902. if (ListItem.code.Contains("TBR"))
  14903. {
  14904. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14905. }
  14906. else
  14907. {
  14908. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14909. }
  14910. TotalPrice += (ListItem.number * ListItem.price);
  14911. }
  14912. }
  14913. }
  14914. else
  14915. {
  14916. itemStr = itemStr.Insert(0, "A段\r\n");
  14917. itemStr += "B段\r\n";
  14918. foreach (var ListItem in List)
  14919. {
  14920. if (ListItem.number > 0)
  14921. {
  14922. if (ListItem.code.Contains("TBR"))
  14923. {
  14924. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14925. }
  14926. else
  14927. {
  14928. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14929. }
  14930. TotalPrice += (ListItem.number * ListItem.price);
  14931. }
  14932. }
  14933. }
  14934. }
  14935. #region 替换Word模板书签内容
  14936. Dictionary<string, string> marks = new Dictionary<string, string>();
  14937. marks.Add("To", di.ClientUnit);//付款方
  14938. marks.Add("ToTel", di.TellPhone);//付款方电话
  14939. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14940. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14941. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14942. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14943. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14944. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14945. marks.Add("PayItemContent", itemStr);//详细信息
  14946. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14947. #endregion
  14948. ////注
  14949. //if (doc.Range.Bookmarks["Attention"] != null)
  14950. //{
  14951. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14952. // mark.Text = frList[0].Attention;
  14953. //}
  14954. foreach (var item in marks.Keys)
  14955. {
  14956. if (doc.Range.Bookmarks[item] != null)
  14957. {
  14958. Bookmark mark = doc.Range.Bookmarks[item];
  14959. mark.Text = marks[item];
  14960. }
  14961. }
  14962. byte[] bytes = null;
  14963. using (MemoryStream stream = new MemoryStream())
  14964. {
  14965. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14966. bytes = stream.ToArray();
  14967. }
  14968. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14969. return Ok(JsonView(true, "", new
  14970. {
  14971. Data = bytes,
  14972. strFileName,
  14973. }));
  14974. }
  14975. else
  14976. {
  14977. return Ok(JsonView(false, "团组信息不存在!"));
  14978. }
  14979. }
  14980. /// <summary>
  14981. /// 导出团组成本
  14982. /// </summary>
  14983. /// <param name="dto"></param>
  14984. /// <returns></returns>
  14985. [HttpPost]
  14986. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14987. {
  14988. var jw = JsonView(false);
  14989. if (dto.Diid == 0)
  14990. {
  14991. return Ok(JsonView(false, "请传递团组id"));
  14992. }
  14993. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14994. if (deleInfo.Code != 0)
  14995. {
  14996. return Ok(JsonView(false, "团组信息查询失败!"));
  14997. }
  14998. var di = deleInfo.Data as DelegationInfoWebView;
  14999. if (di == null)
  15000. {
  15001. return Ok(JsonView(false, "团组信息查询失败!"));
  15002. }
  15003. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  15004. WorkbookDesigner designer = new WorkbookDesigner();
  15005. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  15006. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  15007. List<int> hideColumnList = new List<int>();
  15008. var ColumnSetting = new[]
  15009. {
  15010. new { tag = "VF", Index = 4, P = "CarCost" },
  15011. new { tag = "VN", Index = 5, P = "CarNumber" },
  15012. new { tag = "VRD", Index = 6, P = "CarTiming" },
  15013. new { tag = "T/G S", Index = 7, P = "TGS" },
  15014. new { tag = "TGWH", Index = 8, P = "TGWH" },
  15015. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  15016. new { tag = "T/G M", Index = 10, P = "TGM" },
  15017. new { tag = "T/G A", Index = 11, P = "TGA" },
  15018. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  15019. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  15020. new { tag = "C/F S", Index = 14, P = "CFS" },
  15021. new { tag = "C/F M", Index = 15, P = "CFM" },
  15022. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  15023. new { tag = "B", Index = 17, P = "B" },
  15024. new { tag = "L", Index = 18, P = "L" },
  15025. new { tag = "D", Index = 19, P = "D" },
  15026. new { tag = "TBR", Index = 20, P = "TBR" },
  15027. new { tag = "SGR", Index = 21, P = "SGR" },
  15028. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  15029. new { tag = "Suite", Index = 23, P = "Suite" },
  15030. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  15031. new { tag = "T/V", Index = 25, P = "TV" },
  15032. new { tag = "1/L", Index = 26, P = "iL" },
  15033. new { tag = "I/F", Index = 27, P = "IF" },
  15034. new { tag = "EF", Index = 28, P = "EF" },
  15035. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  15036. new { tag = "TE", Index = 30, P = "TE" },
  15037. new { tag = "T/G T", Index = 31, P = "TGTips" },
  15038. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  15039. new { tag = "P/C", Index = 33, P = "PC" },
  15040. new { tag = "T/L F", Index = 34, P = "TLF" },
  15041. new { tag = "E/C T", Index = 35, P = "ECT" }
  15042. };
  15043. Func<string, bool> isEmpty = (str) =>
  15044. {
  15045. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  15046. {
  15047. return true;
  15048. }
  15049. if (string.IsNullOrWhiteSpace(str))
  15050. {
  15051. return true;
  15052. }
  15053. return false;
  15054. };
  15055. for (int i = 0; i < List_GC.Count; i++)
  15056. {
  15057. GroupCost_Excel gc = new GroupCost_Excel();
  15058. gc.Id = List_GC[i].Id;
  15059. gc.Diid = List_GC[i].Diid.ToString();
  15060. gc.DAY = List_GC[i].DAY;
  15061. string week = "";
  15062. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  15063. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  15064. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  15065. gc.ITIN = List_GC[i].ITIN;
  15066. gc.CarType = List_GC[i].CarType;
  15067. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  15068. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  15069. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  15070. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  15071. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  15072. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  15073. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  15074. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  15075. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  15076. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  15077. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  15078. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  15079. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  15080. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  15081. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  15082. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  15083. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  15084. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  15085. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  15086. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  15087. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  15088. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  15089. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  15090. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  15091. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  15092. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  15093. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  15094. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  15095. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  15096. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  15097. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  15098. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  15099. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  15100. gc.EFR = List_GC[i].EFR;
  15101. List_GC1.Add(gc);
  15102. }
  15103. if (List_GC1.Count > 0)
  15104. {
  15105. var p = List_GC1[0];
  15106. var prs = p.GetType().GetProperties();
  15107. foreach (var item in prs)
  15108. {
  15109. var tp = item.PropertyType;
  15110. if (tp == typeof(int))
  15111. {
  15112. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  15113. if (val == 0)
  15114. {
  15115. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15116. if (columnSetting != null)
  15117. {
  15118. hideColumnList.Add(columnSetting.Index);
  15119. }
  15120. }
  15121. }
  15122. if (tp == typeof(decimal))
  15123. {
  15124. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  15125. if (val == 0)
  15126. {
  15127. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15128. if (columnSetting != null)
  15129. {
  15130. hideColumnList.Add(columnSetting.Index);
  15131. }
  15132. }
  15133. }
  15134. if (tp == typeof(string))
  15135. {
  15136. var val = List_GC1.Sum(x =>
  15137. {
  15138. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  15139. if (decimal.TryParse(str, out decimal str_De))
  15140. {
  15141. return str_De;
  15142. }
  15143. else
  15144. {
  15145. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  15146. }
  15147. });
  15148. if (val == 0)
  15149. {
  15150. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15151. if (columnSetting != null)
  15152. {
  15153. hideColumnList.Add(columnSetting.Index);
  15154. }
  15155. }
  15156. }
  15157. }
  15158. }
  15159. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  15160. dt.TableName = "TB";
  15161. //报表标题等不用dt的值
  15162. designer.SetDataSource("TeamName", dto.title.TeamName);
  15163. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  15164. designer.SetDataSource("Tax", dto.title.Tax);
  15165. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  15166. designer.SetDataSource("Currency", dto.title.Currency);
  15167. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  15168. designer.SetDataSource("Rate", dto.title.Rate);
  15169. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  15170. var Aparams = hotels.Find(x => x.Type == "Default");
  15171. if (Aparams == null)
  15172. {
  15173. return Ok(jw);
  15174. }
  15175. //酒店数量
  15176. var txtSGRNumber = Aparams.SGR.ToString();
  15177. var txtTBRNumber = Aparams.TBR.ToString();
  15178. var txtJSESNumber = Aparams.JSES.ToString();
  15179. var txtSUITENumbe = Aparams.SUITE.ToString();
  15180. if (dto.costType == "B")
  15181. {
  15182. Aparams = hotels.Find(x => x.Type == "A");
  15183. var Bparams = hotels.Find(x => x.Type == "B");
  15184. if (Aparams == null || Bparams == null)
  15185. {
  15186. return Ok(jw);
  15187. }
  15188. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  15189. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  15190. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  15191. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  15192. }
  15193. designer.SetDataSource("SGRNumber", txtSGRNumber);
  15194. designer.SetDataSource("TBRNumber", txtTBRNumber);
  15195. designer.SetDataSource("JSESNumber", txtJSESNumber);
  15196. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  15197. var ws = designer.Workbook.Worksheets[1];
  15198. int Row = List_GC.Count;
  15199. int startIndex = 0;
  15200. int HideRows = 0;
  15201. Row = 0;
  15202. List<int> hideRowsList = new List<int>();
  15203. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  15204. #region A段left数据
  15205. var left = dto.leftInfo.Find(x => x.Type == "A");
  15206. if (left == null)
  15207. {
  15208. return Ok(jw);
  15209. }
  15210. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  15211. if (leftBindData != null)
  15212. {
  15213. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  15214. designer.SetDataSource("VisaRS", leftBindData.rs);
  15215. designer.SetDataSource("VisaXS", leftBindData.xs);
  15216. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15217. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15218. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15219. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15220. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15221. }
  15222. else
  15223. {
  15224. hideRowsList.Add(Row + startIndex + HideRows);
  15225. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15226. }
  15227. HideRows += 2;
  15228. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  15229. if (leftBindData != null)
  15230. {
  15231. designer.SetDataSource("BXDRCB", leftBindData.cb);
  15232. designer.SetDataSource("BXRS", leftBindData.rs);
  15233. designer.SetDataSource("BXXS", leftBindData.xs);
  15234. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15235. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15236. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15237. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15238. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15239. }
  15240. else
  15241. {
  15242. hideRowsList.Add(Row + startIndex + HideRows);
  15243. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15244. }
  15245. HideRows += 2;
  15246. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15247. if (leftBindData != null)
  15248. {
  15249. designer.SetDataSource("HSDRCB", leftBindData.cb);
  15250. designer.SetDataSource("HSRS", leftBindData.rs);
  15251. designer.SetDataSource("HSXS", leftBindData.xs);
  15252. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15253. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15254. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15255. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15256. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15257. }
  15258. else
  15259. {
  15260. hideRowsList.Add(Row + startIndex + HideRows);
  15261. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15262. }
  15263. HideRows += 2;
  15264. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15265. if (leftBindData != null)
  15266. {
  15267. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  15268. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  15269. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  15270. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15271. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15272. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15273. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15274. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15275. }
  15276. else
  15277. {
  15278. hideRowsList.Add(Row + startIndex + HideRows);
  15279. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15280. }
  15281. HideRows += 2;
  15282. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15283. if (leftBindData != null)
  15284. {
  15285. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  15286. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  15287. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  15288. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15289. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15290. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15291. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15292. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15293. }
  15294. else
  15295. {
  15296. hideRowsList.Add(Row + startIndex + HideRows);
  15297. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15298. }
  15299. HideRows += 2;
  15300. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15301. if (leftBindData != null)
  15302. {
  15303. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  15304. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  15305. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  15306. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15307. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15308. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15309. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15310. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15311. }
  15312. else
  15313. {
  15314. hideRowsList.Add(Row + startIndex + HideRows);
  15315. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15316. }
  15317. HideRows += 2;
  15318. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15319. if (leftBindData != null)
  15320. {
  15321. ////TBR
  15322. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  15323. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  15324. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  15325. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15326. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15327. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15328. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15329. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15330. }
  15331. else
  15332. {
  15333. hideRowsList.Add(Row + startIndex + HideRows);
  15334. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15335. }
  15336. HideRows += 2;
  15337. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15338. if (leftBindData != null)
  15339. {
  15340. ////SGR
  15341. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  15342. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  15343. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  15344. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15345. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15346. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15347. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15348. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15349. }
  15350. else
  15351. {
  15352. hideRowsList.Add(Row + startIndex + HideRows);
  15353. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15354. }
  15355. HideRows += 2;
  15356. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15357. if (leftBindData != null)
  15358. {
  15359. ////JS/ES
  15360. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  15361. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  15362. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  15363. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15364. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15365. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15366. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15367. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15368. }
  15369. else
  15370. {
  15371. hideRowsList.Add(Row + startIndex + HideRows);
  15372. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15373. }
  15374. HideRows += 2;
  15375. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15376. if (leftBindData != null)
  15377. {
  15378. ////SUITE
  15379. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  15380. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  15381. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  15382. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15383. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15384. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15385. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15386. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15387. }
  15388. else
  15389. {
  15390. hideRowsList.Add(Row + startIndex + HideRows);
  15391. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15392. }
  15393. HideRows += 2;
  15394. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15395. if (leftBindData != null)
  15396. {
  15397. designer.SetDataSource("DJDRCB", leftBindData.cb);
  15398. designer.SetDataSource("DJRS", leftBindData.rs);
  15399. designer.SetDataSource("DJXS", leftBindData.xs);
  15400. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15401. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15402. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15403. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15404. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15405. }
  15406. else
  15407. {
  15408. hideRowsList.Add(Row + startIndex + HideRows);
  15409. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15410. }
  15411. HideRows += 2;
  15412. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15413. if (leftBindData != null)
  15414. {
  15415. designer.SetDataSource("HCPCB", leftBindData.cb);
  15416. designer.SetDataSource("HCPRS", leftBindData.rs);
  15417. designer.SetDataSource("HCPXS", leftBindData.xs);
  15418. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15419. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15420. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15421. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15422. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15423. }
  15424. else
  15425. {
  15426. hideRowsList.Add(Row + startIndex + HideRows);
  15427. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15428. }
  15429. HideRows += 2;
  15430. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15431. if (leftBindData != null)
  15432. {
  15433. designer.SetDataSource("CPCB", leftBindData.cb);
  15434. designer.SetDataSource("CPRS", leftBindData.rs);
  15435. designer.SetDataSource("CPXS", leftBindData.xs);
  15436. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15437. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15438. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15439. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15440. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15441. }
  15442. else
  15443. {
  15444. hideRowsList.Add(Row + startIndex + HideRows);
  15445. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15446. }
  15447. HideRows += 2;
  15448. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15449. if (leftBindData != null)
  15450. {
  15451. designer.SetDataSource("GWDRCD", leftBindData.cb);
  15452. designer.SetDataSource("GWRS", leftBindData.rs);
  15453. designer.SetDataSource("GWXS", leftBindData.xs);
  15454. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15455. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15456. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15457. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15458. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15459. }
  15460. else
  15461. {
  15462. hideRowsList.Add(Row + startIndex + HideRows);
  15463. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15464. }
  15465. HideRows += 2;
  15466. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15467. if (leftBindData != null)
  15468. {
  15469. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  15470. designer.SetDataSource("LYJRS", leftBindData.rs);
  15471. designer.SetDataSource("LYJXS", leftBindData.xs);
  15472. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15473. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15474. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15475. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15476. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15477. }
  15478. else
  15479. {
  15480. hideRowsList.Add(Row + startIndex + HideRows);
  15481. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15482. }
  15483. #endregion
  15484. #region A段Right信息
  15485. var right = dto.rightInfo.Find(x => x.Type == "A");
  15486. if (right == null)
  15487. {
  15488. return Ok(jw);
  15489. }
  15490. HideRows += 4;
  15491. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15492. if (rightBindData != null)
  15493. {
  15494. //经济舱 + 双人间 TBR
  15495. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  15496. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  15497. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15498. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  15499. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15500. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15501. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15502. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15503. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15504. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15505. }
  15506. else
  15507. {
  15508. hideRowsList.Add(Row + startIndex + HideRows);
  15509. }
  15510. HideRows += 2;
  15511. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15512. if (rightBindData != null)
  15513. {
  15514. //经济舱 + 单人间 SGR
  15515. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  15516. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  15517. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15518. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  15519. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15520. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15521. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15522. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15523. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15524. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15525. }
  15526. else
  15527. {
  15528. hideRowsList.Add(Row + startIndex + HideRows);
  15529. }
  15530. HideRows += 2;
  15531. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15532. if (rightBindData != null)
  15533. {
  15534. //公务舱 + 单人间 SGR
  15535. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  15536. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  15537. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15538. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  15539. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15540. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15541. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15542. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15543. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15544. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15545. }
  15546. else
  15547. {
  15548. hideRowsList.Add(Row + startIndex + HideRows);
  15549. }
  15550. HideRows += 2;
  15551. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15552. if (rightBindData != null)
  15553. {
  15554. //公务舱 + 小套房 JSES
  15555. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  15556. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  15557. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15558. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  15559. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15560. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15561. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15562. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15563. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15564. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15565. }
  15566. else
  15567. {
  15568. hideRowsList.Add(Row + startIndex + HideRows);
  15569. }
  15570. HideRows += 2;
  15571. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15572. if (rightBindData != null)
  15573. {
  15574. //公务舱 + 小套房 JSES
  15575. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  15576. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  15577. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15578. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  15579. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15580. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15581. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15582. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15583. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15584. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15585. }
  15586. else
  15587. {
  15588. hideRowsList.Add(Row + startIndex + HideRows);
  15589. }
  15590. HideRows += 2;
  15591. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15592. if (rightBindData != null)
  15593. {
  15594. //经济舱 + 大套房
  15595. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15596. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15597. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15598. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15599. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15600. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15601. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15602. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15603. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15604. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15605. }
  15606. else
  15607. {
  15608. hideRowsList.Add(Row + startIndex + HideRows);
  15609. }
  15610. HideRows += 2;
  15611. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15612. if (rightBindData != null)
  15613. {
  15614. //头等舱 + 小套房 JSES
  15615. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15616. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15617. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15618. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15619. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15620. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15621. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15622. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15623. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15624. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15625. }
  15626. else
  15627. {
  15628. hideRowsList.Add(Row + startIndex + HideRows);
  15629. }
  15630. HideRows += 2;
  15631. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15632. if (rightBindData != null)
  15633. {
  15634. //头等舱 + 大套房
  15635. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15636. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15637. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15638. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15639. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15640. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15641. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15642. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15643. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15644. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15645. }
  15646. else
  15647. {
  15648. hideRowsList.Add(Row + startIndex + HideRows);
  15649. }
  15650. #endregion
  15651. #region B段标题清空
  15652. designer.SetDataSource("CostBDRCB", "");
  15653. designer.SetDataSource("CostBRS", "");
  15654. designer.SetDataSource("CostBXS", "");
  15655. designer.SetDataSource("CostBZCB", "");
  15656. designer.SetDataSource("CostBDRBJ", "");
  15657. designer.SetDataSource("CostBZBJ", "");
  15658. designer.SetDataSource("CostBDRLR", "");
  15659. designer.SetDataSource("CostBZLR", "");
  15660. designer.SetDataSource("CostBDRCBOM", "");
  15661. designer.SetDataSource("CostBRSOM", "");
  15662. designer.SetDataSource("CostBZCBOM", "");
  15663. designer.SetDataSource("CostBDRBJOM", "");
  15664. designer.SetDataSource("CostBZBJOM", "");
  15665. designer.SetDataSource("CostBDRLROM", "");
  15666. designer.SetDataSource("CostBZLROM", "");
  15667. #endregion
  15668. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15669. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15670. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15671. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15672. designer.SetDataSource("DJName", "地接(CNY)");
  15673. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15674. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15675. designer.SetDataSource("GWName", "公务(CNY)");
  15676. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15677. designer.SetDataSource("LYJName", "零用金(CNY)");
  15678. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15679. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15680. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15681. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15682. designer.SetDataSource("BXName", "保险(CNY)");
  15683. designer.SetDataSource("VisaName", "签证(CNY)");
  15684. #region B段基本数据
  15685. if (dto.costType == "B")
  15686. {
  15687. left = dto.leftInfo.Find(x => x.Type == "B");
  15688. if (left == null)
  15689. {
  15690. return Ok(jw);
  15691. }
  15692. #region B段left数据
  15693. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15694. if (leftBindData != null)
  15695. {
  15696. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15697. designer.SetDataSource("BHSRS", leftBindData.rs);
  15698. designer.SetDataSource("BHSXS", leftBindData.xs);
  15699. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15700. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15701. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15702. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15703. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15704. }
  15705. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15706. if (leftBindData != null)
  15707. {
  15708. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15709. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15710. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15711. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15712. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15713. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15714. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15715. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15716. }
  15717. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15718. if (leftBindData != null)
  15719. {
  15720. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15721. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15722. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15723. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15724. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15725. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15726. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15727. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15728. }
  15729. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15730. if (leftBindData != null)
  15731. {
  15732. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15733. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15734. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15735. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15736. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15737. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15738. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15739. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15740. }
  15741. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15742. if (leftBindData != null)
  15743. {
  15744. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15745. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15746. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15747. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15748. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15749. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15750. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15751. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15752. }
  15753. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15754. if (leftBindData != null)
  15755. {
  15756. designer.SetDataSource("BCPCB", leftBindData.cb);
  15757. designer.SetDataSource("BCPRS", leftBindData.rs);
  15758. designer.SetDataSource("BCPXS", leftBindData.xs);
  15759. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15760. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15761. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15762. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15763. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15764. }
  15765. //TBR
  15766. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15767. if (leftBindData != null)
  15768. {
  15769. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15770. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15771. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15772. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15773. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15774. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15775. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15776. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15777. }
  15778. //SGR
  15779. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15780. if (leftBindData != null)
  15781. {
  15782. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15783. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15784. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15785. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15786. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15787. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15788. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15789. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15790. }
  15791. //JS/ES
  15792. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15793. if (leftBindData != null)
  15794. {
  15795. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15796. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15797. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15798. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15799. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15800. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15801. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15802. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15803. }
  15804. //SUITE
  15805. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15806. if (leftBindData != null)
  15807. {
  15808. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15809. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15810. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15811. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15812. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15813. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15814. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15815. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15816. }
  15817. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15818. if (leftBindData != null)
  15819. {
  15820. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15821. designer.SetDataSource("BDJRS", leftBindData.rs);
  15822. designer.SetDataSource("BDJXS", leftBindData.xs);
  15823. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15824. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15825. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15826. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15827. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15828. }
  15829. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15830. if (leftBindData != null)
  15831. {
  15832. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15833. designer.SetDataSource("BGWRS", leftBindData.rs);
  15834. designer.SetDataSource("BGWXS", leftBindData.xs);
  15835. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15836. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15837. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15838. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15839. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15840. }
  15841. #region 优化方案
  15842. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15843. //excelBind.Add("零用金", new {
  15844. //cb="",
  15845. //rs="",
  15846. //xs ="",
  15847. //zcb = "",
  15848. //});
  15849. #endregion
  15850. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15851. if (leftBindData != null)
  15852. {
  15853. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15854. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15855. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15856. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15857. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15858. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15859. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15860. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15861. }
  15862. #endregion
  15863. #region B段Right信息
  15864. right = dto.rightInfo.Find(x => x.Type == "B");
  15865. if (right == null)
  15866. {
  15867. return Ok(jw);
  15868. }
  15869. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15870. if (rightBindData != null)
  15871. {
  15872. //经济舱 + 双人间 TBR
  15873. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15874. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15875. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15876. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15877. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15878. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15879. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15880. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15881. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15882. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15883. }
  15884. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15885. if (rightBindData != null)
  15886. {
  15887. //经济舱 + 单人间 SGR
  15888. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15889. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15890. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15891. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15892. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15893. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15894. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15895. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15896. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15897. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15898. }
  15899. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15900. if (rightBindData != null)
  15901. {
  15902. //公务舱 + 单人间 SGR
  15903. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15904. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15905. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15906. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15907. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15908. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15909. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15910. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15911. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15912. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15913. }
  15914. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15915. if (rightBindData != null)
  15916. {
  15917. //公务舱 + 小套房 JSES
  15918. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15919. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15920. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15921. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15922. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15923. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15924. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15925. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15926. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15927. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15928. }
  15929. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15930. if (rightBindData != null)
  15931. {
  15932. //公务舱 + 小套房 JSES
  15933. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15934. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15935. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15936. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15937. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15938. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15939. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15940. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15941. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15942. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15943. }
  15944. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15945. if (rightBindData != null)
  15946. {
  15947. //经济舱 + 大套房
  15948. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15949. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15950. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15951. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15952. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15953. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15954. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15955. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15956. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15957. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15958. }
  15959. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15960. if (rightBindData != null)
  15961. {
  15962. //头等舱 + 小套房 JSES
  15963. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15964. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15965. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15966. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15967. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15968. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15969. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15970. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15971. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15972. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15973. }
  15974. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15975. if (rightBindData != null)
  15976. {
  15977. //头等舱 + 大套房
  15978. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15979. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15980. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15981. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15982. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15983. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15984. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15985. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15986. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15987. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15988. }
  15989. #endregion
  15990. #region 标题
  15991. designer.SetDataSource("CostBDRCB", "单人成本");
  15992. designer.SetDataSource("CostBRS", "人数");
  15993. designer.SetDataSource("CostBXS", "系数");
  15994. designer.SetDataSource("CostBZCB", "总成本");
  15995. designer.SetDataSource("CostBDRBJ", "单人报价");
  15996. designer.SetDataSource("CostBZBJ", "总报价");
  15997. designer.SetDataSource("CostBDRLR", "单人利润");
  15998. designer.SetDataSource("CostBZLR", "总利润");
  15999. designer.SetDataSource("CostBDRCBOM", "单人成本");
  16000. designer.SetDataSource("CostBRSOM", "人数");
  16001. designer.SetDataSource("CostBZCBOM", "总成本");
  16002. designer.SetDataSource("CostBDRBJOM", "单人报价");
  16003. designer.SetDataSource("CostBZBJOM", "总报价");
  16004. designer.SetDataSource("CostBDRLROM", "单人利润");
  16005. designer.SetDataSource("CostBZLROM", "总利润");
  16006. #endregion
  16007. }
  16008. #endregion
  16009. designer.SetDataSource("TzZCB2", TzZCB2);
  16010. designer.SetDataSource("TzZBJ2", TzZBJ2);
  16011. designer.SetDataSource("TzZLR2", TzZLR2);
  16012. string[] dataSourceKeys = new string[]
  16013. {
  16014. "VF",
  16015. "TGS",
  16016. "TGOF",
  16017. "TGM",
  16018. "TGA",
  16019. "TGTF",
  16020. "TGEF",
  16021. "CFM",
  16022. "CFOF",
  16023. "B",
  16024. "L",
  16025. "D",
  16026. "TBR",
  16027. "SGR",
  16028. "JSES",
  16029. "Suite",
  16030. "TV",
  16031. "1L",
  16032. "IF",
  16033. "EF",
  16034. "BRF",
  16035. "TE",
  16036. "TGT",
  16037. "DRVT",
  16038. "PC",
  16039. "TLF",
  16040. "ECT"
  16041. };
  16042. foreach (var item in dataSourceKeys)
  16043. {
  16044. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  16045. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  16046. var find = dto.titleModel.FirstOrDefault(expr);
  16047. if (find != null)
  16048. {
  16049. designer.SetDataSource(item, find.text);
  16050. }
  16051. else
  16052. {
  16053. designer.SetDataSource(item, 0);
  16054. }
  16055. }
  16056. designer.SetDataSource(dt);
  16057. //根据数据源处理生成报表内容
  16058. designer.Process();
  16059. designer.Workbook.Worksheets[0].Name = "费用明细";
  16060. designer.Workbook.Worksheets[1].Name = "费用总核算";
  16061. Worksheet sheet = designer.Workbook.Worksheets[0];
  16062. #region 隐藏舱位
  16063. var settingAir = new[]
  16064. {
  16065. new { key = "经济舱", index = 7 },
  16066. new { key = "公务舱", index = 19 },
  16067. new { key = "头等舱", index = 11 }
  16068. };
  16069. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  16070. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  16071. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  16072. .Select((c, s) => s.Name)
  16073. .ToList()
  16074. .GroupBy(x => x)
  16075. .Select(x => x.Key);
  16076. foreach (var item in settingAir)
  16077. {
  16078. if (!airType.Contains(item.key))
  16079. {
  16080. hideRowsList.Add(item.index);
  16081. }
  16082. }
  16083. #endregion
  16084. foreach (var Rowindex in hideRowsList)
  16085. {
  16086. ws.Cells.HideRows(Rowindex, 2);
  16087. }
  16088. ws = designer.Workbook.Worksheets[0];
  16089. foreach (var Column in hideColumnList)
  16090. {
  16091. ws.Cells.HideColumns(Column, 1);
  16092. }
  16093. byte[] bytes = null;
  16094. string strFileName = di.TeamName + "-团组-成本.xls";
  16095. using (MemoryStream stream = new MemoryStream())
  16096. {
  16097. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  16098. bytes = stream.ToArray();
  16099. }
  16100. return Ok(JsonView(true, "", new
  16101. {
  16102. Data = bytes,
  16103. strFileName,
  16104. }));
  16105. }
  16106. /// <summary>
  16107. /// 导出客户报表
  16108. /// </summary>
  16109. /// <returns></returns>
  16110. [HttpPost]
  16111. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  16112. {
  16113. var jw = JsonView(false);
  16114. if (dto.Diid == 0)
  16115. {
  16116. return Ok(JsonView(false, "请传递团组id"));
  16117. }
  16118. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  16119. if (deleInfo.Code != 0)
  16120. {
  16121. return Ok(JsonView(false, "团组信息查询失败!"));
  16122. }
  16123. var di = deleInfo.Data as DelegationInfoWebView;
  16124. if (di == null)
  16125. {
  16126. return Ok(JsonView(false, "团组信息查询失败!"));
  16127. }
  16128. //文件名
  16129. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  16130. //获取模板
  16131. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  16132. //载入模板
  16133. Document doc = new Document(tmppath);
  16134. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  16135. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  16136. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  16137. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  16138. var AParameter = ParameterList.Find(x => x.CostType == "A");
  16139. var BParameter = ParameterList.Find(x => x.CostType == "B");
  16140. if (AParameter == null)
  16141. {
  16142. return Ok(JsonView(false, "系数不存在!"));
  16143. }
  16144. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  16145. , TzAirDesc, TzZCost;
  16146. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  16147. = TzAirDesc = TzZCost = string.Empty;
  16148. TzNumber = AParameter.CostTypenumber.ToString();
  16149. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  16150. CarGuides1 = dto.CarGuides1;
  16151. Meal = dto.Meal;
  16152. SubsidizedMeals = dto.SubsidizedMeals;
  16153. NightRepair = dto.NightRepair;
  16154. AttractionsTickets = dto.AttractionsTickets;
  16155. MiscellaneousFees = dto.MiscellaneousFees;
  16156. ATip = dto.ATip;
  16157. TzHotelDesc = "";
  16158. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  16159. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  16160. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  16161. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  16162. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  16163. TzAirDesc = "";
  16164. TzZCost = dto.TzZCost;
  16165. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  16166. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  16167. var index = 1;
  16168. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  16169. foreach (var item in TzHotelDescArr)
  16170. {
  16171. if (AinfoArr != null)
  16172. {
  16173. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16174. if (Ainfo != null)
  16175. {
  16176. if (int.Parse(Ainfo.rs) <= 0)
  16177. {
  16178. continue;
  16179. }
  16180. var hotelText = string.Empty;
  16181. switch (item)
  16182. {
  16183. case "SGR":
  16184. hotelText = "单人间";
  16185. break;
  16186. case "JSES":
  16187. hotelText = "小套房";
  16188. break;
  16189. case "SUITE":
  16190. hotelText = "套房";
  16191. break;
  16192. case "TBR":
  16193. hotelText = "双人间";
  16194. break;
  16195. }
  16196. if (item != "TBR")
  16197. {
  16198. 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";
  16199. }
  16200. else
  16201. {
  16202. 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";
  16203. }
  16204. index++;
  16205. }
  16206. }
  16207. }
  16208. index = 1;
  16209. foreach (var item in TzAirDescArr)
  16210. {
  16211. if (AinfoArr != null)
  16212. {
  16213. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16214. if (Ainfo != null)
  16215. {
  16216. if (int.Parse(Ainfo.rs) <= 0)
  16217. {
  16218. continue;
  16219. }
  16220. 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";
  16221. index++;
  16222. }
  16223. }
  16224. }
  16225. if (dto.costType == "B")
  16226. {
  16227. if (BParameter == null)
  16228. {
  16229. return Ok(JsonView(false, "B段系数不存在!"));
  16230. }
  16231. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  16232. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  16233. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  16234. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  16235. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  16236. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  16237. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  16238. foreach (var item in TzHotelDescArr)
  16239. {
  16240. if (AinfoArr != null)
  16241. {
  16242. TzHotelDesc += "B段信息 \r\n";
  16243. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16244. if (Ainfo != null)
  16245. {
  16246. if (int.Parse(Ainfo.rs) <= 0)
  16247. {
  16248. continue;
  16249. }
  16250. var hotelText = string.Empty;
  16251. switch (item)
  16252. {
  16253. case "SGR":
  16254. hotelText = "单人间";
  16255. break;
  16256. case "JSES":
  16257. hotelText = "小套房";
  16258. break;
  16259. case "SUITE":
  16260. hotelText = "套房";
  16261. break;
  16262. case "TBR":
  16263. hotelText = "双人间";
  16264. break;
  16265. }
  16266. if (item != "TBR")
  16267. {
  16268. 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";
  16269. }
  16270. else
  16271. {
  16272. 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";
  16273. }
  16274. index++;
  16275. }
  16276. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  16277. }
  16278. }
  16279. index = 1;
  16280. foreach (var item in TzAirDescArr)
  16281. {
  16282. if (AinfoArr != null)
  16283. {
  16284. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16285. if (Ainfo != null)
  16286. {
  16287. if (int.Parse(Ainfo.rs) <= 0)
  16288. {
  16289. continue;
  16290. }
  16291. 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";
  16292. index++;
  16293. }
  16294. }
  16295. }
  16296. }
  16297. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  16298. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  16299. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  16300. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  16301. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  16302. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  16303. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  16304. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  16305. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  16306. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  16307. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  16308. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  16309. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  16310. DickeyValue.Add("Visa", Visa); // 签证单人报价
  16311. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  16312. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  16313. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  16314. DickeyValue.Add("TzZCost", TzZCost);
  16315. foreach (var key in DickeyValue.Keys)
  16316. {
  16317. if (doc.Range.Bookmarks[key] != null)
  16318. {
  16319. Bookmark mark = doc.Range.Bookmarks[key];
  16320. mark.Text = DickeyValue[key];
  16321. }
  16322. }
  16323. byte[] bytes = null;
  16324. string strFileName = di.TeamName + "-客户报价.doc";
  16325. using (MemoryStream stream = new MemoryStream())
  16326. {
  16327. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  16328. bytes = stream.ToArray();
  16329. }
  16330. return Ok(JsonView(true, "", new
  16331. {
  16332. Data = bytes,
  16333. strFileName,
  16334. }));
  16335. }
  16336. /// <summary>
  16337. /// 团组成本 各模块(酒店,地接,机票)成本提示
  16338. /// </summary>
  16339. /// <param name="dto"></param>
  16340. /// <returns></returns>
  16341. [HttpPost]
  16342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16343. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  16344. {
  16345. try
  16346. {
  16347. #region 参数验证
  16348. if (dto.DiId < 0)
  16349. {
  16350. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  16351. }
  16352. List<int> cTableIds = new List<int>() {
  16353. 76 ,//酒店预订
  16354. 77 ,//行程
  16355. 79 ,//车/导游地接
  16356. 80 ,//签证
  16357. 81 ,//邀请/公务活
  16358. 82 ,//团组客户保险
  16359. 85 ,//机票预订
  16360. 98 ,//其他款项
  16361. 285 ,//收款退还
  16362. 751 ,//酒店早餐
  16363. 1015 // 超支费用
  16364. };
  16365. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  16366. {
  16367. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  16368. }
  16369. #endregion
  16370. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  16371. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  16372. if (_GroupCostParameters.Count <= 0)
  16373. {
  16374. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  16375. }
  16376. if (_GroupCostParameters[0].IsShare == 0)
  16377. {
  16378. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  16379. }
  16380. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16381. //处理date为空问题
  16382. if (_GroupCosts.Count > 0)
  16383. {
  16384. for (int i = 0; i < _GroupCosts.Count; i++)
  16385. {
  16386. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  16387. {
  16388. if (i > 0)
  16389. {
  16390. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  16391. }
  16392. }
  16393. }
  16394. }
  16395. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  16396. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  16397. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  16398. string currCode = "";
  16399. #region currCode 验证
  16400. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  16401. if (isInt)
  16402. {
  16403. var currData = currDatas.Find(it => it.Id == intCurrency);
  16404. if (currData != null)
  16405. {
  16406. currCode = currData.Name;
  16407. }
  16408. }
  16409. else
  16410. {
  16411. currCode = _GroupCostParameters[0].Currency.Trim();
  16412. }
  16413. #endregion
  16414. //op,酒店单段模式存储
  16415. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  16416. {
  16417. CurrencyCode = currCode,
  16418. Rate = _GroupCostParameters[0].Rate,
  16419. CostType = _GroupCostParameters[0].CostType,
  16420. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  16421. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  16422. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  16423. };
  16424. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  16425. if (_GroupCostParameters.Count == 2)
  16426. {
  16427. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  16428. }
  16429. foreach (var item in _GroupCostParameters)
  16430. {
  16431. decimal _rate = 1;
  16432. decimal _rate1 = item.Rate;
  16433. decimal _scale = 1;
  16434. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  16435. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  16436. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  16437. //if (userInfo != null)
  16438. //{
  16439. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  16440. // {
  16441. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  16442. // {
  16443. // _scale = 1.00M;
  16444. // }
  16445. // }
  16446. //}
  16447. #endregion
  16448. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  16449. {
  16450. CurrencyCode = currCode,
  16451. Rate = _rate1,
  16452. CostType = item.CostType,
  16453. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  16454. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  16455. CostTypeNumber = item.CostTypenumber
  16456. };
  16457. if (_GroupCostParameters.Count > 1)
  16458. {
  16459. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  16460. }
  16461. else
  16462. {
  16463. modulePromptInfo.CostTypeNumber = item.LYJRS;
  16464. }
  16465. if (dto.CTable == 79)//
  16466. {
  16467. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  16468. modulePromptInfo.TotalCost = item.DJCB;
  16469. }
  16470. List<string> costTypes = new List<string>() { "A", "B" };
  16471. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  16472. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  16473. if (_GroupCostsDuplicates.Count() == 1)
  16474. {
  16475. _GroupCostsTypeData = _GroupCosts;
  16476. }
  16477. else
  16478. {
  16479. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  16480. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  16481. }
  16482. /*
  16483. * 76 酒店预订
  16484. * 77 行程
  16485. * 79 车/导游地接
  16486. * 80 签证
  16487. * 81 邀请/公务活动
  16488. * 82 团组客户保险
  16489. * 85 机票预订
  16490. * 98 其他款项
  16491. * 285 收款退还
  16492. * 751 酒店早餐
  16493. * 1015 超支费用
  16494. */
  16495. switch (dto.CTable)
  16496. {
  16497. case 76: // 酒店预订
  16498. _ModuleSubPromptInfo.AddRange(
  16499. _GroupCostsTypeData.Select(it => new
  16500. {
  16501. it.DAY,
  16502. it.Date,
  16503. it.ACCON,
  16504. it.ITIN,
  16505. it.SGR,
  16506. it.TBR,
  16507. it.JS_ES,
  16508. it.Suite
  16509. })
  16510. );
  16511. break;
  16512. case 79: // 车/导游地接
  16513. _ModuleSubPromptInfo.AddRange(
  16514. _GroupCostsTypeData.Select(it => new
  16515. {
  16516. Date = it.Date, //日期
  16517. CarFee = it.CarCost * _rate * _scale, //车费用
  16518. CarType = it.CarType, //车型
  16519. DriverFee = it.CFS * _rate * _scale, //司机工资
  16520. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  16521. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  16522. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  16523. GuideFee = it.TGS * _rate * _scale, //导游费用
  16524. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  16525. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  16526. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  16527. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  16528. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  16529. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  16530. Breakfast = it.B * _rate * _scale, //早餐费
  16531. Lunch = it.L * _rate * _scale, //午餐费
  16532. Dinner = it.D * _rate * _scale, //晚餐费
  16533. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  16534. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  16535. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  16536. TicketFee = it.EF * _rate * _scale, //门票费
  16537. TicketRemark = it.EFR, //门票费描述
  16538. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  16539. TravelSupplies = it.TE * _rate * _scale, //出行物资
  16540. SpentCash = it.PC * _rate * _scale, //零用金
  16541. LeadersFee = it.TLF * _rate * _scale, //领队费
  16542. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  16543. })
  16544. );
  16545. break;
  16546. case 85: // 机票
  16547. List<dynamic> datas = new List<dynamic>();
  16548. datas.Add(
  16549. new
  16550. {
  16551. AirType = "经济舱",
  16552. AirNum = item.JJCRS,
  16553. AirDRCB = item.JJCCB,
  16554. AirZCB = (item.JJCRS * item.JJCCB)
  16555. }
  16556. );
  16557. datas.Add(
  16558. new
  16559. {
  16560. AirType = "公务舱",
  16561. AirNum = item.GWCRS,
  16562. AirDRCB = item.GWCCB,
  16563. AirZCB = (item.GWCRS * item.GWCCB)
  16564. }
  16565. );
  16566. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16567. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  16568. modulePromptInfo.Data = new
  16569. {
  16570. airFeeData = datas,
  16571. airInitData = initDatas
  16572. };
  16573. _ModulePromptInfos.Add(modulePromptInfo);
  16574. break;
  16575. default:
  16576. break;
  16577. }
  16578. }
  16579. if (dto.CTable != 85)
  16580. {
  16581. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  16582. _ModulePromptInfos.Add(_ModulePromptInfo);
  16583. }
  16584. _view.ModulePromptInfos = _ModulePromptInfos;
  16585. return Ok(JsonView(true, "操作成功!", _view));
  16586. }
  16587. catch (Exception ex)
  16588. {
  16589. return Ok(JsonView(false, ex.Message));
  16590. }
  16591. }
  16592. /// <summary>
  16593. /// 根据黑屏代码重新生成行程
  16594. /// </summary>
  16595. /// <param name="dto"></param>
  16596. /// <returns></returns>
  16597. [HttpPost]
  16598. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  16599. {
  16600. var jw = JsonView(false, "Error");
  16601. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  16602. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  16603. .Select(x => new
  16604. {
  16605. x.Id,
  16606. x.Title
  16607. })
  16608. .ToList();
  16609. if (Create.Any())
  16610. {
  16611. jw.Msg = "获取成功!";
  16612. jw.Code = 200;
  16613. jw.Data = new
  16614. {
  16615. BlackCodeListSelect = Create,
  16616. blackCodeIsTrue = true
  16617. };
  16618. }
  16619. else
  16620. {
  16621. jw.Code = 400;
  16622. jw.Data = new
  16623. {
  16624. BlackCodeListSelect = Create,
  16625. blackCodeIsTrue = false,
  16626. };
  16627. }
  16628. return Ok(jw);
  16629. }
  16630. /// <summary>
  16631. /// 根据黑屏代码Id重新生成行程
  16632. /// </summary>
  16633. /// <param name="dto"></param>
  16634. /// <returns></returns>
  16635. [HttpPost]
  16636. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16637. {
  16638. var jw = JsonView(false, "Error");
  16639. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16640. if (result.Code == 0)
  16641. {
  16642. jw.Msg = "获取成功!";
  16643. jw.Code = 200;
  16644. jw.Data = new
  16645. {
  16646. groupCost = result.Data,
  16647. blackCodeIsTrue = true
  16648. };
  16649. }
  16650. else
  16651. {
  16652. jw.Code = 400;
  16653. jw.Data = new
  16654. {
  16655. groupCost = result.Data,
  16656. blackCodeIsTrue = false,
  16657. };
  16658. }
  16659. return Ok(jw);
  16660. }
  16661. /// <summary>
  16662. /// 成本获取OP历史车费用
  16663. /// </summary>
  16664. /// <param name="dto"></param>
  16665. /// <returns></returns>
  16666. [HttpPost]
  16667. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16668. {
  16669. var jw = JsonView(false);
  16670. try
  16671. {
  16672. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16673. //获取现有所有车的数据
  16674. if (!dto.Param.IsNullOrWhiteSpace())
  16675. {
  16676. string sql = $@"
  16677. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16678. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16679. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16680. 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
  16681. AND gctggr.ServiceEndTime is not NULL
  16682. ORDER by gctggrc.id DESC
  16683. ";
  16684. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16685. var numeberResult = await Task.Run(() =>
  16686. {
  16687. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16688. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16689. return numberArr;
  16690. });
  16691. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16692. foreach (var item in numeberResult)
  16693. {
  16694. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16695. {
  16696. Country = "数据异常!",
  16697. City = string.Empty,
  16698. };
  16699. item.Area = find.Country + " " + find.City;
  16700. }
  16701. dbResult.AddRange(numeberResult);
  16702. if (dto.Param.Contains("、"))
  16703. {
  16704. var sp = dto.Param.Split("、");
  16705. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16706. .Where(x =>
  16707. {
  16708. return System.Array.Exists(sp, e =>
  16709. {
  16710. bool where = false;
  16711. if (x.Area != null)
  16712. {
  16713. where = x.Area.Contains(e);
  16714. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16715. {
  16716. return false;
  16717. }
  16718. }
  16719. if (x.PriceName != null && !where)
  16720. {
  16721. where = x.PriceName.Contains(e);
  16722. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16723. {
  16724. return false;
  16725. }
  16726. }
  16727. return where;
  16728. });
  16729. }).ToList();
  16730. }
  16731. else
  16732. {
  16733. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16734. .Where(x =>
  16735. {
  16736. bool where = false;
  16737. if (x.Area != null)
  16738. {
  16739. where = x.Area.Contains(dto.Param);
  16740. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16741. {
  16742. return false;
  16743. }
  16744. }
  16745. if (x.PriceName != null && !where)
  16746. {
  16747. where = x.PriceName.Contains(dto.Param);
  16748. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16749. {
  16750. return false;
  16751. }
  16752. }
  16753. return where;
  16754. }
  16755. )
  16756. .ToList();
  16757. }
  16758. }
  16759. var view = dbResult.Select(x =>
  16760. {
  16761. decimal dp = 0.00M;
  16762. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16763. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16764. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16765. {
  16766. if (startB && endB)
  16767. {
  16768. var timesp = endD.Subtract(startD);
  16769. if ((timesp.Days + 1) != 0)
  16770. {
  16771. dp = x.Price / (timesp.Days + 1);
  16772. }
  16773. }
  16774. }
  16775. else
  16776. {
  16777. dp = x.Price;
  16778. }
  16779. return new
  16780. {
  16781. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16782. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16783. x.Area,
  16784. x.id,
  16785. price = x.Price.ToString("F2"),
  16786. x.PriceName,
  16787. x.PriceContent,
  16788. x.TeamName,
  16789. x.DatePrice,
  16790. dayPrice = dp.ToString("F2"),
  16791. };
  16792. }).OrderByDescending(x => x.id).ToList();
  16793. jw = JsonView(true, "获取成功!", view);
  16794. }
  16795. catch (Exception e)
  16796. {
  16797. jw = JsonView(false, e.Message);
  16798. }
  16799. return Ok(jw);
  16800. }
  16801. [HttpPost]
  16802. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16803. {
  16804. var jw = JsonView(true);
  16805. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16806. #region SQL语句
  16807. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16808. //{
  16809. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16810. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16811. // WHEN COUNT(*) >= 0 THEN 'True'
  16812. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16813. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16814. // ")
  16815. // .ToList();
  16816. //}
  16817. //else
  16818. //{
  16819. // string likeKey = string.Empty;
  16820. // foreach (var item in dto.Keyword)
  16821. // {
  16822. // likeKey += "%" + item;
  16823. // }
  16824. // likeKey += "%";
  16825. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16826. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16827. // WHEN COUNT(*) >= 0 THEN 'True'
  16828. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16829. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16830. // ")
  16831. // .ToList();
  16832. //}
  16833. #endregion
  16834. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16835. {
  16836. @KeyWord = dto.Keyword
  16837. });
  16838. if (table != null && table.Rows.Count > 0)
  16839. {
  16840. foreach (DataRow row in table.Rows)
  16841. {
  16842. matches.Add(new DelegationInfoAndIsTrueView
  16843. {
  16844. Id = row.Field<int>("Id"),
  16845. GroupName = row.Field<string>("GroupName"),
  16846. isTrue = row.Field<string>("isTrue")
  16847. });
  16848. }
  16849. }
  16850. if (matches.Any())
  16851. {
  16852. jw.Data = matches;
  16853. }
  16854. else
  16855. {
  16856. jw.Code = 201;
  16857. jw.Msg = "empty list";
  16858. jw.Data = new List<string>(1);
  16859. }
  16860. return Ok(jw);
  16861. }
  16862. /// <summary>
  16863. /// 报价Word下载
  16864. /// </summary>
  16865. /// <param name="dto"></param>
  16866. /// <returns></returns>
  16867. [HttpPost]
  16868. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16869. {
  16870. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16871. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16872. if (di == null)
  16873. {
  16874. return Ok(JsonView(false, "团组不存在!"));
  16875. }
  16876. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16877. if (mainPrice == null || mainPrice.IsShare == 0)
  16878. {
  16879. return Ok(JsonView(false, "团组成本不存在!"));
  16880. }
  16881. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16882. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16883. if (costTypeHotelNumbers == null)
  16884. {
  16885. return Ok(JsonView(false, "团组成本不存在!"));
  16886. }
  16887. //文件名
  16888. string strFileName = di.TeamName + "-收款账单.doc";
  16889. //获取模板
  16890. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16891. //载入模板
  16892. Document doc = new Document(tmppath);
  16893. decimal allPrice = 0.00M;
  16894. string itemStr = string.Empty;
  16895. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16896. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16897. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16898. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16899. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16900. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16901. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16902. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16903. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16904. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16905. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16906. {
  16907. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16908. ("BXRS", "BXCB", "BXXS", "bx"),
  16909. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16910. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16911. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16912. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16913. ("CPRS", "CPCB", "CPXS", "cp"),
  16914. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16915. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16916. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16917. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16918. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16919. ("DJRS", "DJCB", "DJXS", "dj"),
  16920. ("GWRS", "GWCB", "GWXS", "gw"),
  16921. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16922. };
  16923. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16924. var rightSum = 0.00M;
  16925. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16926. {
  16927. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16928. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16929. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16930. if (prefix == "tbr")
  16931. {
  16932. rsValue *= 2;
  16933. cbValue /= 2;
  16934. }
  16935. if (OtherCostPropertyBJ.Contains(prefix))
  16936. {
  16937. rightSum += cbValue * xsValue;
  16938. }
  16939. }
  16940. var hotelRooms = new Dictionary<string, int>
  16941. {
  16942. { "SGR", costTypeHotelNumbers.SGR },
  16943. { "TBR", costTypeHotelNumbers.TBR },
  16944. { "JSES", costTypeHotelNumbers.JSES },
  16945. { "SUITE", costTypeHotelNumbers.SUITE }
  16946. };
  16947. var flights = new Dictionary<string, int>
  16948. {
  16949. { "经济舱", mainPrice.JJCRS },
  16950. { "公务舱", mainPrice.GWCRS },
  16951. { "头等舱", mainPrice.TDCRS }
  16952. };
  16953. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16954. {
  16955. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16956. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16957. { "头等舱", new[] { "SUITE", "JSES" } }
  16958. };
  16959. var result = new Dictionary<string, int>();
  16960. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16961. foreach (var flight in flights.Keys)
  16962. {
  16963. // 获取当前舱位的匹配规则
  16964. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16965. {
  16966. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16967. }
  16968. }
  16969. #region right计算
  16970. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16971. {
  16972. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16973. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16974. airHotelPriceList.Add(new
  16975. AirHotelPrice
  16976. {
  16977. Name = "经济舱TBR",
  16978. Price = rightSum + air + hotel,
  16979. Count = result["经济舱TBR"] * 2
  16980. });
  16981. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16982. }
  16983. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16984. {
  16985. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16986. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16987. airHotelPriceList.Add(new
  16988. AirHotelPrice
  16989. {
  16990. Name = "经济舱SGR",
  16991. Price = rightSum + air + hotel,
  16992. Count = result["经济舱SGR"]
  16993. });
  16994. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16995. }
  16996. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16997. {
  16998. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16999. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17000. airHotelPriceList.Add(new
  17001. AirHotelPrice
  17002. {
  17003. Name = "公务舱SGR",
  17004. Price = rightSum + air + hotel,
  17005. Count = result["公务舱SGR"]
  17006. });
  17007. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17008. }
  17009. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17010. {
  17011. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17012. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17013. airHotelPriceList.Add(new
  17014. AirHotelPrice
  17015. {
  17016. Name = "公务舱JSES",
  17017. Price = rightSum + air + hotel,
  17018. Count = result["公务舱JSES"]
  17019. });
  17020. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17021. }
  17022. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17023. {
  17024. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17025. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17026. airHotelPriceList.Add(new
  17027. AirHotelPrice
  17028. {
  17029. Name = "公务舱SUITE",
  17030. Price = rightSum + air + hotel,
  17031. Count = result["公务舱SUITE"]
  17032. });
  17033. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17034. }
  17035. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17036. {
  17037. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17038. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17039. airHotelPriceList.Add(new
  17040. AirHotelPrice
  17041. {
  17042. Name = "经济舱SUITE",
  17043. Price = rightSum + air + hotel,
  17044. Count = result["经济舱SUITE"]
  17045. });
  17046. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17047. }
  17048. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17049. {
  17050. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17051. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17052. airHotelPriceList.Add(new
  17053. AirHotelPrice
  17054. {
  17055. Name = "头等舱JSES",
  17056. Price = rightSum + air + hotel,
  17057. Count = result["头等舱JSES"]
  17058. });
  17059. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17060. }
  17061. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17062. {
  17063. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17064. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17065. airHotelPriceList.Add(new
  17066. AirHotelPrice
  17067. {
  17068. Name = "头等舱SUITE",
  17069. Price = rightSum + air + hotel,
  17070. Count = result["头等舱SUITE"]
  17071. });
  17072. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17073. }
  17074. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17075. {
  17076. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17077. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17078. airHotelPriceList.Add(new
  17079. AirHotelPrice
  17080. {
  17081. Name = "经济舱JSES",
  17082. Price = rightSum + air + hotel,
  17083. Count = result["经济舱JSES"]
  17084. });
  17085. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17086. }
  17087. #endregion
  17088. foreach (var item in airSouer.Keys)
  17089. {
  17090. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  17091. if (find != null && find.Count > 0)
  17092. {
  17093. if (item.Contains("TBR"))
  17094. {
  17095. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17096. }
  17097. else
  17098. {
  17099. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17100. }
  17101. }
  17102. }
  17103. #region 替换Word模板书签内容
  17104. Dictionary<string, string> marks = new Dictionary<string, string>();
  17105. marks.Add("To", di.ClientUnit);//付款方
  17106. marks.Add("ToTel", di.TellPhone);//付款方电话
  17107. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17108. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17109. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17110. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17111. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17112. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17113. marks.Add("PayItemContent", itemStr);//详细信息
  17114. marks.Add("Total", allPrice.ToString("F2"));//合计
  17115. #endregion
  17116. foreach (var item in marks.Keys)
  17117. {
  17118. if (doc.Range.Bookmarks[item] != null)
  17119. {
  17120. Bookmark mark = doc.Range.Bookmarks[item];
  17121. mark.Text = marks[item];
  17122. }
  17123. }
  17124. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  17125. doc.Save(savePaht);
  17126. var jw = new JsonView();
  17127. jw.Msg = "生成成功!";
  17128. jw.Code = 200;
  17129. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  17130. return Ok(jw);
  17131. }
  17132. /// <summary>
  17133. /// 详细报价费用Excel下载
  17134. /// </summary>
  17135. /// <param name="dto"></param>
  17136. /// <returns></returns>
  17137. [HttpPost]
  17138. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  17139. {
  17140. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17141. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17142. if (di == null)
  17143. {
  17144. return Ok(JsonView(false, "团组不存在!"));
  17145. }
  17146. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17147. if (mainPrice == null || mainPrice.IsShare == 0)
  17148. {
  17149. return Ok(JsonView(false, "团组成本不存在!"));
  17150. }
  17151. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17152. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17153. if (costTypeHotelNumbers == null)
  17154. {
  17155. return Ok(JsonView(false, "团组成本不存在!"));
  17156. }
  17157. WorkbookDesigner designer = new WorkbookDesigner();
  17158. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  17159. List<int> hideRowsList = new List<int>();
  17160. int conterStartIndex = 3;
  17161. int rowIndex = conterStartIndex;
  17162. designer.SetDataSource("GroupName", di.TeamName);
  17163. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17164. {
  17165. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17166. ("BXRS", "BXCB", "BXXS", "bx"),
  17167. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17168. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17169. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  17170. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  17171. ("CPRS", "CPCB", "CPXS", "cp") ,
  17172. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  17173. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  17174. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  17175. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  17176. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  17177. ("DJRS", "DJCB", "DJXS", "dj") ,
  17178. ("GWRS", "GWCB", "GWXS", "gw") ,
  17179. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  17180. };
  17181. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17182. var rightSum = 0.00M;
  17183. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17184. {
  17185. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17186. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17187. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17188. if (prefix == "tbr")
  17189. {
  17190. rsValue *= 2;
  17191. cbValue /= 2;
  17192. }
  17193. if (OtherCostPropertyBJ.Contains(prefix))
  17194. {
  17195. rightSum += cbValue * xsValue;
  17196. }
  17197. if (rsValue == 0)
  17198. {
  17199. hideRowsList.Add(rowIndex);
  17200. }
  17201. else
  17202. {
  17203. designer.SetDataSource($"{prefix}rs", rsValue);
  17204. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  17205. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  17206. }
  17207. rowIndex += 2;
  17208. }
  17209. var hotelRooms = new Dictionary<string, int>
  17210. {
  17211. { "SGR", costTypeHotelNumbers.SGR },
  17212. { "TBR", costTypeHotelNumbers.TBR },
  17213. { "JSES", costTypeHotelNumbers.JSES },
  17214. { "SUITE", costTypeHotelNumbers.SUITE }
  17215. };
  17216. var flights = new Dictionary<string, int>
  17217. {
  17218. { "经济舱", mainPrice.JJCRS },
  17219. { "公务舱", mainPrice.GWCRS },
  17220. { "头等舱", mainPrice.TDCRS }
  17221. };
  17222. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17223. {
  17224. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17225. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17226. { "头等舱", new[] { "SUITE", "JSES" } }
  17227. };
  17228. var result = new Dictionary<string, int>();
  17229. foreach (var flight in flights.Keys)
  17230. {
  17231. // 获取当前舱位的匹配规则
  17232. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17233. {
  17234. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17235. }
  17236. }
  17237. var allPrice = 0.00M;
  17238. #region right计算
  17239. int airRowIndex = 35;
  17240. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17241. {
  17242. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17243. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17244. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  17245. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  17246. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  17247. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17248. }
  17249. else
  17250. {
  17251. hideRowsList.Add(airRowIndex);
  17252. }
  17253. airRowIndex += 2;
  17254. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17255. {
  17256. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17257. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17258. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  17259. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  17260. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  17261. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17262. }
  17263. else
  17264. {
  17265. hideRowsList.Add(airRowIndex);
  17266. }
  17267. airRowIndex += 2;
  17268. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17269. {
  17270. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17271. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17272. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  17273. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  17274. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  17275. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17276. }
  17277. else
  17278. {
  17279. hideRowsList.Add(airRowIndex);
  17280. }
  17281. airRowIndex += 2;
  17282. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17283. {
  17284. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17285. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17286. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  17287. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  17288. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  17289. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17290. }
  17291. else
  17292. {
  17293. hideRowsList.Add(airRowIndex);
  17294. }
  17295. airRowIndex += 2;
  17296. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17297. {
  17298. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17299. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17300. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  17301. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  17302. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  17303. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17304. }
  17305. else
  17306. {
  17307. hideRowsList.Add(airRowIndex);
  17308. }
  17309. airRowIndex += 2;
  17310. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17311. {
  17312. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17313. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17314. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  17315. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  17316. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  17317. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17318. }
  17319. else
  17320. {
  17321. hideRowsList.Add(airRowIndex);
  17322. }
  17323. airRowIndex += 2;
  17324. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17325. {
  17326. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17327. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17328. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  17329. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  17330. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  17331. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17332. }
  17333. else
  17334. {
  17335. hideRowsList.Add(airRowIndex);
  17336. }
  17337. airRowIndex += 2;
  17338. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17339. {
  17340. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17341. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17342. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  17343. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  17344. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  17345. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17346. }
  17347. else
  17348. {
  17349. hideRowsList.Add(airRowIndex);
  17350. }
  17351. airRowIndex += 2;
  17352. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17353. {
  17354. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17355. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17356. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  17357. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  17358. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  17359. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17360. }
  17361. else
  17362. {
  17363. hideRowsList.Add(airRowIndex);
  17364. }
  17365. #endregion
  17366. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  17367. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  17368. var ws = designer.Workbook.Worksheets[0];
  17369. foreach (var Rowindex in hideRowsList)
  17370. {
  17371. ws.Cells.HideRows(Rowindex, 2);
  17372. }
  17373. designer.Process();
  17374. designer.Workbook.Save(savePaht);
  17375. return Ok(JsonView(true, "生成成功!", new
  17376. {
  17377. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  17378. }));
  17379. }
  17380. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  17381. {
  17382. foreach (var roomType in roomTypes)
  17383. {
  17384. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  17385. {
  17386. hotelRooms[roomType]--;
  17387. flights[flightType]--;
  17388. if (roomType == "TBR")
  17389. {
  17390. flights[flightType]--; // 双人间在减少1
  17391. }
  17392. string key = flightType + roomType;
  17393. if (result.Keys.Contains(key))
  17394. {
  17395. result[key]++;
  17396. }
  17397. else
  17398. {
  17399. result.Add(key, 1);
  17400. }
  17401. }
  17402. }
  17403. }
  17404. private class AirHotelPrice
  17405. {
  17406. public string Name { get; set; }
  17407. public decimal Price { get; set; }
  17408. public int Count { get; set; }
  17409. }
  17410. /// <summary>
  17411. /// 团组系数设置
  17412. /// </summary>
  17413. /// <param name="dto"></param>
  17414. /// <returns></returns>
  17415. [HttpPost]
  17416. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  17417. {
  17418. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17419. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17420. if (di == null)
  17421. {
  17422. return Ok(JsonView(false, "团组不存在!"));
  17423. }
  17424. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  17425. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  17426. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  17427. // FirstAsync(firstExpression.ToExpression());
  17428. #region JSON
  17429. string hcpJson = @"
  17430. [
  17431. {
  17432. ""min"": 1,
  17433. ""max"": 500,
  17434. ""value"": 1.50
  17435. },
  17436. {
  17437. ""min"": 501,
  17438. ""max"": 1000,
  17439. ""value"": 1.40
  17440. },
  17441. {
  17442. ""min"": 1001,
  17443. ""max"": 2000,
  17444. ""value"": 1.35
  17445. }
  17446. ]";
  17447. #endregion
  17448. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  17449. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  17450. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  17451. .ToList();
  17452. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  17453. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  17454. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  17455. // new List<(Predicate<decimal>, decimal)>()
  17456. // {
  17457. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  17458. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  17459. // }
  17460. // ));
  17461. #region 签证系数
  17462. var visaXS = 0.00M;
  17463. switch (dto.VisaCB)
  17464. {
  17465. case decimal n when (n > 1 && n < 500):
  17466. switch (dto.VisaRS)
  17467. {
  17468. case 2 or 3:
  17469. visaXS = 1.35M;
  17470. break;
  17471. case 4 or 5:
  17472. visaXS = 1.30M;
  17473. break;
  17474. case 6 or 7:
  17475. visaXS = 1.25M;
  17476. break;
  17477. case 8 or 9 or 10:
  17478. visaXS = 1.20M;
  17479. break;
  17480. case > 10:
  17481. visaXS = 1.15M;
  17482. break;
  17483. default:
  17484. visaXS = 0.00M;
  17485. break;
  17486. }
  17487. break;
  17488. case decimal n when (n >= 500 && n < 1000):
  17489. switch (dto.VisaRS)
  17490. {
  17491. case 2 or 3 or 4:
  17492. visaXS = 1.30M;
  17493. break;
  17494. case 5 or 6 or 7 or 8:
  17495. visaXS = 1.25M;
  17496. break;
  17497. case 9 or 10:
  17498. visaXS = 1.20M;
  17499. break;
  17500. case > 10:
  17501. visaXS = 1.15M;
  17502. break;
  17503. default:
  17504. visaXS = 0.00M;
  17505. break;
  17506. }
  17507. break;
  17508. default:
  17509. switch (dto.VisaRS)
  17510. {
  17511. case 2 or 3 or 4:
  17512. visaXS = 1.30M;
  17513. break;
  17514. case 5 or 6 or 7 or 8:
  17515. visaXS = 1.25M;
  17516. break;
  17517. case 9 or 10:
  17518. visaXS = 1.20M;
  17519. break;
  17520. case > 10:
  17521. visaXS = 1.15M;
  17522. break;
  17523. default:
  17524. visaXS = 0.00M;
  17525. break;
  17526. }
  17527. break;
  17528. }
  17529. #endregion
  17530. #region 火车系数
  17531. var hcpXS = 0.00M;
  17532. foreach (var (condition, result) in hcpSwitchDictionary)
  17533. {
  17534. if (condition(dto.HCPCB))
  17535. {
  17536. hcpXS = result;
  17537. break;
  17538. }
  17539. }
  17540. #endregion
  17541. #region 机票系数
  17542. #region 经济舱系数
  17543. var jjcXS = 0.00M;
  17544. switch (dto.JJCCB)
  17545. {
  17546. case decimal x when (x >= 1000 && x <= 3000):
  17547. jjcXS = 2.6M;
  17548. break;
  17549. case decimal x when (x >= 3001 && x <= 8000):
  17550. jjcXS = 2.3M;
  17551. break;
  17552. case decimal x when (x >= 8001 && x <= 15000):
  17553. jjcXS = 2.1M;
  17554. break;
  17555. case decimal x when (x >= 15001 && x <= 30000):
  17556. jjcXS = 1.95M;
  17557. break;
  17558. case > 30000:
  17559. jjcXS = 1.8M;
  17560. break;
  17561. default:
  17562. break;
  17563. }
  17564. #endregion
  17565. #region 公务舱系数
  17566. var gwcXS = 0.00M;
  17567. switch (dto.GWCCB)
  17568. {
  17569. case decimal x when (x >= 1000 && x <= 3000):
  17570. gwcXS = 2.5M;
  17571. break;
  17572. case decimal x when (x >= 3001 && x <= 8000):
  17573. gwcXS = 2.2M;
  17574. break;
  17575. case decimal x when (x >= 8001 && x <= 15000):
  17576. gwcXS = 2.0M;
  17577. break;
  17578. case decimal x when (x >= 15001 && x <= 30000):
  17579. gwcXS = 1.85M;
  17580. break;
  17581. case > 30000:
  17582. gwcXS = 1.7M;
  17583. break;
  17584. default:
  17585. break;
  17586. }
  17587. #endregion
  17588. #region 头等舱系数
  17589. var tdcXS = 0.00M;
  17590. switch (dto.TDCCB)
  17591. {
  17592. case > 70000:
  17593. tdcXS = 1.5M;
  17594. break;
  17595. default:
  17596. tdcXS = 1.9M;
  17597. break;
  17598. }
  17599. #endregion
  17600. #endregion
  17601. #region 酒店系数
  17602. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  17603. {
  17604. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  17605. {1.5M, new List<string>(){"越南社会主义共和国",
  17606. "老挝",
  17607. "柬埔寨",
  17608. "泰国",
  17609. "缅甸",
  17610. "马来西亚",
  17611. //"新加坡",
  17612. "文莱达鲁萨兰",
  17613. "印度尼西亚",
  17614. "东帝汶"}},
  17615. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  17616. };
  17617. #region SGR
  17618. var sgrXS = 1.25M;
  17619. #endregion
  17620. #region TBR
  17621. var tbrXS = 1.25M;
  17622. #endregion
  17623. #region JSES
  17624. var jsesXS = 1.25M;
  17625. #endregion
  17626. #region SUITE
  17627. var suiteXS = 1.25M;
  17628. #endregion
  17629. var countryArr = di.VisitCountry.Split("|");
  17630. foreach (var item in dic)
  17631. {
  17632. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  17633. .Count();
  17634. if (extsisCount > 0)
  17635. {
  17636. jsesXS = item.Key;
  17637. sgrXS = item.Key;
  17638. tbrXS = item.Key;
  17639. suiteXS = item.Key;
  17640. }
  17641. }
  17642. #endregion
  17643. #region 地接系数
  17644. var djXS = 0.00M;
  17645. switch (dto.DJRS)
  17646. {
  17647. case 2 or 3:
  17648. djXS = 2.65M;
  17649. break;
  17650. case 4:
  17651. djXS = 2.6M;
  17652. break;
  17653. case 5 or 6:
  17654. djXS = 2.5M;
  17655. break;
  17656. case 7 or 8:
  17657. djXS = 2.4M;
  17658. break;
  17659. case 9 or 10:
  17660. djXS = 2.3M;
  17661. break;
  17662. case 11:
  17663. djXS = 2.2M;
  17664. break;
  17665. case 12:
  17666. djXS = 2.1M;
  17667. break;
  17668. case 13 or 14:
  17669. djXS = 2M;
  17670. break;
  17671. case 15:
  17672. djXS = 1.9M;
  17673. break;
  17674. case 16 or 17 or 18:
  17675. djXS = 1.8M;
  17676. break;
  17677. case 19 or 20:
  17678. djXS = 1.7M;
  17679. break;
  17680. }
  17681. #endregion
  17682. #region 零用金系数
  17683. var lyjXS = 0.00M;
  17684. switch (dto.LYJRS)
  17685. {
  17686. case 2:
  17687. lyjXS = 1.25M;
  17688. break;
  17689. case 3 or 4 or 5:
  17690. lyjXS = 1.2M;
  17691. break;
  17692. case int number when (number > 5 && number < 10):
  17693. lyjXS = 1.15M;
  17694. break;
  17695. case > 10:
  17696. lyjXS = 1.1M;
  17697. break;
  17698. default:
  17699. break;
  17700. }
  17701. #endregion
  17702. return Ok(JsonView(true, "查询成功", new ArrayList()
  17703. {
  17704. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  17705. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  17706. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  17707. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  17708. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  17709. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  17710. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  17711. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  17712. new { label = "地接系数", value = djXS, key = "djXS" },
  17713. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  17714. new { label = "公务系数", value = 2M, key = "gwXS" }
  17715. }));
  17716. }
  17717. #endregion
  17718. #region 酒店预订 New 2023-12-28 17:45
  17719. /// <summary>
  17720. /// 酒店预订
  17721. /// 酒店费用列表 根据团组Id查询
  17722. /// </summary>
  17723. /// <param name="_dto"></param>
  17724. /// <returns></returns>
  17725. [HttpPost]
  17726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17727. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  17728. {
  17729. #region 参数验证
  17730. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17731. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17732. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17733. #region 团组操作权限验证 76 酒店预定模块
  17734. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17735. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17736. #endregion
  17737. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17738. #region 页面操作权限验证
  17739. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17740. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17741. #endregion
  17742. #endregion
  17743. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  17744. }
  17745. /// <summary>
  17746. /// 酒店预订
  17747. /// 基础数据
  17748. /// </summary>
  17749. /// <param name="_dto"></param>
  17750. /// <returns></returns>
  17751. [HttpPost]
  17752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17753. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  17754. {
  17755. #region 参数验证
  17756. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17757. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17758. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17759. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17760. #region 页面操作权限验证
  17761. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17762. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17763. #endregion
  17764. #region 团组操作权限验证 76 酒店预定模块
  17765. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17766. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17767. #endregion
  17768. #endregion
  17769. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  17770. }
  17771. /// <summary>
  17772. /// 酒店预订
  17773. /// 创建 入住卷号码
  17774. /// </summary>
  17775. /// <param name="_dto"></param>
  17776. /// <returns></returns>
  17777. [HttpPost]
  17778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17779. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  17780. {
  17781. #region 参数验证
  17782. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17783. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17784. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17785. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17786. #region 页面操作权限验证
  17787. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17788. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17789. #endregion
  17790. #region 团组操作权限验证 76 酒店预定模块
  17791. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17792. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17793. #endregion
  17794. #endregion
  17795. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  17796. if (data.Code != 0)
  17797. {
  17798. return Ok(JsonView(false, data.Msg));
  17799. }
  17800. return Ok(JsonView(true, data.Msg, data.Data));
  17801. }
  17802. /// <summary>
  17803. /// 酒店预订
  17804. /// 详情
  17805. /// </summary>
  17806. /// <param name="_dto"></param>
  17807. /// <returns></returns>
  17808. [HttpPost]
  17809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17810. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  17811. {
  17812. #region 参数验证
  17813. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  17814. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17815. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  17816. #region 团组操作权限验证 76 酒店预定模块
  17817. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17818. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17819. #endregion
  17820. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17821. #region 页面操作权限验证
  17822. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17823. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17824. #endregion
  17825. #endregion
  17826. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  17827. }
  17828. /// <summary>
  17829. /// 酒店预订
  17830. /// Add Or Edit
  17831. /// </summary>
  17832. /// <param name="_dto"></param>
  17833. /// <returns></returns>
  17834. [HttpPost]
  17835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17836. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  17837. {
  17838. #region 参数验证
  17839. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17840. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17841. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17842. #region 团组操作权限验证 76 酒店预定模块
  17843. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17844. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17845. #endregion
  17846. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17847. #region 页面操作权限验证
  17848. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17849. if (_dto.Id == 0) // Add
  17850. {
  17851. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17852. }
  17853. else if (_dto.Id > 1) // Edit
  17854. {
  17855. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17856. }
  17857. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  17858. #endregion
  17859. #endregion
  17860. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17861. if (_view.Code != 200)
  17862. {
  17863. return Ok(_view);
  17864. }
  17865. #region 成本无酒店价格数据进入超支
  17866. _sqlSugar.BeginTran();
  17867. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17868. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17869. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17870. for (int i = 0; i < groupCost.Count; i++)
  17871. {
  17872. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17873. {
  17874. groupCost[i].Date = groupCost[i - 1].Date;
  17875. }
  17876. }
  17877. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17878. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17879. List<Fin_GroupExtraCostDto_OP>();
  17880. if (start_Bool && end_Bool)
  17881. {
  17882. while (start_Time < end_Time)
  17883. {
  17884. foreach (var item in groupCost_Grp)
  17885. {
  17886. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17887. {
  17888. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17889. {
  17890. extraCostList.Add(new
  17891. Fin_GroupExtraCostDto_OP
  17892. {
  17893. Area = _dto.AreaId,
  17894. coefficient = 1.5M,
  17895. createUser = _dto.UserId,
  17896. currency = _dto.CardPriceCurrency,
  17897. diId = _dto.DiId,
  17898. ManagerConfirm = 0,
  17899. SupervisorConfirm = 0,
  17900. SYsupervisorConfirm = 0,
  17901. editType = 1,
  17902. PortType = 1,
  17903. price = _dto.CardPrice,
  17904. PriceCount = 1,
  17905. priceType = 1027,
  17906. priceDetailType = 1044,
  17907. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17908. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17909. });
  17910. }
  17911. }
  17912. }
  17913. start_Time = start_Time.AddDays(1);
  17914. }
  17915. }
  17916. if (extraCostList.Any())
  17917. {
  17918. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17919. }
  17920. _sqlSugar.CommitTran();
  17921. #endregion
  17922. #region 应用推送
  17923. try
  17924. {
  17925. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17926. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17927. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17928. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17929. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17930. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17931. var diId = _dto.DiId;
  17932. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17933. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17934. #region 操作记录
  17935. var opInfo = new Crm_TableOperationRecord()
  17936. {
  17937. TableName = "Grp_HotelReservations",
  17938. PortType = _dto.PortType,
  17939. DataId = hotelId,
  17940. CreateUserId = _dto.UserId
  17941. };
  17942. //var opStatus = OperationEnum.NoOperation;
  17943. if (_dto.Id < 1) //添加操作
  17944. {
  17945. opInfo.OperationItem = OperationEnum.Add;
  17946. }
  17947. else if (_dto.Id > 0)
  17948. {
  17949. opInfo.OperationItem = OperationEnum.Edit;
  17950. }
  17951. string opRemark = string.Empty;
  17952. if (ccpInfo != null)
  17953. {
  17954. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17955. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17956. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17957. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17958. }
  17959. opInfo.Remark = opRemark;
  17960. await _tableorRep.AddAsync(opInfo);
  17961. #endregion
  17962. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17963. //2024-10-21 新增LZ UID
  17964. var userIds = new List<int>() { 21 };
  17965. string title = $"费用审核";
  17966. string content = "";
  17967. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17968. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17969. try
  17970. {
  17971. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17972. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17973. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17974. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17975. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17976. }
  17977. catch (Exception ex)
  17978. {
  17979. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17980. }
  17981. }
  17982. catch (Exception ex)
  17983. {
  17984. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17985. }
  17986. try
  17987. {
  17988. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17989. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17990. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17991. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17992. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17993. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17994. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17995. //自动审核
  17996. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17997. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17998. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17999. //2024-10-21 新增LZ UID
  18000. var userIds = new List<int>() { 21 };
  18001. string title = $"系统通知";
  18002. var diId = _dto.DiId;
  18003. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18004. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18005. string content = "";
  18006. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18007. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18008. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18009. }
  18010. catch (Exception ex)
  18011. {
  18012. }
  18013. #endregion
  18014. return Ok(_view);
  18015. }
  18016. /// <summary>
  18017. /// 酒店自动审核测试
  18018. /// Add Or Edit
  18019. /// </summary>
  18020. /// <param name="diid"></param>
  18021. /// <param name="dataId"></param>
  18022. /// <returns></returns>
  18023. [HttpPost]
  18024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18025. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  18026. {
  18027. #region 应用推送
  18028. try
  18029. {
  18030. //自动审核
  18031. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  18032. }
  18033. catch (Exception ex)
  18034. {
  18035. return Ok(JsonView(false, ex.Message));
  18036. }
  18037. #endregion
  18038. return Ok(JsonView(false, "操作成功"));
  18039. }
  18040. /// <summary>
  18041. /// 酒店预订
  18042. /// Del
  18043. /// </summary>
  18044. /// <param name="_dto"></param>
  18045. /// <returns></returns>
  18046. [HttpPost]
  18047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18048. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  18049. {
  18050. #region 参数验证
  18051. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18052. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18053. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18054. #region 团组操作权限验证 76 酒店预定模块
  18055. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18056. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18057. #endregion
  18058. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18059. #region 页面操作权限验证
  18060. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18061. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18062. #endregion
  18063. #endregion
  18064. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  18065. #region 操作记录
  18066. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  18067. {
  18068. TableName = "Grp_HotelReservations",
  18069. PortType = _dto.PortType,
  18070. OperationItem = OperationEnum.Del,
  18071. DataId = _dto.Id,
  18072. CreateUserId = _dto.UserId
  18073. });
  18074. #endregion
  18075. return Ok(data);
  18076. }
  18077. /// <summary>
  18078. /// 酒店预订
  18079. /// 生成VOUCHER
  18080. /// 2024.05.06 之前版本
  18081. /// </summary>
  18082. /// <param name="_dto"></param>
  18083. /// <returns></returns>
  18084. [HttpPost]
  18085. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18086. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  18087. {
  18088. try
  18089. {
  18090. #region 参数验证
  18091. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18092. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18093. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18094. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  18095. #region 团组操作权限验证 76 酒店预定模块
  18096. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18097. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18098. #endregion
  18099. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18100. #region 页面操作权限验证
  18101. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18102. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18103. #endregion
  18104. #endregion
  18105. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  18106. //判断数据是否完整
  18107. if (hr != null)
  18108. {
  18109. if (!string.IsNullOrEmpty(hr.DetermineNo))
  18110. {
  18111. string strFileName = "HotelStatement/";
  18112. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18113. if (dele != null)
  18114. strFileName += dele.TourCode;
  18115. //载入模板
  18116. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  18117. Document doc = new Document(sss);
  18118. DocumentBuilder builder = new DocumentBuilder(doc);
  18119. #region 替换Word模板书签内容
  18120. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  18121. //入住卷预定号码
  18122. if (doc.Range.Bookmarks["VNO"] != null)
  18123. {
  18124. Bookmark mark = doc.Range.Bookmarks["VNO"];
  18125. mark.Text = hr.CheckNumber;
  18126. }
  18127. //酒店时间
  18128. if (doc.Range.Bookmarks["Date"] != null)
  18129. {
  18130. Bookmark mark = doc.Range.Bookmarks["Date"];
  18131. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18132. }
  18133. //团号
  18134. if (doc.Range.Bookmarks["TNo"] != null)
  18135. {
  18136. Bookmark mark = doc.Range.Bookmarks["TNo"];
  18137. mark.Text = dele.TourCode;
  18138. }
  18139. //预定号码
  18140. if (doc.Range.Bookmarks["BookingId"] != null)
  18141. {
  18142. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  18143. mark.Text = hr.ReservationsNo;
  18144. }
  18145. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  18146. {
  18147. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  18148. mark.Text = hr.DetermineNo;
  18149. }
  18150. //酒店城市
  18151. if (doc.Range.Bookmarks["City"] != null)
  18152. {
  18153. Bookmark mark = doc.Range.Bookmarks["City"];
  18154. mark.Text = hr.City;
  18155. }
  18156. //酒店名称
  18157. if (doc.Range.Bookmarks["HName"] != null)
  18158. {
  18159. Bookmark mark = doc.Range.Bookmarks["HName"];
  18160. mark.Text = hr.HotelName;
  18161. }
  18162. //酒店地址
  18163. if (doc.Range.Bookmarks["Address"] != null)
  18164. {
  18165. Bookmark mark = doc.Range.Bookmarks["Address"];
  18166. mark.Text = hr.HotelAddress;
  18167. }
  18168. //酒店电话
  18169. if (doc.Range.Bookmarks["Tel"] != null)
  18170. {
  18171. Bookmark mark = doc.Range.Bookmarks["Tel"];
  18172. mark.Text = hr.HotelTel;
  18173. }
  18174. //酒店传真
  18175. if (doc.Range.Bookmarks["Fax"] != null)
  18176. {
  18177. Bookmark mark = doc.Range.Bookmarks["Fax"];
  18178. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  18179. {
  18180. mark.Text = hr.HotelFax;
  18181. }
  18182. }
  18183. //入住时间
  18184. if (doc.Range.Bookmarks["CIn"] != null)
  18185. {
  18186. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18187. Bookmark mark = doc.Range.Bookmarks["CIn"];
  18188. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  18189. }
  18190. //退房时间
  18191. if (doc.Range.Bookmarks["COut"] != null)
  18192. {
  18193. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18194. Bookmark mark = doc.Range.Bookmarks["COut"];
  18195. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18196. }
  18197. //客户名称
  18198. if (doc.Range.Bookmarks["GName"] != null)
  18199. {
  18200. string guestName = "";
  18201. string[] clients = Array.Empty<string>();
  18202. if (hr.GuestName.Contains(","))
  18203. {
  18204. clients = hr.GuestName.Split(",");
  18205. }
  18206. else
  18207. {
  18208. clients = new string[] { hr.GuestName };
  18209. }
  18210. List<int> clientIds_int = new List<int>();
  18211. if (clients.Length > 0)
  18212. {
  18213. foreach (var item in clients)
  18214. {
  18215. if (item.IsNumeric())
  18216. {
  18217. clientIds_int.Add(int.Parse(item));
  18218. }
  18219. }
  18220. }
  18221. if (clientIds_int.Count > 0)
  18222. {
  18223. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  18224. foreach (var client in _clientDatas)
  18225. {
  18226. //男
  18227. if (client.Sex == 0) guestName += $"Mr.";
  18228. //女
  18229. else if (client.Sex == 1) guestName += $"Ms.";
  18230. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  18231. {
  18232. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  18233. }
  18234. //guestName += $"{client.Pinyin},";
  18235. }
  18236. if (guestName.Length > 0)
  18237. {
  18238. guestName = guestName.Substring(0, guestName.Length - 1);
  18239. }
  18240. }
  18241. else
  18242. {
  18243. guestName = hr.GuestName;
  18244. }
  18245. Bookmark mark = doc.Range.Bookmarks["GName"];
  18246. mark.Text = guestName;
  18247. }
  18248. //房间介绍
  18249. if (doc.Range.Bookmarks["ROOM"] != null)
  18250. {
  18251. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  18252. mark.Text = hr.RoomExplanation;
  18253. }
  18254. //报价描述
  18255. if (doc.Range.Bookmarks["NOTE"] != null)
  18256. {
  18257. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  18258. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  18259. if (ss != null)
  18260. mark.Text = ss.Name;
  18261. }
  18262. //入住时间
  18263. if (doc.Range.Bookmarks["CheckIn"] != null)
  18264. {
  18265. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18266. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  18267. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18268. }
  18269. //退房时间
  18270. if (doc.Range.Bookmarks["CheckOut"] != null)
  18271. {
  18272. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18273. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  18274. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18275. }
  18276. //日期
  18277. if (doc.Range.Bookmarks["DT"] != null)
  18278. {
  18279. Bookmark mark = doc.Range.Bookmarks["DT"];
  18280. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18281. }
  18282. //名称
  18283. if (doc.Range.Bookmarks["VName"] != null)
  18284. {
  18285. Bookmark mark = doc.Range.Bookmarks["VName"];
  18286. mark.Text = hr.HotelName;
  18287. }
  18288. //号码
  18289. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  18290. {
  18291. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  18292. mark.Text = hr.CheckNumber;
  18293. }
  18294. #endregion
  18295. strFileName += "VOUCHER.doc";
  18296. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18297. doc.Save(fileDir);
  18298. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18299. return Ok(JsonView(true, "操作成功!", Url));
  18300. }
  18301. else
  18302. {
  18303. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  18304. }
  18305. }
  18306. else
  18307. {
  18308. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  18309. }
  18310. }
  18311. catch (Exception ex)
  18312. {
  18313. return Ok(JsonView(false, ex.Message));
  18314. }
  18315. }
  18316. /// <summary>
  18317. /// 酒店预订
  18318. /// 生成VOUCHER
  18319. /// 2024.05.06 之后版本
  18320. /// </summary>
  18321. /// <param name="_dto"></param>
  18322. /// <returns></returns>
  18323. [HttpPost]
  18324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18325. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  18326. {
  18327. #region 参数验证
  18328. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18329. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18330. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18331. #region 团组操作权限验证 76 酒店预定模块
  18332. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18333. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18334. #endregion
  18335. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18336. #region 页面操作权限验证
  18337. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18338. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18339. #endregion
  18340. #endregion
  18341. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  18342. //判断数据是否完整
  18343. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18344. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18345. string strFileName = "HotelStatement/";
  18346. string guestNames = ""; //格式Mr.xxx Ms.xxx
  18347. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  18348. #region 数据处理
  18349. List<int> guestIds = new List<int>();
  18350. //int index = 0;
  18351. foreach (var item in hrDtas)
  18352. {
  18353. if (item.GuestName.Contains(","))
  18354. {
  18355. string[] guestIdArr = item.GuestName.Split(',');
  18356. foreach (var guestIdStr in guestIdArr)
  18357. {
  18358. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  18359. if (guestBool)
  18360. {
  18361. guestIds.Add(guestId);
  18362. }
  18363. }
  18364. }
  18365. else guestNames += item.GuestName;
  18366. var voucherInfo = new HotelVoucherInfoView()
  18367. {
  18368. HotelName = item.HotelName,
  18369. CheckInDate = item.CheckInDate,
  18370. CheckOutDate = item.CheckOutDate,
  18371. ConfirmationNumber = item.DetermineNo.Trim(),
  18372. RoomType = item.RoomExplanation
  18373. };
  18374. vouchers.Add(voucherInfo);
  18375. }
  18376. if (guestIds.Count > 0)
  18377. {
  18378. guestIds = guestIds.Distinct().ToList();
  18379. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  18380. if (guestDatas.Count > 0)
  18381. {
  18382. guestNames = "";
  18383. foreach (var guest in guestDatas)
  18384. {
  18385. string guestName = "";
  18386. if (guest.Sex == 0) guestName += @"MR.";
  18387. else if (guest.Sex == 1) guestName += @"MS.";
  18388. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18389. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18390. guestNames += @$"{guestName.Trim()}、";
  18391. }
  18392. if (guestNames.Length > 0)
  18393. {
  18394. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18395. }
  18396. }
  18397. }
  18398. #endregion
  18399. //载入模板
  18400. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  18401. Document doc = new Document(sss);
  18402. DocumentBuilder builder = new DocumentBuilder(doc);
  18403. if (doc.Range.Bookmarks["GuestName"] != null)
  18404. {
  18405. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  18406. mark.Text = guestNames;
  18407. }
  18408. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18409. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  18410. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  18411. for (int i = 1; i <= vouchers.Count; i++)
  18412. {
  18413. HotelVoucherInfoView hviv = vouchers[i - 1];
  18414. builder.MoveToCell(0, i, 0, 0);
  18415. builder.Write(hviv.HotelName);
  18416. builder.MoveToCell(0, i, 1, 0);
  18417. builder.Write(hviv.CheckInDate);
  18418. builder.MoveToCell(0, i, 2, 0);
  18419. builder.Write(hviv.CheckOutDate);
  18420. builder.MoveToCell(0, i, 3, 0);
  18421. builder.Write(hviv.RoomType);
  18422. builder.MoveToCell(0, i, 4, 0);
  18423. builder.Write(hviv.ConfirmationNumber);
  18424. }
  18425. //删除多余行
  18426. int currRowIndex = vouchers.Count + 1;
  18427. int delRows = 21 - currRowIndex;
  18428. if (delRows > 0)
  18429. {
  18430. for (int i = 0; i < delRows; i++)
  18431. {
  18432. table.Rows.RemoveAt(currRowIndex);
  18433. //cultivateRowIndex++;
  18434. }
  18435. }
  18436. strFileName += "VOUCHER.docx";
  18437. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18438. doc.Save(fileDir);
  18439. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18440. return Ok(JsonView(true, "操作成功!", Url));
  18441. }
  18442. /// <summary>
  18443. /// 酒店预订
  18444. /// 生成VOUCHER 批量生成
  18445. /// New
  18446. /// </summary>
  18447. /// <param name="_dto"></param>
  18448. /// <returns></returns>
  18449. [HttpPost]
  18450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18451. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  18452. {
  18453. #region 参数验证
  18454. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18455. if (_dto.PageId < 1) _dto.PageId = 28;
  18456. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18457. #region 团组操作权限验证 76 酒店预定模块
  18458. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18459. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18460. #endregion
  18461. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18462. #region 页面操作权限验证
  18463. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18464. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18465. #endregion
  18466. #endregion
  18467. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  18468. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  18469. .OrderBy(x => x.CheckInDate)
  18470. .ToListAsync();
  18471. //判断数据是否完整
  18472. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18473. string strFileName = "HotelStatement/";
  18474. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18475. if (dele != null)
  18476. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  18477. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  18478. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  18479. .Where(it => it.IsDel == 0)
  18480. .ToListAsync();
  18481. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  18482. for (int i = 0; i < hrDtas.Count; i++)
  18483. {
  18484. string guestNames = string.Empty;
  18485. List<int> guestIds = new List<int>();
  18486. var item = hrDtas[i];
  18487. //处理客户姓名
  18488. if (item.GuestName.Contains(","))
  18489. {
  18490. string[] guestIdArr = item.GuestName.Split(',');
  18491. foreach (var guestIdStr in guestIdArr)
  18492. if (int.TryParse(guestIdStr, out int guestId))
  18493. guestIds.Add(guestId);
  18494. }
  18495. else
  18496. {
  18497. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  18498. if (guestIdBool)
  18499. {
  18500. guestIds.Add(guestId);
  18501. }
  18502. //NaN
  18503. if (item.GuestName.Contains("NaN"))
  18504. {
  18505. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  18506. }
  18507. }
  18508. if (guestIds.Count > 0)
  18509. {
  18510. guestIds = guestIds.Distinct().ToList();
  18511. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  18512. if (guestDatas1.Count > 0)
  18513. {
  18514. guestNames = "";
  18515. foreach (var guest in guestDatas1)
  18516. {
  18517. string guestName = "";
  18518. if (guest.Sex == 0) guestName += @"MR.";
  18519. else if (guest.Sex == 1) guestName += @"MS.";
  18520. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18521. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18522. guestNames += @$"{guestName.Trim()}、";
  18523. }
  18524. if (guestNames.Length > 0)
  18525. {
  18526. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18527. }
  18528. }
  18529. }
  18530. //if (!string.IsNullOrEmpty(guestNames))
  18531. //{
  18532. hrDtas[i].GuestName = guestNames;
  18533. //}
  18534. }
  18535. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  18536. Document doc = new Document();
  18537. DocumentBuilder builder = new DocumentBuilder(doc);
  18538. try
  18539. {
  18540. builder.MoveToDocumentStart();
  18541. foreach (var item in hrDtas)
  18542. {
  18543. //标题
  18544. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  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.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18550. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  18551. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18552. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18553. builder.ParagraphFormat.LineSpacing = 1;
  18554. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18555. builder.ParagraphFormat.Style.Font.Size = 9;
  18556. builder.ParagraphFormat.Style.Font.Bold = true;
  18557. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  18558. builder.StartTable();
  18559. // 设置边框颜色
  18560. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  18561. //设置边框样式
  18562. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  18563. //表格
  18564. #region 第一行
  18565. builder.InsertCell();
  18566. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18567. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18568. //builder.CellFormat.AllowAutoFit = false;
  18569. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18570. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18571. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18572. builder.CellFormat.WrapText = true; //自动换行
  18573. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18574. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  18575. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18576. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18577. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18578. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18579. builder.Write("TOUR NO:");
  18580. builder.InsertCell();
  18581. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18582. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18583. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18584. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18585. builder.ParagraphFormat.Style.Font.Bold = false;
  18586. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18587. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18588. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18589. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18590. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18591. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18592. builder.Write($"{dele?.TourCode ?? "-"}");
  18593. builder.InsertCell();
  18594. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18595. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18596. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18597. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18598. builder.ParagraphFormat.Style.Font.Bold = false;
  18599. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18600. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18601. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18602. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18603. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18604. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18605. builder.Write($"CITY:");
  18606. builder.InsertCell();
  18607. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18608. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18609. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18610. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18611. builder.ParagraphFormat.Style.Font.Bold = false;
  18612. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18613. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18614. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18615. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18616. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18617. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18618. builder.Write($"{item.City}");
  18619. builder.EndRow();
  18620. #endregion
  18621. #region 第二行
  18622. builder.InsertCell();
  18623. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18624. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18625. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18626. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18627. builder.ParagraphFormat.Style.Font.Bold = false;
  18628. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18629. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18630. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18631. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18632. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18633. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18634. builder.Write("CONFIRMATION NO:");
  18635. builder.InsertCell();
  18636. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18637. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18638. builder.ParagraphFormat.Style.Font.Size = 8;
  18639. builder.ParagraphFormat.Style.Font.Bold = false;
  18640. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18641. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18642. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18643. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18644. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18645. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18646. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18647. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18648. builder.Write($"{item.DetermineNo}");
  18649. builder.InsertCell();
  18650. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18651. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18652. builder.InsertCell();
  18653. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18654. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18655. builder.EndRow();
  18656. #endregion
  18657. #region 第三行
  18658. builder.InsertCell();
  18659. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18660. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18661. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18662. builder.ParagraphFormat.Style.Font.Bold = false;
  18663. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18664. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18665. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18666. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18667. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18668. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18669. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18670. builder.Write($"HOTEL NAME:");
  18671. builder.InsertCell();
  18672. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18673. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18674. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18675. builder.ParagraphFormat.Style.Font.Bold = false;
  18676. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18677. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18678. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18679. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18680. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18681. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18682. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18683. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18684. builder.Write($"{item.HotelName}");
  18685. builder.InsertCell();
  18686. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18687. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18688. builder.InsertCell();
  18689. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18690. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18691. builder.EndRow();
  18692. #endregion
  18693. #region 第四行
  18694. builder.InsertCell();
  18695. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18696. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18697. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18698. builder.ParagraphFormat.Style.Font.Bold = false;
  18699. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18700. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18701. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18702. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18703. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18704. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18705. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18706. builder.Write($"HOTEL ADDRESS:");
  18707. builder.InsertCell();
  18708. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18709. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18710. builder.ParagraphFormat.Style.Font.Size = 8;
  18711. builder.ParagraphFormat.Style.Font.Bold = false;
  18712. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18713. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18714. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18715. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18716. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18717. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18718. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18719. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18720. builder.Write($"{item.HotelAddress}");
  18721. builder.InsertCell();
  18722. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18723. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18724. builder.InsertCell();
  18725. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18726. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18727. builder.EndRow();
  18728. #endregion
  18729. #region 第五行
  18730. builder.InsertCell();
  18731. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18732. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18733. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18734. builder.ParagraphFormat.Style.Font.Bold = false;
  18735. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18736. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18737. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18738. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18739. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18740. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18741. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18742. builder.Write("TEL:");
  18743. builder.InsertCell();
  18744. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18745. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18746. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18747. builder.ParagraphFormat.Style.Font.Bold = false;
  18748. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18749. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18750. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18751. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18752. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18753. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18754. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18755. builder.Write($"{item.HotelTel}");
  18756. builder.InsertCell();
  18757. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18758. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18759. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18760. builder.ParagraphFormat.Style.Font.Bold = false;
  18761. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18762. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18763. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18764. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18765. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18766. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18767. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18768. builder.Write($"FAX:");
  18769. builder.InsertCell();
  18770. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18771. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18772. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18773. builder.ParagraphFormat.Style.Font.Bold = false;
  18774. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18775. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18776. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18777. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18778. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18779. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18780. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18781. builder.Write($"{item.HotelFax}");
  18782. builder.EndRow();
  18783. #endregion
  18784. #region 第六行
  18785. builder.InsertCell();
  18786. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18787. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18788. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18789. builder.ParagraphFormat.Style.Font.Bold = false;
  18790. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18791. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18792. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18793. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18794. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18795. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18796. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18797. builder.Write("CHECK IN:");
  18798. builder.InsertCell();
  18799. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18800. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18801. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18802. builder.ParagraphFormat.Style.Font.Bold = false;
  18803. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18804. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18805. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18806. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18807. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18808. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18809. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18810. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  18811. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18812. builder.Write($"{checkInStr}");
  18813. builder.InsertCell();
  18814. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18815. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18816. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18817. builder.ParagraphFormat.Style.Font.Bold = false;
  18818. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18819. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18820. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18821. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18822. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18823. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18824. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18825. builder.Write($"CHECK OUT:");
  18826. builder.InsertCell();
  18827. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18828. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18829. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18830. builder.ParagraphFormat.Style.Font.Bold = false;
  18831. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18832. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18833. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18834. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18835. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18836. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18837. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18838. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  18839. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  18840. builder.Write($"{checkOutStr}");
  18841. builder.EndRow();
  18842. #endregion
  18843. #region 第七行
  18844. builder.InsertCell();
  18845. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18846. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18847. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18848. builder.ParagraphFormat.Style.Font.Bold = false;
  18849. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18850. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18851. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18852. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18853. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18854. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18855. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18856. builder.Write($"GUEST NAME:");
  18857. builder.InsertCell();
  18858. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18859. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18860. builder.ParagraphFormat.Style.Font.Size = 8;
  18861. builder.ParagraphFormat.Style.Font.Bold = false;
  18862. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18863. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18864. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18865. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18866. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18867. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18868. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18869. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18870. builder.Write($"{item.GuestName.Trim()}");
  18871. builder.InsertCell();
  18872. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18873. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18874. builder.InsertCell();
  18875. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18876. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18877. builder.EndRow();
  18878. #endregion
  18879. #region 第八行
  18880. builder.InsertCell();
  18881. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18882. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18883. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18884. builder.ParagraphFormat.Style.Font.Bold = false;
  18885. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18886. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18887. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18888. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18889. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18890. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18891. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18892. builder.Write($"ROOM TYPE:");
  18893. builder.InsertCell();
  18894. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18895. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18896. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18897. builder.ParagraphFormat.Style.Font.Bold = false;
  18898. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18899. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18900. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18901. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18902. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18903. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18904. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18905. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18906. builder.Write($"{item.RoomExplanation}");
  18907. builder.InsertCell();
  18908. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18909. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18910. builder.InsertCell();
  18911. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18912. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18913. builder.EndRow();
  18914. #endregion
  18915. #region 第九行
  18916. builder.InsertCell();
  18917. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18918. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18919. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18920. builder.ParagraphFormat.Style.Font.Bold = false;
  18921. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18922. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18923. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18924. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18925. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18926. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18927. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18928. builder.Write($"NOTE:");
  18929. builder.InsertCell();
  18930. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18931. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18932. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18933. builder.ParagraphFormat.Style.Font.Bold = false;
  18934. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18935. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18936. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18937. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18938. 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.");
  18939. builder.InsertCell();
  18940. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18941. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18942. builder.InsertCell();
  18943. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18944. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18945. builder.EndRow();
  18946. #endregion
  18947. builder.EndTable();
  18948. //换行
  18949. builder.Writeln("");
  18950. builder.Writeln("");
  18951. }
  18952. #region 获取文档中的所有表格 设置文字自适应
  18953. // 获取文档中的所有表格。
  18954. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18955. {
  18956. // 遍历表格中的所有行。
  18957. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18958. {
  18959. foreach (Cell cell in row.Cells)
  18960. {
  18961. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18962. cellFormat.Width = 0;
  18963. }
  18964. }
  18965. }
  18966. #endregion
  18967. #region 设置页眉
  18968. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18969. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18970. if (System.IO.File.Exists(voucherHeaderPath))
  18971. {
  18972. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18973. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18974. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18975. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18976. // 调整图片位置
  18977. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18978. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18979. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18980. shape.Left = 0; // 将图片距离页面左边缘的距离
  18981. shape.Width = 81; // 设置图片宽度
  18982. shape.Height = 36; // 设置图片高度
  18983. }
  18984. //靠右
  18985. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18986. //// 设置页脚上下边距
  18987. //builder.PageSetup.HeaderDistance = 42;
  18988. // 添加页眉线
  18989. Aspose.Words.Border borderHeader = null;
  18990. try
  18991. {
  18992. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18993. }
  18994. catch (Exception e)
  18995. {
  18996. // TODO Auto-generated catch block
  18997. //e.printStackTrace();
  18998. }
  18999. borderHeader.Shadow = true;
  19000. borderHeader.DistanceFromText = 2;
  19001. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  19002. #endregion
  19003. }
  19004. catch (Exception ex)
  19005. {
  19006. }
  19007. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19008. doc.Save(fileDir);
  19009. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19010. return Ok(JsonView(true, "操作成功!", Url));
  19011. }
  19012. /// <summary>
  19013. /// 酒店预订
  19014. /// 生成 预定成本 Excel
  19015. /// </summary>
  19016. /// <param name="_dto"></param>
  19017. /// <returns></returns>
  19018. [HttpPost]
  19019. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19020. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  19021. {
  19022. #region 参数验证
  19023. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  19024. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  19025. if (!vadalitorRes.IsValid)
  19026. {
  19027. var errors = new StringBuilder();
  19028. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  19029. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  19030. }
  19031. #region 团组操作权限验证 76 酒店预定模块
  19032. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19033. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  19034. #endregion
  19035. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19036. #region 页面操作权限验证
  19037. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19038. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19039. #endregion
  19040. #endregion
  19041. decimal _rate = 1.00M;
  19042. string _currency = string.Empty;
  19043. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  19044. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19045. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  19046. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19047. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  19048. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  19049. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  19050. if (_GroupCostParameter == null)
  19051. {
  19052. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  19053. bool isIntType = int.TryParse(_currency, out int currId);
  19054. if (isIntType)
  19055. {
  19056. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19057. }
  19058. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19059. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19060. if (currInfo == null)
  19061. {
  19062. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19063. }
  19064. else _rate = currInfo.Rate;
  19065. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  19066. {
  19067. _rate = _GroupCostParameter.Rate;
  19068. }
  19069. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19070. //string strFileName = "HotelStatement/";
  19071. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19072. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19073. var rateDatas = new List<dynamic>();
  19074. #region 数据处理
  19075. foreach (var item in hrDtas)
  19076. {
  19077. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19078. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19079. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19080. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19081. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19082. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  19083. {
  19084. continue;
  19085. }
  19086. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19087. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  19088. string singleRoomFeeStr = string.Empty,
  19089. doubleRoomFeeStr = string.Empty,
  19090. suiteRoomFeeStr = string.Empty,
  19091. otherRoomFeeStr = string.Empty,
  19092. payMoneyStr = string.Empty,
  19093. cardPriceStr = string.Empty;
  19094. if (roomCurr.Equals("CNY"))
  19095. {
  19096. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  19097. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19098. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19099. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19100. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19101. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  19102. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  19103. }
  19104. else
  19105. {
  19106. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19107. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19108. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19109. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19110. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19111. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19112. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19113. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19114. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19115. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19116. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  19117. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  19118. if (ccpPaymentCurrency.Equals("CNY"))
  19119. {
  19120. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  19121. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19122. }
  19123. else
  19124. {
  19125. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  19126. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  19127. }
  19128. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  19129. if (hotelcardPriceCurrency.Equals("CNY"))
  19130. {
  19131. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19132. }
  19133. else
  19134. {
  19135. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  19136. }
  19137. }
  19138. string breakfastPriceStr = string.Empty,
  19139. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19140. governmentRentStr = string.Empty,
  19141. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19142. cityTaxStr = string.Empty,
  19143. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19144. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  19145. if (!string.IsNullOrEmpty(breakfastCurrency1))
  19146. {
  19147. if (breakfastCurrency1.Equals("CNY"))
  19148. {
  19149. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19150. }
  19151. else
  19152. {
  19153. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  19154. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  19155. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  19156. }
  19157. }
  19158. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19159. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  19160. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  19161. {
  19162. if (governmentRentCurrency.Equals("CNY"))
  19163. {
  19164. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19165. }
  19166. else
  19167. {
  19168. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  19169. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  19170. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  19171. }
  19172. }
  19173. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19174. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  19175. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  19176. {
  19177. if (cityTaxStrCurrency1.Equals("CNY"))
  19178. {
  19179. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19180. }
  19181. else
  19182. {
  19183. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  19184. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  19185. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  19186. }
  19187. }
  19188. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19189. int payDId = roomInfo?.PayDId ?? 0;
  19190. pcfds.Add(new HotelReservations_PCFD_View()
  19191. {
  19192. City = item.City,
  19193. HotelName = item.HotelName,
  19194. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19195. // SingleRoomCount = item.SingleRoomCount,
  19196. SingleRoomPrice = singleRoomFeeStr,
  19197. // DoubleRoomCount = item.DoubleRoomCount,
  19198. DoubleRoomPrice = doubleRoomFeeStr,
  19199. //SuiteRoomCount = item.SuiteRoomCount,
  19200. SuiteRoomPrice = suiteRoomFeeStr,
  19201. OtherRoomPrice = otherRoomFeeStr,
  19202. //OtherRoomCount = item.OtherRoomCount,
  19203. BreakfastPrice = breakfastPriceStr,
  19204. GovernmentRent = governmentRentStr,
  19205. CityTax = cityTaxStr,
  19206. RoomExplanation = item.RoomExplanation,
  19207. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19208. PayTime = roomInfo?.ConsumptionDate,
  19209. BankNo = roomInfo?.BankNo,
  19210. PayMoney = payMoneyStr,
  19211. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19212. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19213. CardPrice = cardPriceStr,
  19214. Remark = ccpInfo.Remark
  19215. });
  19216. }
  19217. #endregion
  19218. //载入模板
  19219. WorkbookDesigner designer = new WorkbookDesigner();
  19220. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19221. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19222. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19223. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19224. var rateDatas1 = rateDatas.Distinct();
  19225. var rateStr = string.Empty;
  19226. foreach (var item in rateDatas1)
  19227. {
  19228. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  19229. }
  19230. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  19231. designer.SetDataSource("Opertor", userInfo.CnName);
  19232. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19233. dt.TableName = "ViewMyHotelReservations";
  19234. designer.SetDataSource(dt);
  19235. designer.Process();
  19236. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19237. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19238. designer.Workbook.Save(serverPath);
  19239. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19240. #region 删除指定行
  19241. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19242. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19243. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19244. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19245. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19246. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19247. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19248. cssIndex = dt.Columns["CityTax"].Ordinal,
  19249. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19250. remarkIndex = dt.Columns["Remark"].Ordinal;
  19251. //删除指定列
  19252. foreach (DataRow item in dt.Rows)
  19253. {
  19254. string singleStr = item["SingleRoomPrice"].ToString();
  19255. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19256. if (containsDigitButNotZero1) singleDel = false;
  19257. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19258. string doubleStr = item["DoubleRoomPrice"].ToString();
  19259. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19260. if (containsDigitButNotZero2) doubleDel = false;
  19261. string suiteStr = item["SuiteRoomPrice"].ToString();
  19262. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19263. if (containsDigitButNotZero3) suiteDel = false;
  19264. string otherStr = item["OtherRoomPrice"].ToString();
  19265. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19266. if (containsDigitButNotZero4) otherDel = false;
  19267. string zcStr = item["BreakfastPrice"].ToString();
  19268. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19269. if (containsDigitButNotZero5) zcDel = false;
  19270. string dsStr = item["GovernmentRent"].ToString();
  19271. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19272. if (containsDigitButNotZero6) dsDel = false;
  19273. string cssStr = item["CityTax"].ToString();
  19274. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19275. if (containsDigitButNotZero7) cssDel = false;
  19276. string cpStr = item["ConsumptionPatterns"].ToString();
  19277. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19278. string remarkStr = item["Remark"].ToString();
  19279. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19280. }
  19281. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19282. DeleteColumn(serverPath, cpIndex, cpDel);
  19283. DeleteColumn(serverPath, dsIndex, dsDel);
  19284. DeleteColumn(serverPath, cssIndex, cssDel);
  19285. DeleteColumn(serverPath, zcIndex, zcDel);
  19286. DeleteColumn(serverPath, otherIndex, otherDel);
  19287. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19288. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19289. DeleteColumn(serverPath, singleIndex, singleDel);
  19290. #endregion
  19291. //只保留第一个表格
  19292. DeleteSheet(serverPath);
  19293. return Ok(JsonView(true, "操作成功", url = rst));
  19294. }
  19295. else
  19296. {
  19297. _currency = _GroupCostParameter.Currency;
  19298. bool isIntType = int.TryParse(_currency, out int currId);
  19299. if (isIntType)
  19300. {
  19301. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19302. }
  19303. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19304. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19305. if (currInfo == null)
  19306. {
  19307. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19308. }
  19309. if (!_currency.ToUpper().Equals("CNY"))
  19310. {
  19311. _rate = _GroupCostParameter.Rate;
  19312. }
  19313. _rate = currInfo.Rate;
  19314. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19315. //string strFileName = "HotelStatement/";
  19316. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19317. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19318. #region 数据处理
  19319. foreach (var item in hrDtas)
  19320. {
  19321. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19322. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19323. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19324. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19325. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19326. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19327. string singleRoomFeeStr = string.Empty,
  19328. doubleRoomFeeStr = string.Empty,
  19329. suiteRoomFeeStr = string.Empty,
  19330. otherRoomFeeStr = string.Empty,
  19331. payMoneyStr = string.Empty,
  19332. cardPriceStr = string.Empty;
  19333. if (roomCurr.Equals(_currency))
  19334. {
  19335. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  19336. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  19337. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  19338. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  19339. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  19340. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  19341. }
  19342. else
  19343. {
  19344. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19345. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19346. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19347. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19348. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19349. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19350. }
  19351. string breakfastPriceStr = string.Empty,
  19352. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19353. governmentRentStr = string.Empty,
  19354. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19355. cityTaxStrStr = string.Empty,
  19356. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19357. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  19358. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  19359. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  19360. int payDId = roomInfo?.PayDId ?? 0;
  19361. pcfds.Add(new HotelReservations_PCFD_View()
  19362. {
  19363. City = item.City,
  19364. HotelName = item.HotelName,
  19365. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19366. // SingleRoomCount = item.SingleRoomCount,
  19367. SingleRoomPrice = singleRoomFeeStr,
  19368. // DoubleRoomCount = item.DoubleRoomCount,
  19369. DoubleRoomPrice = doubleRoomFeeStr,
  19370. //SuiteRoomCount = item.SuiteRoomCount,
  19371. SuiteRoomPrice = suiteRoomFeeStr,
  19372. OtherRoomPrice = otherRoomFeeStr,
  19373. //OtherRoomCount = item.OtherRoomCount,
  19374. BreakfastPrice = breakfastPriceStr,
  19375. GovernmentRent = governmentRentStr,
  19376. CityTax = cityTaxStrStr,
  19377. RoomExplanation = item.RoomExplanation,
  19378. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19379. PayTime = roomInfo?.ConsumptionDate,
  19380. BankNo = roomInfo?.BankNo,
  19381. PayMoney = payMoneyStr,
  19382. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19383. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19384. CardPrice = cardPriceStr,
  19385. Remark = ccpInfo.Remark
  19386. });
  19387. }
  19388. #endregion
  19389. //载入模板
  19390. WorkbookDesigner designer = new WorkbookDesigner();
  19391. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19392. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19393. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19394. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19395. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  19396. designer.SetDataSource("Opertor", userInfo.CnName);
  19397. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19398. dt.TableName = "ViewMyHotelReservations";
  19399. designer.SetDataSource(dt);
  19400. designer.Process();
  19401. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19402. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19403. designer.Workbook.Save(serverPath);
  19404. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19405. #region 删除指定行
  19406. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19407. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19408. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19409. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19410. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19411. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19412. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19413. cssIndex = dt.Columns["CityTax"].Ordinal,
  19414. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19415. remarkIndex = dt.Columns["Remark"].Ordinal;
  19416. //删除指定列
  19417. foreach (DataRow item in dt.Rows)
  19418. {
  19419. string singleStr = item["SingleRoomPrice"].ToString();
  19420. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19421. if (containsDigitButNotZero1) singleDel = false;
  19422. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19423. string doubleStr = item["DoubleRoomPrice"].ToString();
  19424. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19425. if (containsDigitButNotZero2) doubleDel = false;
  19426. string suiteStr = item["SuiteRoomPrice"].ToString();
  19427. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19428. if (containsDigitButNotZero3) suiteDel = false;
  19429. string otherStr = item["OtherRoomPrice"].ToString();
  19430. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19431. if (containsDigitButNotZero4) otherDel = false;
  19432. string zcStr = item["BreakfastPrice"].ToString();
  19433. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19434. if (containsDigitButNotZero5) zcDel = false;
  19435. string dsStr = item["GovernmentRent"].ToString();
  19436. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19437. if (containsDigitButNotZero6) dsDel = false;
  19438. string cssStr = item["CityTax"].ToString();
  19439. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19440. if (containsDigitButNotZero7) cssDel = false;
  19441. string cpStr = item["ConsumptionPatterns"].ToString();
  19442. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19443. string remarkStr = item["Remark"].ToString();
  19444. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19445. }
  19446. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19447. DeleteColumn(serverPath, cpIndex, cpDel);
  19448. DeleteColumn(serverPath, dsIndex, dsDel);
  19449. DeleteColumn(serverPath, cssIndex, cssDel);
  19450. DeleteColumn(serverPath, zcIndex, zcDel);
  19451. DeleteColumn(serverPath, otherIndex, otherDel);
  19452. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19453. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19454. DeleteColumn(serverPath, singleIndex, singleDel);
  19455. #endregion
  19456. //只保留第一个表格
  19457. DeleteSheet(serverPath);
  19458. return Ok(JsonView(true, "操作成功", url = rst));
  19459. }
  19460. //return Ok(JsonView(false));
  19461. }
  19462. /// <summary>
  19463. /// 删除指定列
  19464. /// </summary>
  19465. /// <param name="file"></param>
  19466. /// <param name="columnIndex"></param>
  19467. /// <param name="isDel"></param>
  19468. private void DeleteColumn(string file, int columnIndex, bool isDel)
  19469. {
  19470. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19471. //wb.Save(file);
  19472. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  19473. if (sheet1 != null)
  19474. {
  19475. if (isDel)
  19476. {
  19477. Cells cells = sheet1.Cells;
  19478. cells.DeleteColumn(columnIndex);
  19479. }
  19480. }
  19481. wb.Save(file);
  19482. }
  19483. /// <summary>
  19484. /// 删除sheet
  19485. /// </summary>
  19486. /// <param name="file"></param>
  19487. private void DeleteSheet(string file)
  19488. {
  19489. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19490. //wb.Save(file);
  19491. List<string> sheets = new List<string>();
  19492. foreach (var item in wb.Worksheets)
  19493. {
  19494. sheets.Add(item.Name);
  19495. }
  19496. if (sheets.Count > 0)
  19497. {
  19498. sheets.RemoveAt(0);//不删除第一个sheet
  19499. foreach (var item in sheets)
  19500. {
  19501. wb.Worksheets.RemoveAt(item);
  19502. }
  19503. }
  19504. wb.Save(file);
  19505. }
  19506. /// <summary>
  19507. /// 酒店预订
  19508. /// 确认单
  19509. /// </summary>
  19510. /// <param name="_dto"></param>
  19511. /// <returns></returns>
  19512. [HttpPost]
  19513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19514. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  19515. {
  19516. try
  19517. {
  19518. #region 参数验证
  19519. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19520. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19521. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19522. #region 团组操作权限验证 76 酒店预定模块
  19523. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19524. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19525. #endregion
  19526. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19527. #region 页面操作权限验证
  19528. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19529. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19530. #endregion
  19531. #endregion
  19532. //团组信息
  19533. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  19534. //酒店数据
  19535. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  19536. if (listhoteldata.Count < 0)
  19537. {
  19538. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  19539. }
  19540. //利datatable存储
  19541. DataTable dt = new DataTable();
  19542. dt.Columns.Add("CheckInDate", typeof(string));
  19543. dt.Columns.Add("City", typeof(string));
  19544. dt.Columns.Add("Hotel", typeof(string));
  19545. dt.Columns.Add("Room", typeof(string));
  19546. for (int i = 0; i < listhoteldata.Count; i++)
  19547. {
  19548. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  19549. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  19550. while (dayStart < dayEnd)
  19551. {
  19552. string temp = "";
  19553. DataRow row = dt.NewRow();
  19554. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  19555. row["City"] = listhoteldata[i].City;
  19556. row["Hotel"] = listhoteldata[i].HotelName;
  19557. if (listhoteldata[i].SingleRoomCount > 0)
  19558. {
  19559. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  19560. }
  19561. if (listhoteldata[i].DoubleRoomCount > 0)
  19562. {
  19563. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  19564. }
  19565. if (listhoteldata[i].SuiteRoomCount > 0)
  19566. {
  19567. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  19568. }
  19569. if (listhoteldata[i].OtherRoomCount > 0)
  19570. {
  19571. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  19572. }
  19573. row["Room"] = temp;
  19574. dt.Rows.Add(row);
  19575. dayStart = dayStart.AddDays(1);
  19576. }
  19577. }
  19578. Dictionary<string, string> dic = new Dictionary<string, string>();
  19579. dic.Add("Dele", di.TeamName);
  19580. dic.Add("City", di.VisitCountry);
  19581. //模板路径
  19582. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  19583. //载入模板
  19584. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  19585. DocumentBuilder builder = new DocumentBuilder(doc);
  19586. foreach (var key in dic.Keys)
  19587. {
  19588. builder.MoveToBookmark(key);
  19589. builder.Write(dic[key]);
  19590. }
  19591. //获取word里所有表格
  19592. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19593. //获取所填表格的序数
  19594. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19595. var rowStart = tableOne.Rows[0]; //获取第1行
  19596. //循环赋值
  19597. for (int i = 0; i < dt.Rows.Count; i++)
  19598. {
  19599. builder.MoveToCell(0, i + 1, 0, 0);
  19600. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  19601. builder.MoveToCell(0, i + 1, 1, 0);
  19602. builder.Write(dt.Rows[i]["City"].ToString());
  19603. builder.MoveToCell(0, i + 1, 2, 0);
  19604. builder.Write(dt.Rows[i]["Hotel"].ToString());
  19605. builder.MoveToCell(0, i + 1, 3, 0);
  19606. builder.Write(dt.Rows[i]["Room"].ToString());
  19607. }
  19608. //删除多余行
  19609. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  19610. {
  19611. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  19612. }
  19613. string strFileName = di.TeamName + "酒店确认单.doc";
  19614. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  19615. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  19616. return Ok(JsonView(true, "成功", url));
  19617. }
  19618. catch (Exception ex)
  19619. {
  19620. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  19621. }
  19622. }
  19623. #endregion
  19624. #region 团组状态
  19625. /// <summary>
  19626. /// 团组状态列表 Page
  19627. /// </summary>
  19628. /// <param name="dto">团组列表请求dto</param>
  19629. /// <returns></returns>
  19630. [HttpPost]
  19631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19632. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  19633. {
  19634. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19635. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  19636. {
  19637. string sqlWhere = string.Empty;
  19638. if (dto.IsSure == 0) //未完成
  19639. {
  19640. sqlWhere += string.Format(@" And IsSure = 0");
  19641. }
  19642. else if (dto.IsSure == 1) //已完成
  19643. {
  19644. sqlWhere += string.Format(@" And IsSure = 1");
  19645. }
  19646. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  19647. {
  19648. string tj = dto.SearchCriteria;
  19649. 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}%')",
  19650. tj, tj, tj, tj, tj);
  19651. }
  19652. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  19653. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  19654. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  19655. From (
  19656. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  19657. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  19658. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  19659. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  19660. From Grp_DelegationInfo gdi
  19661. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  19662. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  19663. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  19664. Where gdi.IsDel = 0 {0}
  19665. ) temp ", sqlWhere);
  19666. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  19667. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  19668. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  19669. }
  19670. else
  19671. {
  19672. return Ok(JsonView(false, "查询失败"));
  19673. }
  19674. }
  19675. /// <summary>
  19676. /// 团组状态
  19677. /// 设置操作完成
  19678. /// </summary>
  19679. /// <param name="dto">团组列表请求dto</param>
  19680. /// <returns></returns>
  19681. [HttpPost]
  19682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19683. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  19684. {
  19685. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19686. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  19687. {
  19688. Id = dto.Id,
  19689. IsSure = 1
  19690. };
  19691. var result = await _sqlSugar.Updateable(_DelegationInfo)
  19692. .UpdateColumns(it => new { it.IsSure })
  19693. .WhereColumns(it => new { it.Id })
  19694. .ExecuteCommandAsync();
  19695. if (result > 0)
  19696. {
  19697. return Ok(JsonView(true, "操作完成!"));
  19698. }
  19699. return Ok(JsonView(false, "操作失败!"));
  19700. }
  19701. #endregion
  19702. #region 保险费用录入
  19703. /// <summary>
  19704. /// 根据团组Id查询保险费用列表
  19705. /// </summary>
  19706. /// <param name="dto"></param>
  19707. /// <returns></returns>
  19708. [HttpPost]
  19709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19710. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  19711. {
  19712. Result groupData = await _customersRep.CustomersByDiId(dto);
  19713. if (groupData.Code != 0)
  19714. {
  19715. return Ok(JsonView(false, groupData.Msg));
  19716. }
  19717. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19718. }
  19719. /// <summary>
  19720. /// 根据保险费用Id查询保险费用详细
  19721. /// </summary>
  19722. /// <param name="dto"></param>
  19723. /// <returns></returns>
  19724. [HttpPost]
  19725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19726. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  19727. {
  19728. try
  19729. {
  19730. Result groupData = await _customersRep.CustomersById(dto);
  19731. if (groupData.Code != 0)
  19732. {
  19733. return Ok(JsonView(false, groupData.Msg));
  19734. }
  19735. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19736. }
  19737. catch (Exception ex)
  19738. {
  19739. return Ok(JsonView(false, ex.Message));
  19740. }
  19741. }
  19742. /// <summary>
  19743. /// 保险费用录入页面初始化绑定
  19744. /// </summary>
  19745. /// <param name="dto"></param>
  19746. /// <returns></returns>
  19747. [HttpPost]
  19748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19749. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  19750. {
  19751. try
  19752. {
  19753. Result groupData = await _customersRep.CustomersInitialize(dto);
  19754. if (groupData.Code != 0)
  19755. {
  19756. return Ok(JsonView(false, groupData.Msg));
  19757. }
  19758. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19759. }
  19760. catch (Exception ex)
  19761. {
  19762. return Ok(JsonView(false, ex.Message));
  19763. }
  19764. }
  19765. /// <summary>
  19766. /// 保险费用操作(Status:1.新增,2.修改)
  19767. /// </summary>
  19768. /// <param name="dto"></param>
  19769. /// <returns></returns>
  19770. [HttpPost]
  19771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19772. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  19773. {
  19774. Result groupData = await _customersRep.OpCustomers(dto);
  19775. if (groupData.Code != 0)
  19776. {
  19777. return Ok(JsonView(false, groupData.Msg));
  19778. }
  19779. #region 应用推送
  19780. try
  19781. {
  19782. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  19783. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  19784. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  19785. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19786. //自动审核
  19787. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  19788. //2024-10-21 新增LZ UID
  19789. var userIds = new List<int>() { 21 };
  19790. string title = $"系统通知";
  19791. var diId = dto.DiId;
  19792. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19793. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19794. string content = "";
  19795. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19796. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19797. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19798. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  19799. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  19800. }
  19801. catch (Exception ex)
  19802. {
  19803. }
  19804. #endregion
  19805. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19806. }
  19807. /// <summary>
  19808. /// 保险文件上传
  19809. /// </summary>
  19810. /// <param name="file"></param>
  19811. /// <returns></returns>
  19812. [HttpPost]
  19813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19814. public async Task<IActionResult> UploadCus(IFormFile file)
  19815. {
  19816. try
  19817. {
  19818. if (file != null)
  19819. {
  19820. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19821. //文件名称
  19822. string projectFileName = file.FileName;
  19823. //上传的文件的路径
  19824. string filePath = "";
  19825. if (!Directory.Exists(fileDir))
  19826. {
  19827. Directory.CreateDirectory(fileDir);
  19828. }
  19829. //上传的文件的路径
  19830. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  19831. using (FileStream fs = System.IO.File.Create(filePath))
  19832. {
  19833. file.CopyTo(fs);
  19834. fs.Flush();
  19835. }
  19836. return Ok(JsonView(true, "上传成功!", projectFileName));
  19837. }
  19838. else
  19839. {
  19840. return Ok(JsonView(false, "上传失败!"));
  19841. }
  19842. }
  19843. catch (Exception ex)
  19844. {
  19845. return Ok(JsonView(false, ex.Message));
  19846. }
  19847. }
  19848. /// <summary>
  19849. /// 保险删除指定文件
  19850. /// </summary>
  19851. /// <param name="dto"></param>
  19852. /// <returns></returns>
  19853. [HttpPost]
  19854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19855. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  19856. {
  19857. try
  19858. {
  19859. string filePath = "";
  19860. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19861. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19862. //int id = 0;
  19863. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19864. // 删除该文件
  19865. try
  19866. {
  19867. System.IO.File.Delete(filePath);
  19868. 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()
  19869. {
  19870. Attachment = "",
  19871. }).ExecuteCommandAsync();
  19872. if (result != 0)
  19873. {
  19874. return Ok(JsonView(true, "成功!"));
  19875. }
  19876. else
  19877. {
  19878. return Ok(JsonView(false, "失败!"));
  19879. }
  19880. }
  19881. catch (Exception)
  19882. {
  19883. 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()
  19884. {
  19885. Attachment = "",
  19886. }).ExecuteCommandAsync();
  19887. if (result != 0)
  19888. {
  19889. return Ok(JsonView(true, "成功!"));
  19890. }
  19891. else
  19892. {
  19893. return Ok(JsonView(false, "失败!"));
  19894. }
  19895. }
  19896. }
  19897. catch (Exception ex)
  19898. {
  19899. return Ok(JsonView(false, "程序错误!"));
  19900. throw;
  19901. }
  19902. }
  19903. /// <summary>
  19904. /// 保险费用操作(删除)
  19905. /// </summary>
  19906. /// <param name="dto"></param>
  19907. /// <returns></returns>
  19908. [HttpPost]
  19909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19910. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19911. {
  19912. try
  19913. {
  19914. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19915. if (!res)
  19916. {
  19917. return Ok(JsonView(false, "删除失败"));
  19918. }
  19919. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19920. {
  19921. IsDel = 1,
  19922. DeleteUserId = dto.DeleteUserId,
  19923. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19924. }).ExecuteCommandAsync();
  19925. return Ok(JsonView(true, "删除成功!"));
  19926. }
  19927. catch (Exception ex)
  19928. {
  19929. return Ok(JsonView(false, "程序错误!"));
  19930. throw;
  19931. }
  19932. }
  19933. #endregion
  19934. #region 接团客户名单 PageId 104
  19935. /// <summary>
  19936. /// 接团客户名单
  19937. /// 迁移数据(慎用!)
  19938. /// </summary>
  19939. /// <returns></returns>
  19940. [HttpPost]
  19941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19942. public async Task<IActionResult> PostTourClientListChange()
  19943. {
  19944. try
  19945. {
  19946. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19947. //var groupClinetData1
  19948. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19949. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19950. int updateCount = 0;
  19951. if (oldOAClientList.Count > 0)
  19952. {
  19953. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19954. _sqlSugar.BeginTran();
  19955. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19956. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19957. foreach (var item in oldOAClientList)
  19958. {
  19959. int comId = 0;
  19960. string format = "yyyy-MM-dd HH:mm:ss";
  19961. string data11 = "1990-01-01 00:00";
  19962. var data1 = IsValidDate(item.OPdate, format);
  19963. if (data1) data11 = item.OPdate;
  19964. //客户公司验证
  19965. if (!string.IsNullOrEmpty(item.Company))
  19966. {
  19967. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19968. if (clientComInfo == null) // add
  19969. {
  19970. var addInfo = new Crm_CustomerCompany()
  19971. {
  19972. CompanyAbbreviation = "",
  19973. CompanyFullName = item.Company,
  19974. Address = "",
  19975. PostCodes = "",
  19976. LastedOpUserId = item.OPer,
  19977. LastedOpDt = Convert.ToDateTime(data11),
  19978. CreateUserId = item.OPer,
  19979. CreateTime = Convert.ToDateTime(data11),
  19980. IsDel = 0
  19981. };
  19982. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19983. if (comId1 > 0) comId = comId1;
  19984. }
  19985. else comId = clientComInfo.Id;
  19986. }
  19987. //客户人员验证
  19988. int clientId = 0;
  19989. string name = item.LastName + item.Name;
  19990. if (!string.IsNullOrEmpty(name))
  19991. {
  19992. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19993. if (clientInfo == null)
  19994. {
  19995. DateTime? dateTime = null;
  19996. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19997. if (isDt) dateTime = birthDayDt;
  19998. var addInfo1 = new Crm_DeleClient()
  19999. {
  20000. CrmCompanyId = comId,
  20001. DiId = -1,
  20002. LastName = item.LastName,
  20003. FirstName = item.Name,
  20004. OldName = "",
  20005. Pinyin = item.Pinyin,
  20006. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  20007. Marriage = 0,
  20008. Phone = item.Phone,
  20009. Job = item.Job,
  20010. BirthDay = dateTime
  20011. };
  20012. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  20013. if (clientId1 > 0) clientId = clientId1;
  20014. }
  20015. else clientId = clientInfo.Id;
  20016. }
  20017. if (clientId < 1)
  20018. {
  20019. continue;
  20020. }
  20021. int airType = 0;
  20022. if (item.AirType == "超经舱") airType = 459;
  20023. else if (item.AirType == "公务舱") airType = 458;
  20024. else if (item.AirType == "经济舱") airType = 460;
  20025. else if (item.AirType == "其他") airType = 565;
  20026. else if (item.AirType == "头等舱") airType = 457;
  20027. var _TourClientListEntity = new Grp_TourClientList()
  20028. {
  20029. DiId = item.Diid,
  20030. ClientId = clientId,
  20031. CreateUserId = item.OPer,
  20032. CreateTime = Convert.ToDateTime(data11),
  20033. Remark = item.Remark,
  20034. IsDel = item.Isdel,
  20035. ShippingSpaceTypeId = airType,
  20036. ShippingSpaceSpecialNeeds = item.AirRemark,
  20037. HotelSpecialNeeds = item.RoomType
  20038. };
  20039. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  20040. if (_TourClientList > 0)
  20041. {
  20042. updateCount++;
  20043. }
  20044. }
  20045. _sqlSugar.CommitTran();
  20046. }
  20047. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  20048. }
  20049. catch (Exception ex)
  20050. {
  20051. _sqlSugar.RollbackTran();
  20052. return Ok(JsonView(false, ex.Message));
  20053. }
  20054. //return Ok(JsonView(true));
  20055. }
  20056. private bool IsValidDate(string dateString, string format)
  20057. {
  20058. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  20059. }
  20060. /// <summary>
  20061. /// 接团客户名单
  20062. /// 根据团组Id查询List
  20063. /// </summary>
  20064. /// <param name="_dto"></param>
  20065. /// <returns></returns>
  20066. [HttpPost]
  20067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20068. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  20069. {
  20070. #region 参数验证
  20071. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  20072. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  20073. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  20074. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20075. #region 页面操作权限验证
  20076. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20077. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20078. #endregion
  20079. #endregion
  20080. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  20081. if (viewData.Code != 0)
  20082. {
  20083. return Ok(JsonView(false, viewData.Msg));
  20084. }
  20085. return Ok(JsonView(viewData.Data));
  20086. }
  20087. /// <summary>
  20088. /// 接团客户名单
  20089. /// 基础数据 Init
  20090. /// </summary>
  20091. /// <param name="_dto"></param>
  20092. /// <returns></returns>
  20093. [HttpPost]
  20094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20095. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  20096. {
  20097. #region 参数验证
  20098. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20099. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20100. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20101. #region 页面操作权限验证
  20102. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20103. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20104. #endregion
  20105. #endregion
  20106. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  20107. }
  20108. /// <summary>
  20109. /// 接团客户名单
  20110. /// 根据 Id查询 Details
  20111. /// </summary>
  20112. /// <param name="_dto"></param>
  20113. /// <returns></returns>
  20114. [HttpPost]
  20115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20116. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  20117. {
  20118. #region 参数验证
  20119. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20120. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20121. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20122. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20123. #region 页面操作权限验证
  20124. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20125. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20126. #endregion
  20127. #endregion
  20128. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  20129. if (viewData.Code != 0)
  20130. {
  20131. return Ok(JsonView(false, viewData.Msg));
  20132. }
  20133. return Ok(JsonView(viewData.Data));
  20134. }
  20135. /// <summary>
  20136. /// 接团客户名单
  20137. /// Add Or Edit
  20138. /// </summary>
  20139. /// <param name="_dto"></param>
  20140. /// <returns></returns>
  20141. [HttpPost]
  20142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20143. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  20144. {
  20145. #region 参数验证
  20146. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20147. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20148. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20149. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20150. #region 页面操作权限验证
  20151. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20152. if (_dto.Id == 0) //添加
  20153. {
  20154. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20155. }
  20156. else if (_dto.Id >= 0) //修改
  20157. {
  20158. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  20159. }
  20160. #endregion
  20161. #endregion
  20162. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  20163. if (viewData.Code != 0)
  20164. {
  20165. return Ok(JsonView(false, viewData.Msg));
  20166. }
  20167. return Ok(JsonView(true));
  20168. }
  20169. /// <summary>
  20170. /// 接团客户名单
  20171. /// json字符串 AddMultiple(添加多个)
  20172. /// </summary>
  20173. /// <param name="_dto"></param>
  20174. /// <returns></returns>
  20175. [HttpPost]
  20176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20177. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  20178. {
  20179. #region 参数验证
  20180. string jsonLabel = _dto.JsonLabel;
  20181. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20182. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20183. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20184. #region 页面操作权限验证
  20185. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20186. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20187. #endregion
  20188. #endregion
  20189. var request = new TourClientListAddMultipleDto();
  20190. request.DiId = _dto.DiId;
  20191. request.UserId = _dto.UserId;
  20192. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  20193. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  20194. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  20195. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  20196. var infos = new List<TourClientListInfo>();
  20197. foreach (var data in datas)
  20198. {
  20199. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  20200. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  20201. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  20202. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  20203. {
  20204. continue;
  20205. }
  20206. infos.Add(new TourClientListInfo()
  20207. {
  20208. IsAccompany = 1,
  20209. LastName = lastName,
  20210. FirstName = firstName,
  20211. Pinyin = lastNameEn + @"/" + firstNameEn,
  20212. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  20213. CompanyFullName = data.CompanyFullName,
  20214. Job = data.Job
  20215. });
  20216. }
  20217. if (infos.Any())
  20218. {
  20219. var viewData = await _tourClientListRep._AddMultiple(request);
  20220. if (viewData.Code != 0)
  20221. {
  20222. return Ok(JsonView(false, viewData.Msg));
  20223. }
  20224. return Ok(JsonView(true));
  20225. }
  20226. return Ok(JsonView(false));
  20227. }
  20228. /// <summary>
  20229. /// 接团客户名单
  20230. /// AddMultiple(添加多个)
  20231. /// </summary>
  20232. /// <param name="_dto"></param>
  20233. /// <returns></returns>
  20234. [HttpPost]
  20235. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20236. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  20237. {
  20238. #region 参数验证
  20239. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20240. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20241. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20242. #region 页面操作权限验证
  20243. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20244. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20245. #endregion
  20246. #endregion
  20247. var viewData = await _tourClientListRep._AddMultiple(_dto);
  20248. if (viewData.Code != 0)
  20249. {
  20250. return Ok(JsonView(false, viewData.Msg));
  20251. }
  20252. return Ok(JsonView(true));
  20253. }
  20254. /// <summary>
  20255. /// 接团客户名单
  20256. /// Del
  20257. /// </summary>
  20258. /// <param name="_dto"></param>
  20259. /// <returns></returns>
  20260. [HttpPost]
  20261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20262. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  20263. {
  20264. #region 参数验证
  20265. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20266. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20267. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20268. #region 页面操作权限验证
  20269. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20270. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20271. #endregion
  20272. #endregion
  20273. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  20274. if (viewData.Code != 0)
  20275. {
  20276. return Ok(JsonView(false, viewData.Msg));
  20277. }
  20278. return Ok(JsonView(true));
  20279. }
  20280. /// <summary>
  20281. /// 接团客户名单
  20282. /// 文件下载 客户名单
  20283. /// </summary>
  20284. /// <param name="_dto"></param>
  20285. /// <returns></returns>
  20286. [HttpPost]
  20287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20288. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  20289. {
  20290. #region 参数验证
  20291. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20292. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20293. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  20294. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20295. #region 页面操作权限验证
  20296. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20297. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20298. #endregion
  20299. #endregion
  20300. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  20301. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  20302. From Grp_TourClientList tcl
  20303. Left Join
  20304. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  20305. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  20306. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  20307. From Crm_DeleClient dc
  20308. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  20309. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  20310. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  20311. Where dc.IsDel = 0) temp
  20312. On temp.DcId =tcl.ClientId
  20313. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  20314. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  20315. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  20316. //载入模板
  20317. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  20318. if (_dto.Language == 1)
  20319. {
  20320. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  20321. }
  20322. //载入模板
  20323. var doc = new Document(tempPath);
  20324. DocumentBuilder builder = new DocumentBuilder(doc);
  20325. //获取word里所有表格
  20326. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20327. //获取所填表格的序数
  20328. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20329. var rowStart = tableOne.Rows[0]; //获取第1行
  20330. if (_dto.Language == 0)
  20331. {
  20332. //循环赋值
  20333. for (int i = 0; i < DcList.Count; i++)
  20334. {
  20335. EncryptionProcessor.DecryptProperties(DcList[i]);
  20336. builder.MoveToCell(0, i + 1, 0, 0);
  20337. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  20338. builder.MoveToCell(0, i + 1, 1, 0);
  20339. int sex = DcList[i].Sex;
  20340. string sexStr = string.Empty;
  20341. if (sex == 0) sexStr = "男";
  20342. else if (sex == 1) sexStr = "女";
  20343. else sexStr = "未设置";
  20344. builder.Write(sexStr);
  20345. builder.MoveToCell(0, i + 1, 2, 0);
  20346. string birthDay = DcList[i].BirthDay;
  20347. string birthDayStr = string.Empty;
  20348. if (!string.IsNullOrEmpty(birthDay))
  20349. {
  20350. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  20351. }
  20352. builder.Write(birthDayStr);
  20353. builder.MoveToCell(0, i + 1, 3, 0);
  20354. string company = "";
  20355. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20356. {
  20357. company = DcList[i].CompanyFullName.ToString();
  20358. }
  20359. builder.Write(company);
  20360. builder.MoveToCell(0, i + 1, 4, 0);
  20361. builder.Write(DcList[i].Job);
  20362. }
  20363. }
  20364. else if (_dto.Language == 1)
  20365. {
  20366. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  20367. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  20368. List<string> transArrayStr = new List<string>();
  20369. string transStrRes1 = "";
  20370. for (int i = 0; i < DcList.Count; i++)
  20371. {
  20372. var dc = DcList[i];
  20373. EncryptionProcessor.DecryptProperties(dc);
  20374. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  20375. if (dc.Job.Equals("暂无")) dc.Job = "-";
  20376. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  20377. if (DcList.Count - 1 == i) transStrRes1 += str1;
  20378. else transStrRes1 += $"{str1}|";
  20379. }
  20380. #region AI转英文
  20381. string jsonValue = JsonConvert.SerializeObject(DcList);
  20382. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  20383. List<SeedMessages> messages = new List<SeedMessages>()
  20384. {
  20385. new SeedMessages
  20386. {
  20387. Role = KimiRole.user,
  20388. Content = jsonValue + text
  20389. }
  20390. };
  20391. KiMiApiClient client = new KiMiApiClient();
  20392. var kimiApiResult = await client.SeedMessage(messages);
  20393. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20394. string clients = kimiApiResult_JObject["content"].ToString();
  20395. string startStr = "```json", endStr = "```";
  20396. // 判断并清除开头部分
  20397. if (clients.StartsWith(startStr))
  20398. {
  20399. clients = clients.Remove(0, startStr.Length);
  20400. }
  20401. // 判断并清除结尾部分
  20402. if (clients.EndsWith(endStr))
  20403. {
  20404. clients = clients.Remove(clients.Length - endStr.Length);
  20405. }
  20406. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  20407. //循环赋值
  20408. for (int i = 0; i < en_Json.Count; i++)
  20409. {
  20410. var dc = en_Json[i];
  20411. var dc1 = DcList.Find(x => x.Id == dc.Id);
  20412. string PYName = dc.FirstName + " " + dc.LastName;
  20413. builder.MoveToCell(0, i + 1, 0, 0);
  20414. builder.Write(PYName);
  20415. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  20416. builder.MoveToCell(0, i + 1, 1, 0);
  20417. builder.Write(sex);
  20418. DateTime birthDt;
  20419. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  20420. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20421. builder.MoveToCell(0, i + 1, 2, 0);
  20422. builder.Write(birthday);
  20423. string company = string.Empty, job = string.Empty;
  20424. company = dc.CompanyFullName;
  20425. job = dc.Job;
  20426. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  20427. {
  20428. //查询对照表
  20429. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  20430. if (tempCec != null)
  20431. {
  20432. company = tempCec.enName;
  20433. }
  20434. }
  20435. builder.MoveToCell(0, i + 1, 3, 0);
  20436. builder.Write(company);
  20437. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  20438. {
  20439. //查询对照表
  20440. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  20441. if (tempPec != null)
  20442. {
  20443. job = tempPec.enName;
  20444. }
  20445. }
  20446. builder.MoveToCell(0, i + 1, 4, 0);
  20447. builder.Write(job);
  20448. }
  20449. #endregion
  20450. #region 旧翻译英文处理
  20451. ////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";
  20452. //string transStrRes = "";
  20453. //if (transStrRes1.Length > 0)
  20454. //{
  20455. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  20456. //}
  20457. ////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
  20458. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  20459. ////List<string> transArray = new List<string> { };
  20460. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  20461. //if (transStrRes.Contains("|"))
  20462. //{
  20463. // string[] transArray1 = transStrRes.Split('|');
  20464. // if (transArray1.Length > 0)
  20465. // {
  20466. // foreach (var item in transArray1)
  20467. // {
  20468. // if (item.Contains("&"))
  20469. // {
  20470. // string[] transArray2 = item.Split('&');
  20471. // int index = 0;
  20472. // string companyName = "", job = "";
  20473. // if (transArray2.Length > 0)
  20474. // {
  20475. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  20476. // if (1 < transArray2.Length) companyName = transArray2[1];
  20477. // if (2 < transArray2.Length) job = transArray2[2];
  20478. // }
  20479. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  20480. // }
  20481. // }
  20482. // }
  20483. //}
  20484. ////循环赋值
  20485. //for (int i = 0; i < DcList.Count; i++)
  20486. //{
  20487. // string PYName = "";
  20488. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  20489. // {
  20490. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  20491. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  20492. // PYName = PY_First + " " + PY_Last;
  20493. // }
  20494. // else
  20495. // {
  20496. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  20497. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  20498. // PYName = PY_First + " " + PY_Last;
  20499. // }
  20500. // builder.MoveToCell(0, i + 1, 0, 0);
  20501. // builder.Write(PYName);
  20502. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  20503. // builder.MoveToCell(0, i + 1, 1, 0);
  20504. // builder.Write(sex);
  20505. // DateTime birthDt;
  20506. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  20507. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20508. // builder.MoveToCell(0, i + 1, 2, 0);
  20509. // builder.Write(birthday);
  20510. // string company = string.Empty, job = string.Empty;
  20511. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  20512. // if (dcTransInfo != null)
  20513. // {
  20514. // company = dcTransInfo.CompanyName;
  20515. // job = dcTransInfo.Job;
  20516. // }
  20517. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20518. // {
  20519. // //查询对照表
  20520. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  20521. // if (tempCec != null)
  20522. // {
  20523. // company = tempCec.enName;
  20524. // }
  20525. // //翻译
  20526. // else
  20527. // {
  20528. // }
  20529. // }
  20530. // builder.MoveToCell(0, i + 1, 3, 0);
  20531. // builder.Write(company);
  20532. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  20533. // {
  20534. // //查询对照表
  20535. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  20536. // if (tempPec != null)
  20537. // {
  20538. // job = tempPec.enName;
  20539. // }
  20540. // //翻译
  20541. // else
  20542. // {
  20543. // }
  20544. // }
  20545. // builder.MoveToCell(0, i + 1, 4, 0);
  20546. // builder.Write(job);
  20547. //}
  20548. #endregion
  20549. }
  20550. //删除多余行
  20551. while (tableOne.Rows.Count > DcList.Count + 1)
  20552. {
  20553. tableOne.Rows.RemoveAt(DcList.Count + 1);
  20554. }
  20555. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  20556. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  20557. doc.Save(fileDir);
  20558. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  20559. return Ok(JsonView(true, "操作成功!", Url));
  20560. }
  20561. private class TranslateInfo
  20562. {
  20563. public int Index { get; set; }
  20564. public string CompanyName { get; set; }
  20565. public string Job { get; set; }
  20566. }
  20567. [HttpPost]
  20568. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  20569. {
  20570. if (files.Count == 0)
  20571. {
  20572. return Ok(JsonView(false, "文件为空"));
  20573. }
  20574. KiMiApiClient KiMiApi = new KiMiApiClient();
  20575. var seedConter = await KiMiApi.UploadFilesAsync(files);
  20576. if (seedConter.Count == 0)
  20577. {
  20578. return Ok(JsonView(false, "上传结果为空!"));
  20579. }
  20580. var messages = new List<SeedMessages>
  20581. {
  20582. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  20583. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  20584. };
  20585. messages.InsertRange(1, seedConter);
  20586. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  20587. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20588. string clients = kimiApiResult_JObject["content"].ToString();
  20589. string startStr = "```json", endStr = "```";
  20590. // 判断并清除开头部分
  20591. if (clients.StartsWith(startStr))
  20592. {
  20593. clients = clients.Remove(0, startStr.Length);
  20594. }
  20595. // 判断并清除结尾部分
  20596. if (clients.EndsWith(endStr))
  20597. {
  20598. clients = clients.Remove(clients.Length - endStr.Length);
  20599. }
  20600. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  20601. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  20602. {
  20603. {"姓", "LastName" },
  20604. {"名", "FirstName" },
  20605. {"姓名拼音", "Pinyin" },
  20606. {"性别", "Sex" },
  20607. {"单位", "CompanyFullName" },
  20608. {"职务", "Job" },
  20609. {"出生日期", "Birthday" },
  20610. };
  20611. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  20612. foreach (var item in clients_JObject)
  20613. {
  20614. BaiduClientOCRView cdc = new BaiduClientOCRView();
  20615. foreach (var field in clientFieldMap.Keys)
  20616. {
  20617. if (item.TryGetValue(field, out JToken value))
  20618. {
  20619. var getValue = value.ToString();
  20620. System.Type type = cdc.GetType();
  20621. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  20622. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  20623. propertyInfo.SetValue(cdc, propertyValue);
  20624. }
  20625. }
  20626. crmClients.Add(cdc);
  20627. }
  20628. return Ok(JsonView(new
  20629. {
  20630. fileCount = files.Count,
  20631. UploadCount = seedConter.Count,
  20632. ApiResult = clients,
  20633. CrmClients = crmClients
  20634. }));
  20635. }
  20636. #endregion
  20637. #region 团组倒推表
  20638. /// <summary>
  20639. /// 倒推表基础数据
  20640. /// Init
  20641. /// </summary>
  20642. /// <returns></returns>
  20643. [HttpPost]
  20644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20645. public async Task<IActionResult> PostInvertedListInit()
  20646. {
  20647. var viewData = await _invertedListRep._Init();
  20648. if (viewData.Code != 0)
  20649. {
  20650. return Ok(JsonView(false, viewData.Msg));
  20651. }
  20652. return Ok(JsonView(viewData.Data));
  20653. }
  20654. /// <summary>
  20655. /// 倒推表
  20656. /// Info
  20657. /// </summary>
  20658. /// <param name="dto"></param>
  20659. /// <returns></returns>
  20660. [HttpPost]
  20661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20662. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  20663. {
  20664. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  20665. if (viewData.Code != 0)
  20666. {
  20667. return Ok(JsonView(false, viewData.Msg));
  20668. }
  20669. return Ok(JsonView(viewData.Data));
  20670. }
  20671. /// <summary>
  20672. /// 倒推表
  20673. /// Create
  20674. /// </summary>
  20675. /// <param name="dto"></param>
  20676. /// <returns></returns>
  20677. [HttpPost]
  20678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20679. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  20680. {
  20681. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  20682. if (viewData.Code != 0)
  20683. {
  20684. return Ok(JsonView(false, viewData.Msg));
  20685. }
  20686. return Ok(JsonView(viewData.Data));
  20687. }
  20688. /// <summary>
  20689. /// 倒推表
  20690. /// Update
  20691. /// </summary>
  20692. /// <param name="dto"></param>
  20693. /// <returns></returns>
  20694. [HttpPost]
  20695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20696. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  20697. {
  20698. var viewData = await _invertedListRep._Update(dto);
  20699. if (viewData.Code != 0)
  20700. {
  20701. return Ok(JsonView(false, viewData.Msg));
  20702. }
  20703. return Ok(JsonView(viewData.Data));
  20704. }
  20705. /// <summary>
  20706. /// 倒推表
  20707. /// File Download
  20708. /// </summary>
  20709. /// <param name="dto"></param>
  20710. /// <returns></returns>
  20711. [HttpPost]
  20712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20713. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  20714. {
  20715. var info2 = await _invertedListRep._Info(1, dto.DiId);
  20716. if (info2.Code != 0)
  20717. {
  20718. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  20719. }
  20720. var info1 = info2.Data as InvertedListInfoView;
  20721. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  20722. string teamName = "";
  20723. if (info != null) teamName = info.TeamName;
  20724. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  20725. var doc = new Document();
  20726. var builder = new DocumentBuilder(doc);
  20727. #region old insert
  20728. ////载入模板
  20729. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  20730. //Document doc = new Document(tempPath);
  20731. //DocumentBuilder builder = new DocumentBuilder(doc);
  20732. //利用键值对存放数据
  20733. //Dictionary<string, string> dic = new Dictionary<string, string>();
  20734. //dic.Add("TeamName", teamName);
  20735. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  20736. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  20737. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  20738. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  20739. //dic.Add("SQRemark", info1.ApprovalRemark);
  20740. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  20741. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  20742. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  20743. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  20744. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  20745. //dic.Add("QZRemark", info1.VisaInformationRemark);
  20746. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  20747. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  20748. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  20749. //dic.Add("CQRemark", info1.IssueVisaRemark);
  20750. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  20751. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  20752. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  20753. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  20754. //#region 填充word模板书签内容
  20755. //foreach (var key in dic.Keys)
  20756. //{
  20757. // builder.MoveToBookmark(key);
  20758. // builder.Write(dic[key]);
  20759. //}
  20760. //#endregion
  20761. #endregion
  20762. #region New Insert
  20763. string titleFont = $"仿宋",
  20764. contentFont = $"仿宋";
  20765. var fontColor = Color.FromArgb(64, 64, 64);
  20766. //设置标题 团组名称
  20767. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20768. builder.Font.Name = titleFont;
  20769. builder.Font.Color = fontColor;
  20770. builder.Font.Size = 12;
  20771. builder.Font.Bold = true;
  20772. builder.Writeln(teamName);
  20773. //设置副标题 团组出访时间
  20774. builder.Font.Size = 12;
  20775. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  20776. builder.Writeln();
  20777. var backgroundColor = Color.FromArgb(199, 199, 199);
  20778. var table = builder.StartTable();
  20779. builder.InsertCell();
  20780. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  20781. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  20782. builder.CellFormat.Borders.LineWidth = 1;
  20783. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  20784. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  20785. builder.RowFormat.Height = 40;
  20786. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20787. builder.Font.Name = contentFont;
  20788. builder.Font.Size = 12;
  20789. builder.Font.Bold = true;
  20790. builder.Font.Color = fontColor;
  20791. builder.Write("时间");
  20792. builder.InsertCell();
  20793. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  20794. builder.Write("流程");
  20795. builder.InsertCell();
  20796. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  20797. builder.Write("说明");
  20798. builder.EndRow();
  20799. //报批资料准备
  20800. if (info1.IsSelectedAirportd)
  20801. {
  20802. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  20803. }
  20804. //报批/提供送签资料
  20805. if (info1.IsSelectedApprovalData)
  20806. {
  20807. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  20808. }
  20809. //出批件护照办理
  20810. if (info1.IsSelectedIssueApproval)
  20811. {
  20812. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  20813. }
  20814. //签证资料准备
  20815. if (info1.IsSelectedVisaInfo)
  20816. {
  20817. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  20818. }
  20819. //送签
  20820. if (info1.IsSelectedSendVisa)
  20821. {
  20822. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  20823. }
  20824. //出签
  20825. if (info1.IsSelectedIssueVisa)
  20826. {
  20827. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  20828. }
  20829. //机票
  20830. if (info1.IsSelectedAirTicket)
  20831. {
  20832. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  20833. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  20834. }
  20835. //酒店
  20836. if (info1.IsSelectedHotel)
  20837. {
  20838. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  20839. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  20840. }
  20841. //开行前会
  20842. if (info1.IsSelectedPreTripMeeting)
  20843. {
  20844. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  20845. }
  20846. //送机
  20847. if (info1.IsSelectedAirportdDropOff)
  20848. {
  20849. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  20850. }
  20851. builder.EndTable();
  20852. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  20853. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  20854. for (int i = 0; i < table.Rows.Count; i++)
  20855. {
  20856. var row = table.Rows[i];
  20857. //设置宽度
  20858. row.Cells[0].CellFormat.Width = 20.00;
  20859. row.Cells[1].CellFormat.Width = 30.00;
  20860. row.Cells[2].CellFormat.Width = 50.00;
  20861. if (i != 0)
  20862. {
  20863. //边框设置
  20864. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20865. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20866. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20867. }
  20868. }
  20869. #region 页脚插入图片
  20870. // 创建页脚
  20871. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20872. doc.FirstSection.HeadersFooters.Add(footer);
  20873. Paragraph para = new Paragraph(doc);
  20874. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20875. footer.AppendChild(para);
  20876. builder.MoveTo(para);
  20877. string imagePath = "./Images/FMGJ_Log.png";
  20878. builder.InsertImage(imagePath);
  20879. #endregion
  20880. #endregion
  20881. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20882. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20883. string filePath = fileDir + $@"InvertedList/{fileName}";
  20884. doc.Save(filePath);
  20885. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20886. return Ok(JsonView(true, "操作成功!", Url));
  20887. }
  20888. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20889. {
  20890. var fontColor = Color.FromArgb(64, 64, 64);
  20891. builder.InsertCell();
  20892. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20893. builder.RowFormat.Height = 40;
  20894. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20895. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20896. builder.Font.Name = fontName;
  20897. builder.Font.Size = 8;
  20898. builder.Font.Bold = true;
  20899. builder.Font.Color = fontColor;
  20900. builder.Write(dateTime);
  20901. builder.InsertCell();
  20902. builder.Font.Size = 9;
  20903. builder.Font.Bold = true;
  20904. builder.Font.Color = fontColor;
  20905. builder.Write(content);
  20906. builder.InsertCell();
  20907. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20908. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20909. builder.Font.Size = 9;
  20910. builder.Font.Bold = false;
  20911. builder.Font.Color = fontColor;
  20912. builder.Write(reamrk);
  20913. builder.EndRow();
  20914. }
  20915. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20916. {
  20917. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20918. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20919. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20920. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20921. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20922. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20923. }
  20924. #endregion
  20925. #region 会务倒推表
  20926. /// <summary>
  20927. /// 会务倒推表
  20928. /// Init
  20929. /// </summary>
  20930. /// <returns></returns>
  20931. [HttpPost]
  20932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20933. public async Task<IActionResult> InforRetrogressTableInit()
  20934. {
  20935. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20936. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20937. return Ok(JsonView(false, groupData.Msg));
  20938. }
  20939. /// <summary>
  20940. /// 会务倒推表
  20941. /// ExcelDownload
  20942. /// </summary>
  20943. /// <param name="dto"></param>
  20944. /// <returns></returns>
  20945. [HttpPost]
  20946. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20948. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20949. {
  20950. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20951. var validatorRes = await validator.ValidateAsync(dto);
  20952. if (!validatorRes.IsValid)
  20953. {
  20954. StringBuilder sb = new StringBuilder();
  20955. foreach (var item in validatorRes.Errors)
  20956. {
  20957. sb.AppendLine(item.ErrorMessage);
  20958. }
  20959. return Ok(JsonView(false, sb.ToString()));
  20960. }
  20961. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20962. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20963. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20964. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20965. #region Excel
  20966. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20967. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20968. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20969. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20970. var fileNamePrefix = string.Empty;
  20971. if (days >= 30)
  20972. {
  20973. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20974. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20975. }
  20976. else if (days < 30 && days > 7)
  20977. {
  20978. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20979. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20980. }
  20981. else if (days <= 7)
  20982. {
  20983. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20984. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20985. }
  20986. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20987. fileName = CommonFun.ValidFileName(fileName);
  20988. //载入模板
  20989. WorkbookDesigner designer = new WorkbookDesigner();
  20990. designer.Workbook = new Workbook(tempPath);
  20991. designer.Process();
  20992. if (!Directory.Exists(savePath))
  20993. {
  20994. Directory.CreateDirectory(savePath);
  20995. }
  20996. string serverPath = $"{savePath}{fileName}";
  20997. designer.Workbook.Save(serverPath);
  20998. string rst = $"{servicePath}{ftpPath}{fileName}";
  20999. #endregion
  21000. return Ok(JsonView(new { url = rst }));
  21001. }
  21002. #endregion
  21003. #region 三公签证费用(签证费、代办费)
  21004. /// <summary>
  21005. /// 三公签证费用(签证费、代办费)
  21006. /// List
  21007. /// </summary>
  21008. /// <returns></returns>
  21009. [HttpPost]
  21010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21011. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  21012. {
  21013. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  21014. }
  21015. /// <summary>
  21016. /// 三公签证费用(签证费、代办费)
  21017. /// Add Or Update
  21018. /// </summary>
  21019. /// <returns></returns>
  21020. [HttpPost]
  21021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21022. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  21023. {
  21024. var _view = await _visaFeeInfoRep.Update(_dto);
  21025. if (_view.Code != 0)
  21026. {
  21027. return Ok(JsonView(false, _view.Msg));
  21028. }
  21029. return Ok(JsonView(true, _view.Msg));
  21030. }
  21031. #endregion
  21032. #region 酒店询价
  21033. /// <summary>
  21034. /// 酒店询价
  21035. /// Init
  21036. /// </summary>
  21037. /// <returns></returns>
  21038. [HttpPost]
  21039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21040. public async Task<IActionResult> PostHotelInquiryInit()
  21041. {
  21042. var res = await _hotelInquiryRep._Init();
  21043. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21044. return Ok(JsonView(true, res.Msg, res.Data));
  21045. }
  21046. /// <summary>
  21047. /// 酒店询价
  21048. /// page Item
  21049. /// </summary>
  21050. /// <param name="_dto"></param>
  21051. /// <returns></returns>
  21052. [HttpPost]
  21053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21054. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  21055. {
  21056. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  21057. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21058. var view = res.Data as PageDataViewBase;
  21059. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  21060. }
  21061. /// <summary>
  21062. /// 酒店询价
  21063. /// info
  21064. /// </summary>
  21065. /// <param name="_dto"></param>
  21066. /// <returns></returns>
  21067. [HttpPost]
  21068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21069. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  21070. {
  21071. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  21072. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21073. return Ok(JsonView(true, res.Msg, res.Data));
  21074. }
  21075. /// <summary>
  21076. /// 酒店询价
  21077. /// Add Or Edit
  21078. /// </summary>
  21079. /// <param name="_dto"></param>
  21080. /// <returns></returns>
  21081. [HttpPost]
  21082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21083. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  21084. {
  21085. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  21086. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21087. return Ok(JsonView(true, res.Msg, res.Data));
  21088. }
  21089. /// <summary>
  21090. /// 酒店询价
  21091. /// Del
  21092. /// </summary>
  21093. /// <param name="_dto"></param>
  21094. /// <returns></returns>
  21095. [HttpPost]
  21096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21097. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  21098. {
  21099. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  21100. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21101. return Ok(JsonView(true, res.Msg, res.Data));
  21102. }
  21103. #endregion
  21104. #region 下载匹配op行程单
  21105. /// <summary>
  21106. /// 匹配op行程单
  21107. /// Init
  21108. /// </summary>
  21109. /// <param name="dto">团组列表请求dto</param>
  21110. /// <returns></returns>
  21111. [HttpPost]
  21112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21113. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  21114. {
  21115. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21116. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21117. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  21118. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  21119. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  21120. .Where(it => it.IsDel == 0)
  21121. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  21122. .OrderByDescending(it => it.VisitStartDate)
  21123. .ToList();
  21124. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  21125. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21126. var diids = groupInfos.Select(it => it.Id).ToList();
  21127. List<string> countrys = new List<string>();
  21128. foreach (var item in country)
  21129. {
  21130. var data = _groupRepository.FormartTeamName(item);
  21131. var dataArray = _groupRepository.GroupSplitCountry(data);
  21132. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21133. }
  21134. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  21135. List<string> areaArray = new List<string>(); //GetGroupCityLine
  21136. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  21137. foreach (var item in areaItem)
  21138. {
  21139. string areaStr = item.Value;
  21140. if (!string.IsNullOrEmpty(areaStr))
  21141. {
  21142. string[] str1 = areaStr.Split("-");
  21143. if (str1.Length > 0)
  21144. {
  21145. areaArray.AddRange(str1);
  21146. }
  21147. }
  21148. }
  21149. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  21150. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  21151. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  21152. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  21153. .ToList();
  21154. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  21155. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  21156. .Where(it => countriesIds.Contains(it.Id))
  21157. .Select(it => new { it.Id, Name = it.Name_CN })
  21158. .ToList();
  21159. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  21160. .Select(it => it.TeamName).ToList();
  21161. stopwatch.Stop();
  21162. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  21163. }
  21164. ///// <summary>
  21165. ///// 匹配op行程单
  21166. ///// Init 查询区域数据
  21167. ///// </summary>
  21168. ///// <param name="dto">团组列表请求dto</param>
  21169. ///// <returns></returns>
  21170. //[HttpPost]
  21171. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21172. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  21173. //{
  21174. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21175. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  21176. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  21177. // if (string.IsNullOrEmpty(countriesDataStr))
  21178. // {
  21179. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  21180. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  21181. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  21182. // }
  21183. // else
  21184. // {
  21185. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  21186. // }
  21187. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  21188. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  21189. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  21190. // List<dynamic> childList = new List<dynamic>();
  21191. // int parentId = dto.CountriesId;
  21192. // if (provinceData.Count > 1)
  21193. // {
  21194. // foreach (var item1 in provinceData)
  21195. // {
  21196. // List<dynamic> childList1 = new List<dynamic>();
  21197. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  21198. // foreach (var item2 in citiesData1)
  21199. // {
  21200. // List<dynamic> childList2 = new List<dynamic>();
  21201. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21202. // foreach (var item3 in countiesData1)
  21203. // {
  21204. // childList2.Add(new
  21205. // {
  21206. // id = item3.Id,
  21207. // parentId = item2.Id,
  21208. // level = "district",
  21209. // name = item3.Name_CN,
  21210. // });
  21211. // }
  21212. // childList1.Add(new
  21213. // {
  21214. // id = item2.Id,
  21215. // parentId = item1.Id,
  21216. // level = "city",
  21217. // name = item2.Name_CN,
  21218. // childList = childList2
  21219. // });
  21220. // }
  21221. // childList.Add(new
  21222. // {
  21223. // id = item1.Id,
  21224. // parentId = parentId,
  21225. // level = "province",
  21226. // name = item1.Name_CN,
  21227. // childList = childList1
  21228. // });
  21229. // }
  21230. // //城市
  21231. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  21232. // foreach (var item2 in citiesData2)
  21233. // {
  21234. // List<dynamic> childList22 = new List<dynamic>();
  21235. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21236. // foreach (var item3 in countiesData1)
  21237. // {
  21238. // childList22.Add(new
  21239. // {
  21240. // id = item3.Id,
  21241. // parentId = item2.Id,
  21242. // level = "district",
  21243. // name = item3.Name_CN,
  21244. // });
  21245. // }
  21246. // childList.Add(new
  21247. // {
  21248. // id = item2.Id,
  21249. // parentId = parentId,
  21250. // level = "city",
  21251. // name = item2.Name_CN,
  21252. // childList = childList22
  21253. // });
  21254. // }
  21255. // }
  21256. // else
  21257. // {
  21258. // foreach (var item2 in citiesData)
  21259. // {
  21260. // string cname = item2.Name_CN;
  21261. // List<dynamic> childList1 = new List<dynamic>();
  21262. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21263. // foreach (var item3 in countiesData1)
  21264. // {
  21265. // childList1.Add(new
  21266. // {
  21267. // Id = item3.Id,
  21268. // parentId = item2.Id,
  21269. // level = "district",
  21270. // name = item3.Name_CN
  21271. // });
  21272. // }
  21273. // childList.Add(new
  21274. // {
  21275. // id = item2.Id,
  21276. // parentId = parentId,
  21277. // level = "city",
  21278. // name = item2.Name_CN,
  21279. // childList = childList1
  21280. // });
  21281. // }
  21282. // }
  21283. // stopwatch.Stop();
  21284. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  21285. //}
  21286. /// <summary>
  21287. /// 匹配op行程单
  21288. /// 接团信息列表 Page
  21289. /// </summary>
  21290. /// <param name="dto">团组列表请求dto</param>
  21291. /// <returns></returns>
  21292. [HttpPost]
  21293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21294. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  21295. {
  21296. var swatch = new Stopwatch();
  21297. swatch.Start();
  21298. #region 参数验证
  21299. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21300. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21301. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21302. #region 页面操作权限验证
  21303. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21304. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  21305. #endregion
  21306. #endregion
  21307. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21308. {
  21309. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  21310. //string sqlWhere = "";
  21311. if (!string.IsNullOrEmpty(dto.Country))
  21312. {
  21313. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  21314. }
  21315. if (!string.IsNullOrEmpty(dto.Area))
  21316. {
  21317. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  21318. }
  21319. if (!string.IsNullOrEmpty(dto.TeamName))
  21320. {
  21321. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  21322. }
  21323. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  21324. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  21325. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  21326. swatch.Stop();
  21327. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  21328. }
  21329. else
  21330. {
  21331. return Ok(JsonView(false, "查询失败"));
  21332. }
  21333. }
  21334. /// <summary>
  21335. /// 匹配op行程单
  21336. /// 行程单下载
  21337. /// </summary>
  21338. /// <param name="dto">团组列表请求dto</param>
  21339. /// <returns></returns>
  21340. [HttpPost]
  21341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21342. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  21343. {
  21344. #region 参数验证
  21345. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21346. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21347. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21348. #region 页面操作权限验证
  21349. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21350. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  21351. #endregion
  21352. #endregion
  21353. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21354. {
  21355. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  21356. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  21357. }
  21358. else
  21359. {
  21360. return Ok(JsonView(false, "下载失败!"));
  21361. }
  21362. }
  21363. #endregion
  21364. #region 国家信息 数据 注释
  21365. //[HttpPost]
  21366. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  21367. //{
  21368. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  21369. // foreach (var item in dto)
  21370. // {
  21371. // infos.Add(new Grp_GroupsTaskAssignment()
  21372. // {
  21373. // DIId = item,
  21374. // CTId = 82,
  21375. // UId = 248,
  21376. // IsEnable = 1,
  21377. // CreateUserId = 233,
  21378. // CreateTime = DateTime.Now,
  21379. // IsDel = 0
  21380. // });
  21381. // infos.Add(new Grp_GroupsTaskAssignment()
  21382. // {
  21383. // DIId = item,
  21384. // CTId = 82,
  21385. // UId = 286,
  21386. // IsEnable = 1,
  21387. // CreateUserId = 233,
  21388. // CreateTime = DateTime.Now,
  21389. // IsDel = 0
  21390. // });
  21391. // }
  21392. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  21393. // return Ok("操作成功");
  21394. //}
  21395. //public class paramJsonDto
  21396. //{
  21397. // public List<CountriesInfo> str { get; set; }
  21398. //}
  21399. //[HttpPost]
  21400. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  21401. //{
  21402. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  21403. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  21404. // List<Sys_Cities> cities = new List<Sys_Cities>();
  21405. // List<Sys_Cities> districts = new List<Sys_Cities>();
  21406. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21407. // _sqlSugar.BeginTran();
  21408. // int countitiesIndex = 0;
  21409. // foreach (var item in dto.str)
  21410. // {
  21411. // dynamic data = item.c;
  21412. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  21413. // if (data != null)
  21414. // {
  21415. // countitiesIndex++;
  21416. // foreach (var item1 in data)
  21417. // {
  21418. // string cnname = item1.cn;
  21419. // string enname = item1.en;
  21420. // Sys_Cities provinceInfo = new Sys_Cities()
  21421. // {
  21422. // CountriesId = countriesId,
  21423. // Name_CN = cnname,
  21424. // Name_EN = enname,
  21425. // ParentId = 0,
  21426. // IsCapital = 1,
  21427. // CreateUserId = 208,
  21428. // CreateTime = DateTime.Now,
  21429. // IsDel = 0
  21430. // };
  21431. // if (item1.lv == "province") //省份
  21432. // {
  21433. // provinceInfo.Level = 1;
  21434. // int provinceId = 0;
  21435. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  21436. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  21437. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21438. // var data1 = item1.c;
  21439. // foreach (var item2 in data1)
  21440. // {
  21441. // if (item2.lv == "city")
  21442. // {
  21443. // string citycnname = item2.cn;
  21444. // string cityenname = item2.en;
  21445. // Sys_Cities cityInfo = new Sys_Cities()
  21446. // {
  21447. // CountriesId = countriesId,
  21448. // ParentId = provinceId,
  21449. // Level = 2,
  21450. // Name_CN = citycnname,
  21451. // Name_EN = cityenname,
  21452. // IsCapital = 1,
  21453. // CreateUserId = 208,
  21454. // CreateTime = DateTime.Now,
  21455. // IsDel = 0
  21456. // };
  21457. // if (item2.c != null)
  21458. // {
  21459. // int cityId = 0;
  21460. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  21461. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21462. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  21463. // foreach (var item3 in item2.c)
  21464. // {
  21465. // if (item3.lv == "district")
  21466. // {
  21467. // var districtInfo = new Sys_Cities()
  21468. // {
  21469. // CountriesId = countriesId,
  21470. // Name_CN = item3.cn,
  21471. // Name_EN = item3.en,
  21472. // Level = 3,
  21473. // ParentId = cityId,
  21474. // IsCapital = 1,
  21475. // CreateUserId = 208,
  21476. // CreateTime = DateTime.Now,
  21477. // IsDel = 0
  21478. // };
  21479. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21480. // //{
  21481. // districts.Add(districtInfo);
  21482. // //}
  21483. // }
  21484. // }
  21485. // }
  21486. // else
  21487. // {
  21488. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  21489. // //{
  21490. // cities.Add(cityInfo);
  21491. // //}
  21492. // }
  21493. // }
  21494. // }
  21495. // }
  21496. // else if (item1.lv == "city")//城市
  21497. // {
  21498. // provinceInfo.Level = 2;
  21499. // if (item1.c != null)
  21500. // {
  21501. // int cityId = 0;
  21502. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  21503. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21504. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21505. // foreach (var item3 in item1.c)
  21506. // {
  21507. // if (item3.lv == "district")
  21508. // {
  21509. // var districtInfo = new Sys_Cities()
  21510. // {
  21511. // CountriesId = countriesId,
  21512. // Name_CN = item3.cn,
  21513. // Name_EN = item3.en,
  21514. // Level = 3,
  21515. // ParentId = cityId,
  21516. // IsCapital = 1,
  21517. // CreateUserId = 208,
  21518. // CreateTime = DateTime.Now,
  21519. // IsDel = 0
  21520. // };
  21521. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21522. // //{
  21523. // districts.Add(districtInfo);
  21524. // //}
  21525. // }
  21526. // }
  21527. // }
  21528. // else
  21529. // {
  21530. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  21531. // //{
  21532. // cities.Add(provinceInfo);
  21533. // //}
  21534. // }
  21535. // }
  21536. // }
  21537. // }
  21538. // }
  21539. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  21540. // cities = cities.Distinct().ToList();
  21541. // districts = districts.Distinct().ToList();
  21542. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  21543. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  21544. // cities.AddRange(districts);
  21545. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  21546. // //_sqlSugar.RollbackTran();
  21547. // _sqlSugar.CommitTran();
  21548. // return Ok(JsonView(false, "操作成功!"));
  21549. //}
  21550. //[HttpPost]
  21551. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  21552. //{
  21553. // List<CountitiesInfo> infos = dto.MyProperty;
  21554. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  21555. // _sqlSugar.BeginTran();
  21556. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21557. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  21558. // foreach (var item in infos)
  21559. // {
  21560. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  21561. // if (countryInfo != null)
  21562. // {
  21563. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  21564. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  21565. // if (cityInfo1 != null)
  21566. // {
  21567. // cityInfo1.IsCapital = 0;
  21568. // cityInfos.Add(cityInfo1);
  21569. // }
  21570. // }
  21571. // }
  21572. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  21573. // .UpdateColumns(it => it.IsCapital)
  21574. // .WhereColumns(it => it.Id)
  21575. // .ExecuteCommand();
  21576. // //_sqlSugar.RollbackTran();
  21577. // _sqlSugar.CommitTran();
  21578. // return Ok(JsonView(false, "操作成功!"));
  21579. //}
  21580. //public class CounrtiesDto
  21581. //{
  21582. // public List<CountitiesInfo> MyProperty { get; set; }
  21583. //}
  21584. //public class CountitiesInfo
  21585. //{
  21586. // /// <summary>
  21587. // /// 圣约翰
  21588. // /// </summary>
  21589. // public string capital_name_chinese { get; set; }
  21590. // /// <summary>
  21591. // ///
  21592. // /// </summary>
  21593. // public string capital_name { get; set; }
  21594. // /// <summary>
  21595. // ///
  21596. // /// </summary>
  21597. // public string country_type { get; set; }
  21598. // /// <summary>
  21599. // /// 安提瓜和巴布达
  21600. // /// </summary>
  21601. // public string country_name_chinese { get; set; }
  21602. // /// <summary>
  21603. // /// 安提瓜和巴布达
  21604. // /// </summary>
  21605. // public string country_name_chinese_short { get; set; }
  21606. // /// <summary>
  21607. // /// 安提瓜和巴布达
  21608. // /// </summary>
  21609. // public string country_name_chinese_UN { get; set; }
  21610. // /// <summary>
  21611. // ///
  21612. // /// </summary>
  21613. // public string country_name_english_abbreviation { get; set; }
  21614. // /// <summary>
  21615. // ///
  21616. // /// </summary>
  21617. // public string country_name_english_formal { get; set; }
  21618. // /// <summary>
  21619. // ///
  21620. // /// </summary>
  21621. // public string country_name_english_UN { get; set; }
  21622. // /// <summary>
  21623. // ///
  21624. // /// </summary>
  21625. // public string continent_name { get; set; }
  21626. // /// <summary>
  21627. // ///
  21628. // /// </summary>
  21629. // public string subregion_name { get; set; }
  21630. // /// <summary>
  21631. // ///
  21632. // /// </summary>
  21633. // public string country_code2 { get; set; }
  21634. // /// <summary>
  21635. // ///
  21636. // /// </summary>
  21637. // public string country_code3 { get; set; }
  21638. // /// <summary>
  21639. // ///
  21640. // /// </summary>
  21641. // public string phone_code { get; set; }
  21642. //}
  21643. //public class CountriesInfo : BasicInfo
  21644. //{
  21645. // public List<CitiesInfo> c { get; set; }
  21646. //}
  21647. //public class CitiesInfo : BasicInfo
  21648. //{
  21649. // public List<AreaInfo> c { get; set; }
  21650. //}
  21651. //public class AreaInfo : BasicInfo
  21652. //{
  21653. // public List<AreaInfo> c { get; set; }
  21654. //}
  21655. //public class BasicInfo
  21656. //{
  21657. // public string code { get; set; }
  21658. // public string cn { get; set; }
  21659. // public string lv { get; set; }
  21660. // public string en { get; set; }
  21661. //}
  21662. #endregion
  21663. #region 查看邀请方
  21664. /// <summary>
  21665. /// 查看邀请方
  21666. /// 邀请方信息 Init
  21667. /// </summary>
  21668. /// <param name="dto"></param>
  21669. /// <returns></returns>
  21670. [HttpPost]
  21671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21672. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  21673. {
  21674. string sqlWhere = string.Empty;
  21675. if (!string.IsNullOrEmpty(dto.Search))
  21676. {
  21677. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  21678. }
  21679. string sql = string.Format($@"Select
  21680. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  21681. Id,
  21682. UnitName
  21683. From Res_InvitationOfficialActivityData
  21684. Where IsDel = 0
  21685. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  21686. RefAsync<int> total = 0;
  21687. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21688. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  21689. }
  21690. /// <summary>
  21691. /// 查看邀请方
  21692. /// 国家信息 Init
  21693. /// </summary>
  21694. /// <param name="dto"></param>
  21695. /// <returns></returns>
  21696. [HttpPost]
  21697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21698. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  21699. {
  21700. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  21701. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21702. var diids = groupInfos.Select(it => it.Id).ToList();
  21703. List<string> countrys = new List<string>();
  21704. foreach (var item in country)
  21705. {
  21706. var data = _groupRepository.FormartTeamName(item);
  21707. var dataArray = _groupRepository.GroupSplitCountry(data);
  21708. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21709. }
  21710. countrys = countrys.Distinct().ToList();
  21711. for (int i = 0; i < countrys.Count; i++)
  21712. {
  21713. string item = countrys[i];
  21714. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  21715. {
  21716. countrys.Remove(item);
  21717. i--;
  21718. }
  21719. }
  21720. RefAsync<int> total = 0;
  21721. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  21722. .Where(it => countrys.Contains(it.Name_CN))
  21723. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21724. .Select(it => new { id = it.Id, name = it.Name_CN })
  21725. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21726. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21727. }
  21728. /// <summary>
  21729. /// 查看邀请方
  21730. /// 城市信息 Init
  21731. /// </summary>
  21732. /// <param name="dto"></param>
  21733. /// <returns></returns>
  21734. [HttpPost]
  21735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21736. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  21737. {
  21738. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  21739. RefAsync<int> total = 0;
  21740. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  21741. .Where(it => it.CountriesId == dto.CountiesId)
  21742. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21743. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  21744. .Select(it => new { id = it.Id, name = it.Name_CN })
  21745. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21746. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21747. }
  21748. /// <summary>
  21749. /// 查看邀请方
  21750. /// 团组名称 Init
  21751. /// </summary>
  21752. /// <param name="dto"></param>
  21753. /// <returns></returns>
  21754. [HttpPost]
  21755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21756. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  21757. {
  21758. var watch = new Stopwatch();
  21759. watch.Start();
  21760. RefAsync<int> total = 0;
  21761. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  21762. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  21763. .Where((oa, di) => oa.IsDel == 0)
  21764. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  21765. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  21766. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  21767. .Distinct()
  21768. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21769. watch.Stop();
  21770. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  21771. }
  21772. /// <summary>
  21773. /// 查看邀请方
  21774. /// 团组 & 邀请方信息
  21775. /// </summary>
  21776. /// <param name="dto"></param>
  21777. /// <returns></returns>
  21778. [HttpPost]
  21779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21780. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  21781. {
  21782. var watch = new Stopwatch();
  21783. watch.Start();
  21784. RefAsync<int> total = 0;
  21785. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  21786. .AS("Grp_DelegationInfo")
  21787. .Includes(x => x.InvitingInfos)
  21788. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  21789. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  21790. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  21791. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  21792. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  21793. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  21794. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21795. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  21796. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  21797. infos.ForEach(x =>
  21798. {
  21799. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  21800. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  21801. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  21802. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  21803. });
  21804. watch.Stop();
  21805. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  21806. }
  21807. #endregion
  21808. #region 报批行程
  21809. /// <summary>
  21810. /// 报批行程初始化
  21811. /// </summary>
  21812. /// <param name="dto"></param>
  21813. /// <returns></returns>
  21814. [HttpPost]
  21815. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  21816. {
  21817. const int chiNumber = 5;
  21818. var jw = JsonView(false);
  21819. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  21820. var group = groupList.First();
  21821. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  21822. group = groupList.First(x => x.Id == diid);
  21823. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21824. .Where(x => x.DiId == diid && x.IsDel == 0)
  21825. .ToArray();
  21826. var count = 1;
  21827. foreach (var item in blackCodeList)
  21828. {
  21829. if (string.IsNullOrWhiteSpace(item.Title))
  21830. {
  21831. item.Title = "未设置名称数据" + count;
  21832. }
  21833. count++;
  21834. }
  21835. ;
  21836. if (group == null)
  21837. {
  21838. jw.Msg = "暂无团组!";
  21839. return Ok(jw);
  21840. }
  21841. var data = new
  21842. {
  21843. groupList = groupList.Select(x => new
  21844. {
  21845. x.TeamName,
  21846. x.Id
  21847. }),
  21848. content = new ArrayList(),
  21849. groupInfo = new
  21850. {
  21851. group.VisitDays,
  21852. group.TourCode,
  21853. group.VisitPNumber,
  21854. group.TeamName,
  21855. group.Id,
  21856. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21857. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21858. group.ClientUnit
  21859. },
  21860. blackCodeList = blackCodeList.Select(x => new
  21861. {
  21862. x.Title,
  21863. x.Id
  21864. }),
  21865. FileTempList = new ArrayList()
  21866. {
  21867. new { Index = 1,FileName = "旧模板" },
  21868. new { Index = 2,FileName = "省外办" },
  21869. new { Index = 3,FileName = "市外办" },
  21870. }
  21871. };
  21872. var resultArr = new ArrayList();
  21873. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21874. #region 默认不生成行程
  21875. //if (content.Count == 0)
  21876. //{
  21877. // var stay = "-";
  21878. // var cityPath = "-";
  21879. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21880. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21881. // .ToList();
  21882. // //添加城市路径以及住宿地
  21883. // //黑屏代码数据
  21884. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21885. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21886. // {
  21887. // jw = JsonView(true, "黑屏代码有误!", data);
  21888. // return Ok(jw);
  21889. // }
  21890. // data = data with
  21891. // {
  21892. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21893. // {
  21894. // x.Title,
  21895. // x.Id,
  21896. // }).ToArray())
  21897. // };
  21898. // foreach (DataRow row in dtBlack.Rows)
  21899. // {
  21900. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21901. // {
  21902. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21903. // return Ok(jw);
  21904. // }
  21905. // }
  21906. // //黑屏代码获取时间区间
  21907. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21908. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21909. // _sqlSugar.BeginTran();
  21910. // for (int i = 0; i < timeArr.Count; i++)
  21911. // {
  21912. // stay = "-";
  21913. // cityPath = "-";
  21914. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21915. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21916. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21917. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21918. // if (tbSelect.Length > 0)
  21919. // {
  21920. // List<string> threeCodeStr = new List<string>();
  21921. // foreach (var item in tbSelect)
  21922. // {
  21923. // var threeCode = item["Three"].ToString() ?? "";
  21924. // if (threeCode.Length == 6)
  21925. // {
  21926. // var start = threeCode.Substring(0, 3);
  21927. // var end = threeCode.Substring(3, 3);
  21928. // if (threeCodeStr.Count == 0)
  21929. // {
  21930. // threeCodeStr.Add(start);
  21931. // threeCodeStr.Add(end);
  21932. // }
  21933. // else
  21934. // {
  21935. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21936. // {
  21937. // threeCodeStr.Add(end);
  21938. // }
  21939. // else
  21940. // {
  21941. // threeCodeStr.Add(start);
  21942. // threeCodeStr.Add(end);
  21943. // }
  21944. // }
  21945. // }
  21946. // }
  21947. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21948. // var last = threeCodeStr.Last();
  21949. // foreach (var item in threeCodeStr)
  21950. // {
  21951. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21952. // if (item.Equals(last))
  21953. // {
  21954. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21955. // }
  21956. // }
  21957. // cityPath = cityPath.Trim('-');
  21958. // }
  21959. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21960. // appro.Diid = diid ?? -1;
  21961. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21962. // appro.Id = thisId;
  21963. // appro.CreateUserId = dto.UserId;
  21964. // appro.CreateTime = DateTime.Now;
  21965. // content.Add(appro);
  21966. // }
  21967. // _sqlSugar.CommitTran();
  21968. //}
  21969. #endregion
  21970. foreach (var x in content)
  21971. {
  21972. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21973. if (chiList.Count < chiNumber)
  21974. {
  21975. for (int i = chiList.Count; i < chiNumber; i++)
  21976. {
  21977. chiList.Add(new Grp_ApprovalTravelDetails());
  21978. }
  21979. }
  21980. resultArr.Add(new
  21981. {
  21982. x.Id,
  21983. x.Date,
  21984. x.Diid,
  21985. chiList = chiList.Select(x1 => new
  21986. {
  21987. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21988. x1.Details,
  21989. x1.ParentId,
  21990. x1.Id
  21991. })
  21992. });
  21993. }
  21994. data = data with
  21995. {
  21996. content = resultArr,
  21997. };
  21998. jw = JsonView(true, "获取成功!", data);
  21999. return Ok(jw);
  22000. }
  22001. /// <summary>
  22002. /// 报批行程删除
  22003. /// </summary>
  22004. /// <param name="dto"></param>
  22005. /// <returns></returns>
  22006. [HttpPost]
  22007. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  22008. {
  22009. var jw = JsonView(false);
  22010. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22011. if (group == null)
  22012. {
  22013. jw.Msg = "团组参数有误!";
  22014. return Ok(jw);
  22015. }
  22016. try
  22017. {
  22018. _sqlSugar.BeginTran();
  22019. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  22020. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  22021. {
  22022. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22023. DeleteUserId = dto.uesrId,
  22024. IsDel = 1
  22025. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  22026. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  22027. {
  22028. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22029. DeleteUserId = dto.uesrId,
  22030. IsDel = 1
  22031. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  22032. _sqlSugar.CommitTran();
  22033. jw = JsonView(true, "删除成功");
  22034. }
  22035. catch (Exception ex)
  22036. {
  22037. jw = JsonView(false, ex.Message);
  22038. }
  22039. return Ok(jw);
  22040. }
  22041. /// <summary>
  22042. /// 报批行程保存
  22043. /// </summary>
  22044. /// <param name="dto"></param>
  22045. /// <returns></returns>
  22046. [HttpPost]
  22047. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  22048. {
  22049. var jw = JsonView(false);
  22050. var Find = dto.Arr.Find(x => x.id == 0);
  22051. if (Find != null)
  22052. {
  22053. jw.Msg = "生成的ID为0!";
  22054. return Ok(jw);
  22055. }
  22056. foreach (var item in dto.Arr)
  22057. {
  22058. foreach (var chi in item.chiList)
  22059. {
  22060. if (chi.parentId == 0)
  22061. {
  22062. chi.parentId = item.id;
  22063. }
  22064. }
  22065. }
  22066. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  22067. _sqlSugar.BeginTran();
  22068. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  22069. {
  22070. var parentIds = dto.Arr.Select(x => x.id).ToList();
  22071. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  22072. {
  22073. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22074. DeleteUserId = dto.UserId,
  22075. IsDel = 1
  22076. }).ExecuteCommand();
  22077. }
  22078. try
  22079. {
  22080. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  22081. {
  22082. CreateTime = DateTime.Now,
  22083. CreateUserId = dto.UserId,
  22084. Details = x.details,
  22085. ParentId = x.parentId,
  22086. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22087. Remark = "",
  22088. IsDel = 0
  22089. }).ToList()).ExecuteCommand();
  22090. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  22091. {
  22092. Id = x.id,
  22093. Details = x.details,
  22094. ParentId = x.parentId,
  22095. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22096. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  22097. {
  22098. Details = x.Details,
  22099. ParentId = x.ParentId,
  22100. Time = x.Time
  22101. }).ExecuteCommand();
  22102. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  22103. {
  22104. Id = x.id,
  22105. Date = x.date,
  22106. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  22107. {
  22108. Date = x.Date
  22109. }).ExecuteCommand();
  22110. _sqlSugar.CommitTran();
  22111. jw = JsonView(true, "保存成功!");
  22112. }
  22113. catch (Exception ex)
  22114. {
  22115. _sqlSugar.RollbackTran();
  22116. jw = JsonView(false, "保存失败!" + ex.Message);
  22117. }
  22118. return Ok(jw);
  22119. }
  22120. /// <summary>
  22121. /// 报批行程生成
  22122. /// </summary>
  22123. /// <param name="dto"></param>
  22124. /// <returns></returns>
  22125. [HttpPost]
  22126. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  22127. {
  22128. var jw = JsonView(false);
  22129. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22130. if (group == null)
  22131. {
  22132. jw.Msg = "暂无该团组!";
  22133. return Ok(jw);
  22134. }
  22135. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  22136. //黑屏代码数据
  22137. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  22138. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22139. {
  22140. jw.Msg = "黑屏代码有误!";
  22141. return Ok(jw);
  22142. }
  22143. foreach (DataRow row in dtBlack.Rows)
  22144. {
  22145. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22146. {
  22147. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  22148. return Ok(jw);
  22149. }
  22150. }
  22151. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  22152. var resultArr = new ArrayList();
  22153. //if (officialActivitiesArr.Count == 0)
  22154. //{
  22155. // jw.Msg = "暂无公务出访信息!";
  22156. // return Ok(jw);
  22157. //}
  22158. try
  22159. {
  22160. _sqlSugar.BeginTran();
  22161. DeleteApprovalJourney(new
  22162. Domain.Dtos.Groups.DeleteApprovalJourney
  22163. {
  22164. Diid = dto.Diid,
  22165. uesrId = dto.Userid
  22166. });
  22167. var stay = "-";
  22168. var cityPath = "-";
  22169. var arriveCountry = string.Empty;
  22170. //添加城市路径以及住宿地
  22171. //黑屏代码获取时间区间
  22172. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22173. var empty = "【未收入该三字码!请机票同事录入】";
  22174. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22175. #region 配置公务活动时间
  22176. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  22177. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  22178. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  22179. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  22180. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  22181. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22182. {
  22183. 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" }),
  22184. 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"}),
  22185. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22186. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  22187. };
  22188. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22189. {
  22190. 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" }),
  22191. 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"}),
  22192. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22193. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  22194. };
  22195. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  22196. {
  22197. 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" }),
  22198. 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"}),
  22199. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  22200. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  22201. };
  22202. #endregion
  22203. var nextDayNum = 0;
  22204. for (int i = 0; i < timeArr.Count; i++)
  22205. {
  22206. stay = "-";
  22207. cityPath = "-";
  22208. var chiarr = new List<Grp_ApprovalTravelDetails>();
  22209. DateTime NewData = DateTime.Parse(timeArr[i]);
  22210. //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();
  22211. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22212. if (nextDayNum > 0)
  22213. {
  22214. nextDayNum--;
  22215. }
  22216. if (tbSelect.Length > 0)
  22217. {
  22218. List<string> threeCodeStr = new List<string>();
  22219. bool isTrade = false;
  22220. string trip = string.Empty;
  22221. foreach (var item in tbSelect)
  22222. {
  22223. if (nextDayNum == 0)
  22224. {
  22225. nextDayNum = Convert.ToInt32(item["Sign"]);
  22226. }
  22227. var airStartTime = item["StartTime"].ToString() ?? "0000";
  22228. var airEndTime = item["EndTime"].ToString() ?? "0000";
  22229. var takeOffTime = DateTime.Parse(timeArr[i]);
  22230. var fallToTime = DateTime.Parse(timeArr[i]);
  22231. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  22232. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  22233. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  22234. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  22235. if (nextDayNum > 0)
  22236. {
  22237. fallToTime = fallToTime.AddDays(nextDayNum);
  22238. }
  22239. trip = string.Empty;
  22240. var start = string.Empty;
  22241. var end = string.Empty;
  22242. var threeCode = item["Three"].ToString() ?? "";
  22243. if (threeCode.Length == 6)
  22244. {
  22245. start = threeCode.Substring(0, 3);
  22246. end = threeCode.Substring(3, 3);
  22247. if (threeCodeStr.Count == 0)
  22248. {
  22249. threeCodeStr.Add(start);
  22250. threeCodeStr.Add(end);
  22251. }
  22252. else
  22253. {
  22254. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22255. {
  22256. threeCodeStr.Add(end);
  22257. }
  22258. else
  22259. {
  22260. threeCodeStr.Add(start);
  22261. threeCodeStr.Add(end);
  22262. }
  22263. }
  22264. }
  22265. //处理机票信息
  22266. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  22267. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  22268. if (start_Object == null)
  22269. {
  22270. start_Object = new Res_ThreeCode()
  22271. {
  22272. AirPort = empty,
  22273. AirPort_En = empty,
  22274. City = empty,
  22275. Country = empty,
  22276. Four = empty,
  22277. Three = empty,
  22278. };
  22279. }
  22280. if (end_Object == null)
  22281. {
  22282. end_Object = new Res_ThreeCode()
  22283. {
  22284. AirPort = empty,
  22285. AirPort_En = empty,
  22286. City = empty,
  22287. Country = empty,
  22288. Four = empty,
  22289. Three = empty,
  22290. };
  22291. }
  22292. //机型判断
  22293. string airModel = item["AirModel"].ToString();
  22294. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  22295. string flightTime = item["FlightTime"].ToString();
  22296. flightTime = ParseBlackTime(flightTime);
  22297. //航班号
  22298. string flightcode = item["Fliagtcode"].ToString();
  22299. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  22300. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  22301. if (aircompany == null)
  22302. {
  22303. aircompany = new Res_AirCompany
  22304. {
  22305. CnName = hsEmpty,
  22306. EnName = hsEmpty,
  22307. ShortCode = hsEmpty,
  22308. };
  22309. }
  22310. //航班前公务安排
  22311. if (tbSelect.First().Equals(item) && i != 0)
  22312. {
  22313. foreach (var takeoff in takeoffTimes)
  22314. {
  22315. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  22316. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  22317. {
  22318. foreach (var addTime in takeoff.Item2)
  22319. {
  22320. chiarr.Add(new Grp_ApprovalTravelDetails
  22321. {
  22322. Time = addTime,
  22323. CreateTime = DateTime.Now,
  22324. CreateUserId = dto.Userid,
  22325. ParentId = 0,
  22326. Details = "公务活动"
  22327. });
  22328. }
  22329. break;
  22330. }
  22331. }
  22332. }
  22333. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  22334. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  22335. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  22336. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  22337. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  22338. if (isTrade)
  22339. {
  22340. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  22341. trip += "(转机不出机场)。";
  22342. }
  22343. //else
  22344. //{
  22345. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  22346. //}
  22347. chiarr.Add(new Grp_ApprovalTravelDetails
  22348. {
  22349. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  22350. CreateTime = DateTime.Now,
  22351. CreateUserId = dto.Userid,
  22352. ParentId = 0,
  22353. Details = trip
  22354. });
  22355. //最后一条到达的时间安排公务
  22356. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  22357. {
  22358. bool isCheckCountry = false;
  22359. if (end_Object.Country != arriveCountry)
  22360. {
  22361. arriveCountry = end_Object.Country;
  22362. isCheckCountry = true;
  22363. }
  22364. if (nextDayNum == 0)
  22365. {
  22366. //需要入境的情况
  22367. if (isCheckCountry)
  22368. {
  22369. foreach (var fallTime in fallTimesCheckCountry)
  22370. {
  22371. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22372. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22373. {
  22374. foreach (var addTime in fallTime.Item2)
  22375. {
  22376. chiarr.Add(new Grp_ApprovalTravelDetails
  22377. {
  22378. Time = addTime,
  22379. CreateTime = DateTime.Now,
  22380. CreateUserId = dto.Userid,
  22381. ParentId = 0,
  22382. Details = "公务活动"
  22383. });
  22384. }
  22385. break;
  22386. }
  22387. }
  22388. }
  22389. else
  22390. {
  22391. foreach (var fallTime in fallTimesNotCheckCountry)
  22392. {
  22393. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22394. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22395. {
  22396. foreach (var addTime in fallTime.Item2)
  22397. {
  22398. chiarr.Add(new Grp_ApprovalTravelDetails
  22399. {
  22400. Time = addTime,
  22401. CreateTime = DateTime.Now,
  22402. CreateUserId = dto.Userid,
  22403. ParentId = 0,
  22404. Details = "公务活动"
  22405. });
  22406. }
  22407. break;
  22408. }
  22409. }
  22410. }
  22411. }
  22412. }
  22413. }
  22414. //添加乘车语句
  22415. //chiarr.Add(new Grp_ApprovalTravelDetails
  22416. //{
  22417. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  22418. // CreateTime = DateTime.Now,
  22419. // CreateUserId = dto.Userid,
  22420. // ParentId = 0,
  22421. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  22422. //});
  22423. //if (i != timeArr.Count - 1)
  22424. //{
  22425. // fallToTime = fallToTime.AddHours(2.5);
  22426. // foreach (var item in Times)
  22427. // {
  22428. // //排列公务时间
  22429. // if (fallToTime.Hour < item.Item1)
  22430. // {
  22431. // chiarr.Add(new Grp_ApprovalTravelDetails
  22432. // {
  22433. // Time = $"{item.Item2} - {item.Item3}",
  22434. // CreateTime = DateTime.Now,
  22435. // CreateUserId = dto.Userid,
  22436. // ParentId = 0,
  22437. // Details = "公务活动"
  22438. // });
  22439. // }
  22440. // }
  22441. //}
  22442. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22443. var last = threeCodeStr.Last();
  22444. foreach (var item in threeCodeStr)
  22445. {
  22446. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22447. if (item.Equals(last))
  22448. {
  22449. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22450. }
  22451. }
  22452. cityPath = cityPath.Trim('-');
  22453. }
  22454. else
  22455. {
  22456. foreach (var item in Times)
  22457. {
  22458. chiarr.Add(new Grp_ApprovalTravelDetails
  22459. {
  22460. Time = $"{item.Item2} - {item.Item3}",
  22461. CreateTime = DateTime.Now,
  22462. CreateUserId = dto.Userid,
  22463. ParentId = 0,
  22464. Details = "公务活动"
  22465. });
  22466. }
  22467. }
  22468. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22469. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22470. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  22471. appro.Diid = dto.Diid;
  22472. appro.CreateUserId = dto.Userid;
  22473. appro.CreateTime = DateTime.Now;
  22474. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22475. appro.Id = thisId;
  22476. //foreach (var item in gwinfo)
  22477. //{
  22478. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  22479. // chi.Details = "拜访" + item.Client;
  22480. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  22481. // {
  22482. // chi.Details += "," + item.ReqSample;
  22483. // }
  22484. // chi.ParentId = thisId;
  22485. // chi.Time = item.Time;
  22486. // chiarr.Add(chi);
  22487. //}
  22488. if (chiarr.Count < 6)
  22489. {
  22490. for (int j = chiarr.Count; j < 6; j++)
  22491. {
  22492. chiarr.Add(new
  22493. Grp_ApprovalTravelDetails());
  22494. }
  22495. }
  22496. resultArr.Add(new
  22497. {
  22498. appro.Id,
  22499. appro.Date,
  22500. appro.Diid,
  22501. chiList = chiarr.Select(x1 => new
  22502. {
  22503. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22504. x1.Details,
  22505. x1.ParentId,
  22506. x1.Id
  22507. })
  22508. });
  22509. }
  22510. _sqlSugar.CommitTran();
  22511. jw = JsonView(true, "生成成功!", resultArr);
  22512. }
  22513. catch (Exception ex)
  22514. {
  22515. jw.Code = 400;
  22516. jw.Msg = "生成失败!" + ex.Message;
  22517. }
  22518. return Ok(jw);
  22519. }
  22520. /// <summary>
  22521. /// 报批行程word导出
  22522. /// </summary>
  22523. /// <param name="dto"></param>
  22524. /// <returns></returns>
  22525. [HttpPost]
  22526. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  22527. {
  22528. var jw = JsonView(false);
  22529. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22530. if (group == null)
  22531. {
  22532. jw.Msg = "暂无该团组!";
  22533. return Ok(jw);
  22534. }
  22535. //模板路径
  22536. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  22537. var fileName = string.Empty;
  22538. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  22539. bool bold = false;
  22540. if (dto.FileIndex == 1)
  22541. {
  22542. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  22543. }
  22544. else if (dto.FileIndex == 2)
  22545. {
  22546. fileName = "省外办-报批.docx";
  22547. bold = false;
  22548. titleFont = "方正黑体简体";
  22549. timeFont = "Times New Roman";
  22550. contentFont = "方正仿宋_GBK";
  22551. }
  22552. else if (dto.FileIndex == 3)
  22553. {
  22554. fileName = "市外办-报批.docx";
  22555. titleFont = "方正黑体简体";
  22556. timeFont = "Times New Roman";
  22557. contentFont = "方正仿宋简体";
  22558. }
  22559. tempPath = tempPath + fileName;
  22560. //载入模板
  22561. Document doc = new Document(tempPath);
  22562. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  22563. //获取所填表格的序数
  22564. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  22565. Aspose.Words.Tables.Row titleRowClone = null;
  22566. Aspose.Words.Tables.Row CenterRowClone = null;
  22567. int index = 0;
  22568. int indexChi = 0;
  22569. int SetIndex = 0;
  22570. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  22571. //获取数据,放到datatable
  22572. foreach (var item in ApprovalTravelArr)
  22573. {
  22574. if (index > 0)
  22575. {
  22576. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  22577. tableOne.AppendChild(titleRowClone);
  22578. }
  22579. var textTime = item.Date;
  22580. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  22581. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  22582. SetIndex++;
  22583. if (ChiRep.Count > 0)
  22584. {
  22585. foreach (var itemChi in ChiRep)
  22586. {
  22587. var txtTime = itemChi.Time;
  22588. var txtDetail = itemChi.Details;
  22589. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  22590. {
  22591. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  22592. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22593. //indexChi++;
  22594. //SetIndex++;
  22595. break;
  22596. }
  22597. if (indexChi > 0)
  22598. {
  22599. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22600. tableOne.AppendChild(CenterRowClone);
  22601. }
  22602. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  22603. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  22604. indexChi++;
  22605. SetIndex++;
  22606. }
  22607. }
  22608. //else
  22609. //{
  22610. // if (indexChi > 0)
  22611. // {
  22612. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22613. // tableOne.AppendChild(CenterRowClone);
  22614. // }
  22615. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  22616. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22617. // indexChi++;
  22618. // SetIndex++;
  22619. //}
  22620. index++;
  22621. }
  22622. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  22623. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22624. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22625. jw.Code = 200;
  22626. jw.Msg = "";
  22627. return Ok(jw);
  22628. }
  22629. private string ParseBlackTime(string time)
  22630. {
  22631. // 匹配可能只有分钟的情况
  22632. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  22633. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  22634. if (match.Success)
  22635. {
  22636. string hours = match.Groups[1].Value;
  22637. string minutes = match.Groups[2].Value;
  22638. // 如果小时部分为空,则只显示分钟
  22639. if (string.IsNullOrEmpty(hours))
  22640. {
  22641. return $"{minutes}分钟";
  22642. }
  22643. // 如果分钟部分为空,则只显示小时
  22644. else if (string.IsNullOrEmpty(minutes))
  22645. {
  22646. return $"{hours}小时";
  22647. }
  22648. // 否则显示完整格式
  22649. else
  22650. {
  22651. return $"{hours}小时{minutes}分钟";
  22652. }
  22653. }
  22654. else
  22655. {
  22656. return "未知时长";
  22657. }
  22658. }
  22659. private string intToString(int numberVal)
  22660. {
  22661. string numberval = numberVal.ToString();
  22662. Dictionary<char, string> Number = new Dictionary<char, string>();
  22663. Number.Add('1', "一");
  22664. Number.Add('2', "二");
  22665. Number.Add('3', "三");
  22666. Number.Add('4', "四");
  22667. Number.Add('5', "五");
  22668. Number.Add('6', "六");
  22669. Number.Add('7', "七");
  22670. Number.Add('8', "八");
  22671. Number.Add('9', "九");
  22672. string stringNumberVal = string.Empty;
  22673. for (int i = 0; i < numberval.Length; i++)
  22674. {
  22675. if (i == 0)
  22676. {
  22677. stringNumberVal += Number[numberval[i]];
  22678. }
  22679. else if (i >= 1)
  22680. {
  22681. if (numberval[i] == '0')
  22682. {
  22683. stringNumberVal = "十";
  22684. }
  22685. else
  22686. {
  22687. stringNumberVal += "十" + Number[numberval[i]];
  22688. }
  22689. }
  22690. }
  22691. return stringNumberVal;
  22692. }
  22693. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  22694. {
  22695. //获取table中的某个单元格,从0开始
  22696. Cell lshCell = table.Rows[rows].Cells[cells];
  22697. //将单元格中段落移除
  22698. foreach (Paragraph item in lshCell.Paragraphs)
  22699. {
  22700. lshCell.Paragraphs.Remove(item);
  22701. }
  22702. if (val.Contains("\r\n"))
  22703. {
  22704. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  22705. foreach (var item in spArr)
  22706. {
  22707. //新建一个段落
  22708. Paragraph p = new Paragraph(doc);
  22709. var r = new Run(doc, item);
  22710. //设置字体
  22711. if (!string.IsNullOrEmpty(font))
  22712. {
  22713. r.Font.Name = font;
  22714. }
  22715. r.Font.Bold = bold;
  22716. //把设置的值赋给之前新建的段落
  22717. p.AppendChild(r);
  22718. //将此段落加到单元格内
  22719. lshCell.AppendChild(p);
  22720. }
  22721. }
  22722. else
  22723. {
  22724. //新建一个段落
  22725. Paragraph p = new Paragraph(doc);
  22726. var r = new Run(doc, val);
  22727. //设置字体
  22728. if (!string.IsNullOrEmpty(font))
  22729. {
  22730. r.Font.Name = font;
  22731. }
  22732. r.Font.Bold = bold;
  22733. //把设置的值赋给之前新建的段落
  22734. p.AppendChild(r);
  22735. //将此段落加到单元格内
  22736. lshCell.AppendChild(p);
  22737. }
  22738. }
  22739. /// <summary>
  22740. /// 报批行程AI续写
  22741. /// </summary>
  22742. /// <returns></returns>
  22743. [HttpPost]
  22744. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  22745. {
  22746. var jw = JsonView(false);
  22747. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  22748. {
  22749. jw.Msg = "参数有误!";
  22750. return Ok(jw);
  22751. }
  22752. KiMiApiClient kiMi = new KiMiApiClient();
  22753. List<SeedMessages> messages = new List<SeedMessages>() {
  22754. new SeedMessages
  22755. {
  22756. Role = KimiRole.system,
  22757. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  22758. },
  22759. new SeedMessages
  22760. {
  22761. Role = KimiRole.user,
  22762. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  22763. }
  22764. };
  22765. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  22766. string data = kimi_result.Choices[0]?.Message.Content;
  22767. if (string.IsNullOrWhiteSpace(data))
  22768. {
  22769. jw.Data = "Ai续写失败!";
  22770. }
  22771. else
  22772. {
  22773. jw = JsonView(true, "success!", data);
  22774. }
  22775. return Ok(jw);
  22776. }
  22777. #endregion
  22778. #region 团组接待意见调查
  22779. /// <summary>
  22780. /// 团组接待意见调查 - 信息管理
  22781. /// 基础数据(团组)
  22782. /// </summary>
  22783. /// <returns></returns>
  22784. [HttpGet]
  22785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22786. public async Task<IActionResult> OpinionaireInit()
  22787. {
  22788. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  22789. .Select(x => new
  22790. {
  22791. x.Id,
  22792. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  22793. })
  22794. .OrderByDescending(x => x.Id)
  22795. .ToListAsync();
  22796. return Ok(JsonView(groupData, groupData.Count));
  22797. }
  22798. /// <summary>
  22799. /// 团组接待意见调查 - 信息管理
  22800. /// 列表
  22801. /// </summary>
  22802. /// <param name="groupId"></param>
  22803. /// <returns></returns>
  22804. [HttpGet("{groupId}")]
  22805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22806. public async Task<IActionResult> OpinionaireManageList(int groupId)
  22807. {
  22808. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22809. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  22810. .Select(x => new
  22811. {
  22812. x.Id,
  22813. x.TourGuideName,
  22814. x.CityName,
  22815. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  22816. x.CreateTime
  22817. })
  22818. .OrderBy(x => x.Id)
  22819. .ToListAsync();
  22820. return Ok(JsonView(data));
  22821. }
  22822. /// <summary>
  22823. /// 团组接待意见调查 - 信息管理
  22824. /// 保存
  22825. /// </summary>
  22826. /// <param name="dto"></param>
  22827. /// <returns></returns>
  22828. [HttpPost]
  22829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22830. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  22831. {
  22832. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22833. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22834. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22835. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  22836. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  22837. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  22838. _opinionaireRep.BeginTran();
  22839. if (addData != null && addData.Count > 0)
  22840. {
  22841. foreach (var item in addData)
  22842. {
  22843. item.CreateUserId = currUserInfo.UserId;
  22844. item.DiId = dto.DiId;
  22845. }
  22846. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  22847. }
  22848. if (updData != null && updData.Count > 0)
  22849. {
  22850. var upd = await _opinionaireRep._sqlSugar
  22851. .Updateable(updData)
  22852. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  22853. .WhereColumns(x => new { x.Id })
  22854. .ExecuteCommandAsync();
  22855. }
  22856. _opinionaireRep.CommitTran();
  22857. return Ok(JsonView("操作成功!"));
  22858. }
  22859. /// <summary>
  22860. /// 团组接待意见调查 - 信息管理
  22861. /// 删除
  22862. /// </summary>
  22863. /// <param name="id"></param>
  22864. /// <returns></returns>
  22865. [HttpDelete("{id}")]
  22866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22867. public async Task<IActionResult> OpinionaireManageDel(int id)
  22868. {
  22869. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22870. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22871. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22872. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22873. if (!del) return Ok(JsonView("操作失败!"));
  22874. return Ok(JsonView("操作成功!"));
  22875. }
  22876. /// <summary>
  22877. /// 团组接待意见调查 - 用户
  22878. /// 列表
  22879. /// </summary>
  22880. /// <param name="diId"></param>
  22881. /// <returns></returns>
  22882. [HttpGet("{diId}")]
  22883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22884. public async Task<IActionResult> OpinionaireUserList(int diId)
  22885. {
  22886. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22887. var sql = string.Format(@"
  22888. SELECT
  22889. o.Id,
  22890. o.DiId,
  22891. di.TeamName AS 'GroupName',
  22892. di.VisitPNumber AS 'PeopleNumber',
  22893. di.ClientName AS 'LeadGroup',
  22894. di.VisitCountry AS 'Travel',
  22895. di.VisitDays AS 'Days',
  22896. o.CityName,
  22897. o.TourGuideName,
  22898. o.Catering,
  22899. o.CateringReason,
  22900. o.Stay,
  22901. o.StayReason,
  22902. o.[Route],
  22903. o.RouteReason,
  22904. o.OfficialActivity,
  22905. o.OfficialActivityReason,
  22906. o.TourGuide,
  22907. o.TourGuideReason,
  22908. o.[Translate],
  22909. o.TranslateReason,
  22910. o.Trip,
  22911. o.TripReason,
  22912. o.ESFileName,
  22913. o.SignatureDate,
  22914. o.Remark
  22915. FROM
  22916. Grp_Opinionaire o
  22917. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22918. WHERE
  22919. o.IsDel = 0
  22920. AND o.DiId = {0}
  22921. ORDER BY
  22922. o.Id ASC", diId);
  22923. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22924. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22925. return Ok(JsonView(data));
  22926. }
  22927. /// <summary>
  22928. /// 团组接待意见调查 - 用户
  22929. /// 保存
  22930. /// </summary>
  22931. /// <param name="dto"></param>
  22932. /// <returns></returns>
  22933. [HttpPost]
  22934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22935. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22936. {
  22937. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22938. foreach (var item in dto)
  22939. {
  22940. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22941. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22942. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22943. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22944. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22945. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22946. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22947. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22948. }
  22949. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22950. if (!Directory.Exists(filePathBase))
  22951. {
  22952. Directory.CreateDirectory(filePathBase);
  22953. }
  22954. #region 上传文件
  22955. var filePaths = new List<string>();
  22956. foreach (var item in dto)
  22957. {
  22958. var file = item.File;
  22959. // 将文件保存到指定位置
  22960. var filePath = Path.Combine(filePathBase, file.FileName);
  22961. using (var stream = new FileStream(filePath, FileMode.Create))
  22962. {
  22963. await file.CopyToAsync(stream);
  22964. }
  22965. //验证文件是否上传成功
  22966. if (!System.IO.File.Exists(filePath))
  22967. {
  22968. foreach (var filePathStr in filePaths)
  22969. {
  22970. System.IO.File.Delete(filePathStr);
  22971. }
  22972. return Ok(JsonView(false, "文件上传失败!"));
  22973. }
  22974. item.ESFileName = file.FileName;
  22975. }
  22976. #endregion
  22977. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22978. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22979. .UpdateColumns(x => new
  22980. {
  22981. x.Catering,
  22982. x.CateringReason,
  22983. x.Stay,
  22984. x.StayReason,
  22985. x.Route,
  22986. x.RouteReason,
  22987. x.OfficialActivity,
  22988. x.OfficialActivityReason,
  22989. x.TourGuide,
  22990. x.TourGuideReason,
  22991. x.Translate,
  22992. x.TranslateReason,
  22993. x.Trip,
  22994. x.TripReason,
  22995. x.ESFileName,
  22996. x.SignatureDate,
  22997. x.Remark
  22998. })
  22999. .WhereColumns(x => new { x.Id })
  23000. .ExecuteCommandAsync();
  23001. if (upd < 1)
  23002. {
  23003. foreach (var filePathStr in filePaths)
  23004. {
  23005. System.IO.File.Delete(filePathStr);
  23006. }
  23007. return Ok(JsonView(false));
  23008. }
  23009. return Ok(JsonView(true));
  23010. }
  23011. #endregion
  23012. #region 团组餐厅相关信息
  23013. /// <summary>
  23014. /// 团组相关餐厅信息
  23015. /// 基础数据(团组)
  23016. /// </summary>
  23017. /// <returns></returns>
  23018. [HttpGet]
  23019. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23020. public async Task<IActionResult> RestaurantInit()
  23021. {
  23022. return Ok(await _restaurantRep.InitAsync());
  23023. }
  23024. /// <summary>
  23025. /// 团组相关餐厅信息
  23026. /// Item
  23027. /// </summary>
  23028. /// <param name="dto"></param>
  23029. /// <returns></returns>
  23030. [HttpPost]
  23031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23032. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  23033. {
  23034. int portType = dto.PortType,
  23035. groupId = dto.GroupId;
  23036. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23037. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23038. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  23039. }
  23040. /// <summary>
  23041. /// 团组相关餐厅信息
  23042. /// List
  23043. /// </summary>
  23044. /// <param name="dto"></param>
  23045. /// <returns></returns>
  23046. [HttpPost]
  23047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23048. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  23049. {
  23050. int portType = dto.PortType,
  23051. groupId = dto.GroupId;
  23052. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23053. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23054. var sql = string.Format(@" SELECT
  23055. ri.Id,
  23056. ri.GroupId,
  23057. ri.Date,
  23058. ri.StartTime,
  23059. ri.EndTime,
  23060. CASE WHEN ri.Type = 1 THEN '早餐'
  23061. WHEN ri.Type = 2 THEN '午餐'
  23062. WHEN ri.Type = 3 THEN '晚餐'
  23063. ELSE '其他'
  23064. END AS 'Type',
  23065. ri.Name,
  23066. ri.Address,
  23067. ri.Tel,
  23068. ri.Remark,
  23069. ri.CreateTime,
  23070. u.CnName AS CreateUserName
  23071. FROM
  23072. Grp_RestaurantInfo ri
  23073. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  23074. WHERE
  23075. ri.IsDel = 0
  23076. AND ri.GroupId = {0}
  23077. ORDER BY
  23078. ri.Date ASC
  23079. ", groupId);
  23080. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  23081. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  23082. return Ok(JsonView(infos));
  23083. }
  23084. /// <summary>
  23085. /// 团组相关餐厅信息
  23086. /// Info
  23087. /// </summary>
  23088. /// <param name="dto"></param>
  23089. /// <returns></returns>
  23090. [HttpPost]
  23091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23092. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  23093. {
  23094. int portType = dto.PortType,
  23095. id = dto.Id;
  23096. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23097. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23098. return Ok(await _restaurantRep.InfoAsync(portType, id));
  23099. }
  23100. /// <summary>
  23101. /// 团组相关餐厅信息
  23102. /// Op
  23103. /// </summary>
  23104. /// <param name="dto"></param>
  23105. /// <returns></returns>
  23106. [HttpPost]
  23107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23108. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  23109. {
  23110. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23111. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23112. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  23113. return Ok(await _restaurantRep.OpAsync(dto));
  23114. }
  23115. /// <summary>
  23116. /// 团组相关餐厅信息
  23117. /// Del
  23118. /// </summary>
  23119. /// <param name="dto"></param>
  23120. /// <returns></returns>
  23121. [HttpPost]
  23122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23123. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  23124. {
  23125. int userId = dto.DeleteUserId;
  23126. var id = dto.Id;
  23127. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23128. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23129. return Ok(await _restaurantRep.DelAsync(dto));
  23130. }
  23131. #endregion
  23132. #region 团组会务成本
  23133. /// <summary>
  23134. /// 团组会务成本数据初始化
  23135. /// </summary>
  23136. /// <returns></returns>
  23137. [HttpPost]
  23138. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  23139. {
  23140. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23141. .OrderByDescending(x => x.CreateTime)
  23142. .Where(x => x.IsDel == 0)
  23143. .Select<DelegationEasyView>();
  23144. DelegationEasyView di = Dto.GroupId == 0 ?
  23145. expr.First() :
  23146. expr.First(x => x.Id == Dto.GroupId);
  23147. if (di == null)
  23148. {
  23149. return Ok(JsonView(false, "团组信息不存在!"));
  23150. }
  23151. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  23152. .Where(x => x.IsDel == 0 && x.STid == 21)
  23153. .Select(x => new { x.Id, Text = x.Name })
  23154. .ToListAsync();
  23155. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  23156. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  23157. .Select(x => x.Id)
  23158. .ToList();
  23159. //仅检索会务团组
  23160. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  23161. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  23162. .OrderByDescending(x => x.VisitDate)
  23163. .Select(x => new { x.Id, x.TeamName })
  23164. .ToListAsync();
  23165. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  23166. var userList = await _sqlSugar.Queryable<Sys_Users>()
  23167. .Where(x => x.IsDel == 0)
  23168. .Select(x => new { x.Id, x.CnName })
  23169. .ToListAsync();
  23170. var units = await _sqlSugar.Queryable<Sys_SetData>()
  23171. .Where(x => x.IsDel == 0 && x.STid == 119)
  23172. .Select(x => new { x.Id, Text = x.Name })
  23173. .ToListAsync();
  23174. var FileType = new[]
  23175. {
  23176. new { Id = 0 , Name = "成本下载" },
  23177. new { Id = 1 , Name = "报价下载" },
  23178. new { Id = 2 , Name = "总表下载" },
  23179. };
  23180. var GM = new List<int>();
  23181. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  23182. try
  23183. {
  23184. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  23185. }
  23186. catch (Exception ex)
  23187. {
  23188. GM = new List<int>() { 21 };
  23189. }
  23190. var isReview = Dto.UserId == 21;
  23191. var isGM = GM.Contains(Dto.UserId);
  23192. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23193. .Where(x => x.IsDel == 0)
  23194. .Select<ConferenceAffairsCostView>()
  23195. .First(x => x.Diid == di.Id);
  23196. if (ConferenceAffairsCost == null)
  23197. {
  23198. ConferenceAffairsCost = new ConferenceAffairsCostView();
  23199. ConferenceAffairsCost.Diid = di.Id;
  23200. }
  23201. #region 权限校验
  23202. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  23203. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  23204. .Select(x => x.UserId)
  23205. .Distinct()
  23206. .ToList();
  23207. if (!ids.Contains(Dto.UserId) && !isGM)
  23208. {
  23209. return Ok(JsonView(201, "暂无权限!", new
  23210. {
  23211. typeData,
  23212. groupList,
  23213. currenyList,
  23214. isGM,
  23215. userList,
  23216. units,
  23217. isReview,
  23218. operatorUser = ids,
  23219. di,
  23220. FileType
  23221. }));
  23222. }
  23223. #endregion
  23224. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  23225. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  23226. .Select<ConferenceAffairsCostChildView>()
  23227. .OrderBy(x => x.Index)
  23228. .ToList();
  23229. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  23230. {
  23231. ConferenceAffairsCostChi[i - 1].Index = i;
  23232. }
  23233. var backData = new
  23234. {
  23235. ConferenceAffairsCost,
  23236. ConferenceAffairsCostChi,
  23237. typeData,
  23238. groupList,
  23239. currenyList,
  23240. isGM,
  23241. userList,
  23242. units,
  23243. isReview,
  23244. operatorUser = ids,
  23245. di,
  23246. FileType
  23247. };
  23248. return Ok(JsonView(true, "SUCCESS", backData));
  23249. }
  23250. /// <summary>
  23251. /// 会务成本保存
  23252. /// </summary>
  23253. /// <returns></returns>
  23254. [HttpPost]
  23255. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  23256. {
  23257. _sqlSugar.BeginTran();
  23258. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  23259. var childResult = new
  23260. {
  23261. success = 0,
  23262. error = 0
  23263. };
  23264. try
  23265. {
  23266. if (data.Id == 0)
  23267. {
  23268. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23269. .Where(x => x.Diid == Dto.GroupId)
  23270. .SetColumns(x => new Grp_ConferenceAffairsCost
  23271. {
  23272. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23273. DeleteUserId = Dto.UserId
  23274. })
  23275. .ExecuteCommand();
  23276. data.Diid = Dto.GroupId;
  23277. data.CreateTime = DateTime.Now;
  23278. data.CreateUserId = Dto.UserId;
  23279. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  23280. .ExecuteReturnIdentity();
  23281. }
  23282. else
  23283. {
  23284. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  23285. .ExecuteCommand();
  23286. data.Id = data.Id;
  23287. }
  23288. if (Dto.ConferenceAffairsCostChild.Any())
  23289. {
  23290. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  23291. var insertArr = datas.Where(x => x.Id == 0).ToList();
  23292. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  23293. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  23294. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  23295. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  23296. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  23297. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  23298. .ExecuteCommand() : 0;
  23299. childResult = childResult with
  23300. {
  23301. error = notUpdateArr.Count(),
  23302. success = inrsetCount + updateCount
  23303. };
  23304. }
  23305. _sqlSugar.CommitTran();
  23306. }
  23307. catch (Exception ex)
  23308. {
  23309. _sqlSugar.RollbackTran();
  23310. return Ok(JsonView(false, "失败!" + ex.Message));
  23311. }
  23312. return Ok(JsonView(true, "操作成功!", childResult));
  23313. }
  23314. [HttpPost]
  23315. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  23316. {
  23317. var count = 0;
  23318. if (Dto.ConferenceAffairsCostChildids.Any())
  23319. {
  23320. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  23321. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  23322. SetColumns(x => new Grp_ConferenceAffairsCostChild
  23323. {
  23324. ReviewStatus = Dto.ReviewStatus
  23325. }).
  23326. ExecuteCommand();
  23327. }
  23328. return Ok(JsonView(true, "操作成功!", count));
  23329. }
  23330. /// <summary>
  23331. /// 会务成本所有数据清除
  23332. /// </summary>
  23333. /// <param name="Dto"></param>
  23334. /// <returns></returns>
  23335. [HttpPost]
  23336. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  23337. {
  23338. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23339. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  23340. _sqlSugar.BeginTran();
  23341. try
  23342. {
  23343. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23344. .Where(x => x.Diid == Dto.GroupId)
  23345. .SetColumns(x => new Grp_ConferenceAffairsCost
  23346. {
  23347. IsDel = 1,
  23348. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23349. DeleteUserId = Dto.UserId
  23350. })
  23351. .ExecuteCommand();
  23352. if (delCount > 0)
  23353. {
  23354. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23355. .Where(x => x.Diid == Dto.GroupId)
  23356. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23357. {
  23358. IsDel = 1,
  23359. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23360. DeleteUserId = Dto.UserId
  23361. })
  23362. .ExecuteCommand();
  23363. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23364. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23365. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23366. {
  23367. IsDel = 1,
  23368. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23369. DeleteUserId = Dto.UserId
  23370. })
  23371. .ExecuteCommand();
  23372. }
  23373. _sqlSugar.CommitTran();
  23374. }
  23375. catch (Exception ex)
  23376. {
  23377. _sqlSugar.RollbackTran();
  23378. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23379. }
  23380. return Ok(JsonView(true, "操作成功!"));
  23381. }
  23382. /// <summary>
  23383. /// 子项数据删除
  23384. /// </summary>
  23385. /// <param name="Dto"></param>
  23386. /// <returns></returns>
  23387. [HttpPost]
  23388. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  23389. {
  23390. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  23391. .Any(x => x.ReviewStatus == 1);
  23392. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  23393. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23394. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  23395. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23396. {
  23397. IsDel = 1,
  23398. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23399. DeleteUserId = Dto.UserId
  23400. })
  23401. .ExecuteCommand();
  23402. return Ok(JsonView(true, "SUCCESS!", count));
  23403. }
  23404. /// <summary>
  23405. /// 会务成本权限分配
  23406. /// </summary>
  23407. /// <param name="Dto"></param>
  23408. /// <returns></returns>
  23409. [HttpPost]
  23410. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  23411. {
  23412. _sqlSugar.BeginTran();
  23413. var count = 0;
  23414. try
  23415. {
  23416. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23417. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23418. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23419. {
  23420. IsDel = 1,
  23421. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23422. DeleteUserId = Dto.CreateUserId
  23423. })
  23424. .ExecuteCommand();
  23425. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  23426. {
  23427. CreateTime = DateTime.Now,
  23428. CreateUserId = Dto.CreateUserId,
  23429. UserId = x,
  23430. Diid = Dto.GroupId,
  23431. }).ToList()).ExecuteCommand();
  23432. _sqlSugar.CommitTran();
  23433. }
  23434. catch (Exception ex)
  23435. {
  23436. _sqlSugar.RollbackTran();
  23437. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23438. }
  23439. return Ok(JsonView(true, "操作成功!", count));
  23440. }
  23441. /// <summary>
  23442. /// 团组会务成本文件下载
  23443. /// </summary>
  23444. /// <returns></returns>
  23445. [HttpPost]
  23446. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  23447. {
  23448. var FileType = new[]
  23449. {
  23450. new { Id = 0 , Name = "成本下载" },
  23451. new { Id = 1 , Name = "报价下载" },
  23452. new { Id = 2 , Name = "总表下载" },
  23453. };
  23454. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23455. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  23456. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23457. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  23458. .Select<DelegationEasyView>()
  23459. .First();
  23460. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23461. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  23462. if (main == null)
  23463. {
  23464. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  23465. }
  23466. JsonView jw = JsonView(false);
  23467. //总表下载
  23468. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  23469. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  23470. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  23471. var field = string.Empty;
  23472. var fileTypeName = string.Empty;
  23473. field = @$"
  23474. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  23475. b.Name as PriceTypeStr ,
  23476. c.Name as CurrencyStr ,
  23477. d.Name as UnitStr ,
  23478. case a.ReviewStatus
  23479. WHEN 1 THEN '已通过'
  23480. WHEN 0 THEN '未审核'
  23481. WHEN -1 THEN '未通过'
  23482. ELSE '未审核'
  23483. END AS ReviewStatusStr
  23484. ";
  23485. if (Dto.FileTypeId == 0)
  23486. {
  23487. fileTypeName = "会务成本成本表";
  23488. loadPath += $"{fileTypeName}.xlsx";
  23489. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23490. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23491. }
  23492. else if (Dto.FileTypeId == 1)
  23493. {
  23494. fileTypeName = "会务成本报价表";
  23495. loadPath += $"{fileTypeName}.xlsx";
  23496. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23497. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23498. }
  23499. else if (Dto.FileTypeId == 2)
  23500. {
  23501. fileTypeName = "会务成本总表";
  23502. loadPath += $"{fileTypeName}.xlsx";
  23503. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23504. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23505. }
  23506. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  23507. SELECT
  23508. {field}
  23509. FROM Grp_ConferenceAffairsCostChild a
  23510. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  23511. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  23512. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  23513. WHERE a.isdel = 0
  23514. AND a.Diid = {main.Diid}
  23515. AND a.ConferenceAffairsCostId = {main.Id}
  23516. ").ToList();
  23517. var currLists = chiExcelContent.Select(x => new CurrList
  23518. {
  23519. CurrName = x.CurrencyStr,
  23520. CurrRate = x.Rate
  23521. })
  23522. .Distinct()
  23523. .ToList();
  23524. var designer = new WorkbookDesigner
  23525. {
  23526. Workbook = new Workbook(loadPath)
  23527. };
  23528. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  23529. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  23530. designer.SetDataSource("TeamName", di.TeamName);
  23531. designer.SetDataSource("City", main.City);
  23532. designer.SetDataSource("AllCost", main.CostAll);
  23533. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  23534. designer.SetDataSource("Curr", MostCurr.Name);
  23535. designer.SetDataSource("Curr1", MostCurr.Name);
  23536. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  23537. dt.TableName = "TB";
  23538. designer.SetDataSource(dt);
  23539. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  23540. dt1.TableName = "currTb";
  23541. designer.SetDataSource(dt1);
  23542. designer.Process();
  23543. designer.Workbook.Save(outputPath);
  23544. jw = JsonView(true, "操作成功!", new
  23545. {
  23546. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  23547. FilePath = networkPath
  23548. });
  23549. return Ok(jw);
  23550. }
  23551. [HttpPost]
  23552. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  23553. {
  23554. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  23555. .Select(x => x.PriceName).ToList()));
  23556. }
  23557. #endregion
  23558. #region 团组签证流程
  23559. /// <summary>
  23560. /// 团组签证流程 - 团组列表(分页)
  23561. /// </summary>
  23562. /// <returns></returns>
  23563. [HttpPost]
  23564. public async Task<IActionResult> VisaProcessGroupNames(VisaProcessGroupNamesDto dto)
  23565. {
  23566. int currUserId = dto.CurrUserId <= 0 ? 1 : dto.CurrUserId;
  23567. string groupName = dto.GroupName.Trim();
  23568. int pageIndex = dto.PageIndex <= 0 ? 1 : dto.PageIndex;
  23569. int pageSize = dto.PageSize <= 0 ? 10 : dto.PageSize;
  23570. int portType = dto.PortType;
  23571. RefAsync<int> total = 0;
  23572. var query = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>()
  23573. .InnerJoin<Grp_DelegationInfo>((x, y) => x.DIId == y.Id)
  23574. .Where((x, y) => x.IsDel == 0 && x.CTId == 80 && x.UId == currUserId);
  23575. //构建单字模糊查询
  23576. if (!string.IsNullOrEmpty(groupName))
  23577. {
  23578. var characters = groupName.ToCharArray();
  23579. foreach (var character in characters)
  23580. {
  23581. var charString = character.ToString();
  23582. query = query.Where((x, y) =>
  23583. SqlFunc.Contains(y.TeamName, charString));
  23584. }
  23585. }
  23586. var groups = await query
  23587. .GroupBy((x,y) => y.Id)
  23588. .OrderByDescending((x, y) => y.VisitDate)
  23589. .Select((x, y) => new
  23590. {
  23591. y.Id,
  23592. GroupName = y.TeamName
  23593. })
  23594. .ToPageListAsync(pageIndex, pageSize, total);
  23595. var msg = "SUCCESS";
  23596. if (total <= 0) msg = "暂无可操作的团组,请联系经理分配团组!";
  23597. return Ok(JsonView(true, msg, groups,total));
  23598. }
  23599. /// <summary>
  23600. /// 团组签证流程 - 详情
  23601. /// </summary>
  23602. /// <returns></returns>
  23603. [HttpPost]
  23604. public async Task<IActionResult> VisaProcessInfoByGroupId(VisaProcessInfoByGroupIdDto dto)
  23605. {
  23606. var res = await _visaProcessRep.Info(dto);
  23607. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  23608. return Ok(JsonView(true, res.Msg, res.Data));
  23609. }
  23610. /// <summary>
  23611. /// 团组签证流程 - 流程创建测试
  23612. /// </summary>
  23613. /// <returns></returns>
  23614. [HttpPost]
  23615. public async Task<IActionResult> VisaProcessAdd(int groupId,int currUserId)
  23616. {
  23617. return Ok(await _visaProcessRep.Create(currUserId, groupId));
  23618. }
  23619. /// <summary>
  23620. /// 团组签证流程 - 流程Top4Init 测试
  23621. /// </summary>
  23622. /// <returns></returns>
  23623. [HttpPost]
  23624. public async Task<IActionResult> VisaProcessTop4StepInit(int groupId, int currUserId)
  23625. {
  23626. return Ok(await _visaProcessRep.UpdateBatchTop4Step(groupId, currUserId));
  23627. }
  23628. /// <summary>
  23629. /// 团组签证流程 - 设置状态为已完成
  23630. /// </summary>
  23631. /// <returns></returns>
  23632. [HttpPost]
  23633. public async Task<IActionResult> VisaProcessSetCompleted(int id, int currUserId)
  23634. {
  23635. //参数验证
  23636. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == id && x.IsDel == 0).AnyAsync();
  23637. if (!stepValid) return Ok(JsonView(false,"签证流程ID无效。"));
  23638. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == currUserId && x.IsDel == 0).AnyAsync();
  23639. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  23640. var res = await _visaProcessRep.SetCompleted(id, currUserId);
  23641. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  23642. return Ok(JsonView(true, res.Msg));
  23643. }
  23644. /// <summary>
  23645. /// 团组签证流程 - 修改各步骤内容
  23646. /// </summary>
  23647. /// <returns></returns>
  23648. [HttpPost]
  23649. public async Task<IActionResult> VisaProcessSetContent(VisaProcessSetContent dto)
  23650. {
  23651. //参数验证
  23652. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  23653. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  23654. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  23655. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  23656. if (dto.StepContents == null && dto.StepContents.Count < 1)
  23657. {
  23658. return Ok(JsonView(false, "步骤内容无效。"));
  23659. }
  23660. //各步骤值处理
  23661. object stepVal;
  23662. if (stepValid.Step == 7) stepVal = dto.StepContents;
  23663. else stepVal = dto.StepContents[0].ToString();
  23664. var stepInfo = new Grp_VisaProcessSteps
  23665. {
  23666. Id = dto.StepId,
  23667. DataType = stepValid.DataType,
  23668. TypedValue = stepVal,
  23669. LastUpdateUserId = dto.CurrUserId
  23670. };
  23671. var res = await _visaProcessRep.Update(stepInfo);
  23672. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  23673. return Ok(JsonView(true, res.Msg));
  23674. }
  23675. /// <summary>
  23676. /// 团组签证流程 - 上传文件
  23677. /// </summary>
  23678. /// <returns></returns>
  23679. [HttpPost]
  23680. public async Task<IActionResult> VisaProcessUploadFiles([FromForm] VisaProcessUploadFilesDto dto)
  23681. {
  23682. //参数验证
  23683. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  23684. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  23685. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  23686. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  23687. //验证文件是否存在
  23688. if (dto.Files == null || dto.Files.Count < 1) return Ok(JsonView(false, "请选择文件。"));
  23689. //验证该步骤是否可以上传文件
  23690. var uploadSteps = new List<int>() {
  23691. 5, //实际出签时间
  23692. 6, //是否需要开出境证明
  23693. 7, //是否需要办理电子入境卡手续
  23694. };
  23695. if (!uploadSteps.Contains(stepValid.Step))
  23696. {
  23697. return Ok(JsonView(false, $"该步骤不可上传附件。可上传附件步骤({string.Join("、", uploadSteps)})"));
  23698. }
  23699. //验证根目录
  23700. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  23701. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  23702. if (!System.IO.Directory.Exists(rootPath))
  23703. {
  23704. System.IO.Directory.CreateDirectory(rootPath);
  23705. }
  23706. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  23707. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  23708. .Where(x => x.IsDel == 0 && x.Id == stepValid.GroupId)
  23709. .Select(x => $"{x.TeamName}({x.Id})")
  23710. .FirstAsync();
  23711. //创建团组文件夹
  23712. var groupPath = rootPath + "GrpFile/VisaProcessFiles/" + groupName;
  23713. if (!System.IO.Directory.Exists(groupPath))
  23714. {
  23715. System.IO.Directory.CreateDirectory(groupPath);
  23716. }
  23717. List<string> filePaths = new List<string>();
  23718. //保存文件
  23719. foreach (var file in dto.Files)
  23720. {
  23721. // 生成存储文件名
  23722. var fileName = CommonFun.GenerateStoredFileName($"Step{stepValid.Step}.{file.FileName.Split(".")[1]}");
  23723. var filePath = Path.Combine(groupPath, fileName);
  23724. // 保存文件到磁盘
  23725. using (var stream = new FileStream(filePath, FileMode.Create))
  23726. {
  23727. await file.CopyToAsync(stream);
  23728. }
  23729. filePaths.Add($"GrpFile/VisaProcessFiles/{groupName}/{fileName}");
  23730. }
  23731. //数据库存储
  23732. var stepInfo = new Grp_VisaProcessSteps
  23733. {
  23734. Id = dto.StepId,
  23735. TypedFileNameValue = filePaths,
  23736. LastUpdateUserId = dto.CurrUserId
  23737. };
  23738. var res = await _sqlSugar.Updateable<Grp_VisaProcessSteps>()
  23739. .SetColumns(s => new Grp_VisaProcessSteps
  23740. {
  23741. AttachUrl = stepInfo.AttachUrl,
  23742. LastUpdateUserId = dto.CurrUserId,
  23743. LastUpdateTime = DateTime.Now
  23744. })
  23745. .Where(s => s.Id == dto.StepId && s.IsDel == 0)
  23746. .ExecuteCommandAsync();
  23747. if (res < 1) Ok(JsonView(false,"文件上传失败。"));
  23748. return Ok(JsonView(true));
  23749. }
  23750. #endregion
  23751. /// <summary>
  23752. /// 123132123
  23753. /// </summary>
  23754. /// <param name="_dto"></param>
  23755. /// <returns></returns>
  23756. [HttpPost]
  23757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23758. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  23759. {
  23760. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  23761. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  23762. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  23763. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  23764. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  23765. dicDetail.Add(789, 1034);
  23766. dicDetail.Add(790, 1035);
  23767. dicDetail.Add(791, 1036);
  23768. dicDetail.Add(792, 1037);
  23769. dicDetail.Add(793, 1038);
  23770. dicDetail.Add(794, 1039);
  23771. dicDetail.Add(795, 1040);
  23772. dicDetail.Add(796, 1041);
  23773. dicDetail.Add(797, 1042);
  23774. dicDetail.Add(798, 1043);
  23775. dicDetail.Add(801, 1044);
  23776. dicDetail.Add(802, 1045);
  23777. dicDetail.Add(803, 1046);
  23778. Dictionary<int, int> dic = new Dictionary<int, int>();
  23779. dic.Add(806, 1027);
  23780. dic.Add(807, 1028);
  23781. dic.Add(808, 1029);
  23782. dic.Add(809, 1030);
  23783. dic.Add(810, 1031);
  23784. dic.Add(811, 1032);
  23785. dic.Add(812, 1033);
  23786. foreach (var item in list_visa)
  23787. {
  23788. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  23789. temp.Coefficient = item.coefficient;
  23790. DateTime dtCrt;
  23791. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  23792. if (b1)
  23793. {
  23794. temp.CreateTime = dtCrt;
  23795. }
  23796. else
  23797. {
  23798. temp.CreateTime = DateTime.Now;
  23799. }
  23800. temp.CreateUserId = item.Operators;
  23801. temp.DeleteTime = "";
  23802. temp.DeleteUserId = 0;
  23803. temp.DiId = int.Parse(item.DIID);
  23804. temp.FilePath = item.FilePath;
  23805. temp.IsDel = item.IsDel;
  23806. temp.Price = item.Price;
  23807. temp.PriceCount = 1;
  23808. temp.PriceCurrency = item.Currency;
  23809. int detailId = 0;
  23810. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  23811. {
  23812. detailId = dicDetail[item.PriceTypeDetail];
  23813. }
  23814. temp.PriceDetailType = detailId;
  23815. temp.PriceDt = DateTime.Now;
  23816. temp.PriceName = item.PriceName;
  23817. temp.PriceSum = item.Price;
  23818. int tid = 0;
  23819. if (dic.ContainsKey(item.PriceType))
  23820. {
  23821. tid = dic[item.PriceType];
  23822. }
  23823. temp.PriceType = tid;
  23824. temp.Remark = item.Remark;
  23825. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  23826. }
  23827. return Ok(JsonView(true, "操作成功!"));
  23828. }
  23829. [HttpPost]
  23830. public IActionResult TimeTest()
  23831. {
  23832. var jw = JsonView(false, "error");
  23833. _sqlSugar.BeginTran();
  23834. try
  23835. {
  23836. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  23837. .Select(x => new Crm_NewClientData
  23838. {
  23839. Id = x.Id,
  23840. Client = x.Client,
  23841. Contact = x.Contact,
  23842. Location = x.Location,
  23843. })
  23844. .ToList();
  23845. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  23846. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  23847. Stopwatch stopwatch = new Stopwatch();
  23848. // 开始计时
  23849. stopwatch.Start();
  23850. foreach (var item in clientList)
  23851. {
  23852. EncryptionProcessor.DecryptProperties(item);
  23853. }
  23854. stopwatch.Stop();
  23855. jw.Code = 200;
  23856. jw.Data = stopwatch.ElapsedMilliseconds;
  23857. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  23858. }
  23859. catch (Exception ex)
  23860. {
  23861. jw.Code = 400;
  23862. jw.Msg = ex.Message;
  23863. }
  23864. return Ok(jw);
  23865. }
  23866. }
  23867. }