GroupsController.cs 1.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using NPOI.SS.UserModel;
  8. using NPOI.SS.Util;
  9. using NPOI.XSSF.UserModel;
  10. using OASystem.API.Middlewares;
  11. using OASystem.API.OAMethodLib;
  12. using OASystem.API.OAMethodLib.APNs;
  13. using OASystem.API.OAMethodLib.File;
  14. using OASystem.API.OAMethodLib.Hub.HubClients;
  15. using OASystem.API.OAMethodLib.Hub.Hubs;
  16. using OASystem.API.OAMethodLib.JuHeAPI;
  17. using OASystem.API.OAMethodLib.KiMiApi;
  18. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  19. using OASystem.Domain.AesEncryption;
  20. using OASystem.Domain.Attributes;
  21. using OASystem.Domain.Dtos.CRM;
  22. using OASystem.Domain.Dtos.FileDto;
  23. using OASystem.Domain.Dtos.Financial;
  24. using OASystem.Domain.Dtos.Groups;
  25. using OASystem.Domain.Entities.Customer;
  26. using OASystem.Domain.Entities.Financial;
  27. using OASystem.Domain.Entities.Groups;
  28. using OASystem.Domain.ViewModels.Financial;
  29. using OASystem.Domain.ViewModels.Groups;
  30. using OASystem.Domain.ViewModels.OCR;
  31. using OASystem.Infrastructure.Repositories.CRM;
  32. using OASystem.Infrastructure.Repositories.Financial;
  33. using OASystem.Infrastructure.Repositories.Groups;
  34. using Quartz.Util;
  35. using SqlSugar.Extensions;
  36. using System.Collections;
  37. using System.Data;
  38. using System.Diagnostics;
  39. using System.Globalization;
  40. using System.IO.Compression;
  41. using System.Web;
  42. using static OASystem.API.OAMethodLib.JWTHelper;
  43. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  44. using Bookmark = Aspose.Words.Bookmark;
  45. using Cell = Aspose.Words.Tables.Cell;
  46. using Table = Aspose.Words.Tables.Table;
  47. namespace OASystem.API.Controllers
  48. {
  49. /// <summary>
  50. /// 团组相关
  51. /// </summary>
  52. //[Authorize]
  53. [Route("api/[controller]/[action]")]
  54. public class GroupsController : ControllerBase
  55. {
  56. private readonly ILogger<GroupsController> _logger;
  57. private readonly GrpScheduleRepository _grpScheduleRep;
  58. private readonly IMapper _mapper;
  59. private readonly DelegationInfoRepository _groupRepository;
  60. private readonly TaskAssignmentRepository _taskAssignmentRep;
  61. private readonly AirTicketResRepository _airTicketResRep;
  62. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  63. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  64. private readonly DelegationEnDataRepository _delegationEnDataRep;
  65. private readonly DelegationVisaRepository _delegationVisaRep;
  66. private readonly VisaPriceRepository _visaPriceRep;
  67. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  68. private readonly HotelPriceRepository _hotelPriceRep;
  69. private readonly CustomersRepository _customersRep;
  70. private readonly MessageRepository _message;
  71. private readonly SqlSugarClient _sqlSugar;
  72. private readonly TourClientListRepository _tourClientListRep;
  73. private readonly TeamRateRepository _teamRateRep;
  74. #region 成本相关
  75. private readonly CheckBoxsRepository _checkBoxs;
  76. private readonly GroupCostRepository _GroupCostRepository;
  77. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  78. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  79. #endregion
  80. private readonly SetDataRepository _setDataRep;
  81. private string url;
  82. private string path;
  83. private readonly EnterExitCostRepository _enterExitCostRep;
  84. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  85. private readonly UsersRepository _usersRep;
  86. private readonly IJuHeApiService _juHeApi;
  87. private readonly InvertedListRepository _invertedListRep;
  88. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  89. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  90. private readonly ThreeCodeRepository _threeCodeRepository;
  91. private readonly HotelInquiryRepository _hotelInquiryRep;
  92. private readonly FeeAuditRepository _feeAuditRep;
  93. private readonly VisaCommissionRepository _visaCommissionRep;
  94. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  95. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  96. private readonly List<CurrencyInfo> _currencyInit;
  97. private readonly List<int> _portTypeData;
  98. private readonly TableOperationRecordRepository _tableorRep;
  99. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  100. private readonly RestaurantRepository _restaurantRep;
  101. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  102. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  103. /// <summary>
  104. /// 构造函数
  105. /// </summary>
  106. /// <param name="logger"></param>
  107. /// <param name="mapper"></param>
  108. /// <param name="hubContext"></param>
  109. /// <param name="sqlSugar"></param>
  110. /// <param name="grpScheduleRep"></param>
  111. /// <param name="groupRepository"></param>
  112. /// <param name="taskAssignmentRep"></param>
  113. /// <param name="airTicketResRep"></param>
  114. /// <param name="decreasePaymentsRep"></param>
  115. /// <param name="InvitationOfficialActivitiesRep"></param>
  116. /// <param name="delegationEnDataRep"></param>
  117. /// <param name="enterExitCostRep"></param>
  118. /// <param name="delegationVisaRep"></param>
  119. /// <param name="message"></param>
  120. /// <param name="visaPriceRep"></param>
  121. /// <param name="carTouristGuideGroundRep"></param>
  122. /// <param name="checkBoxs"></param>
  123. /// <param name="GroupCostRepository"></param>
  124. /// <param name="CostTypeHotelNumberRepository"></param>
  125. /// <param name="GroupCostParameterRepository"></param>
  126. /// <param name="hotelPriceRep"></param>
  127. /// <param name="customersRep"></param>
  128. /// <param name="setDataRep"></param>
  129. /// <param name="tourClientListRep"></param>
  130. /// <param name="teamRateRep"></param>
  131. /// <param name="usersRep"></param>
  132. /// <param name="juHeApi"></param>
  133. /// <param name="invertedListRep"></param>
  134. /// <param name="visaFeeInfoRep"></param>
  135. /// <param name="ticketBlackCodeRep"></param>
  136. /// <param name="hotelInquiryRep"></param>
  137. /// <param name="threeCodeRepository"></param>
  138. /// <param name="feeAuditRep"></param>
  139. /// <param name="visaCommissionRep"></param>
  140. /// <param name="ffrRep"></param>
  141. /// <param name="opinionaireRep"></param>
  142. /// <param name="tableorRep"></param>
  143. /// <param name="enterExitCostDraftRep"></param>
  144. /// <param name="restaurantRep"></param>
  145. /// <param name="enterExitCostQuoteRep"></param>
  146. /// <param name="grpOrderPreInfoRep"></param>
  147. public GroupsController(
  148. ILogger<GroupsController> logger,
  149. IMapper mapper,
  150. IHubContext<ChatHub, IChatClient> hubContext,
  151. SqlSugarClient sqlSugar,
  152. GrpScheduleRepository grpScheduleRep,
  153. DelegationInfoRepository groupRepository,
  154. TaskAssignmentRepository taskAssignmentRep,
  155. AirTicketResRepository airTicketResRep,
  156. DecreasePaymentsRepository decreasePaymentsRep,
  157. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  158. DelegationEnDataRepository delegationEnDataRep,
  159. EnterExitCostRepository enterExitCostRep,
  160. DelegationVisaRepository delegationVisaRep,
  161. MessageRepository message,
  162. VisaPriceRepository visaPriceRep,
  163. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  164. CheckBoxsRepository checkBoxs,
  165. GroupCostRepository GroupCostRepository,
  166. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  167. GroupCostParameterRepository GroupCostParameterRepository,
  168. HotelPriceRepository hotelPriceRep,
  169. CustomersRepository customersRep,
  170. SetDataRepository setDataRep,
  171. TourClientListRepository tourClientListRep,
  172. TeamRateRepository teamRateRep,
  173. UsersRepository usersRep,
  174. IJuHeApiService juHeApi,
  175. InvertedListRepository invertedListRep,
  176. VisaFeeInfoRepository visaFeeInfoRep,
  177. TicketBlackCodeRepository ticketBlackCodeRep,
  178. HotelInquiryRepository hotelInquiryRep,
  179. ThreeCodeRepository threeCodeRepository,
  180. FeeAuditRepository feeAuditRep,
  181. VisaCommissionRepository visaCommissionRep,
  182. ForeignReceivablesRepository ffrRep,
  183. OpinionaireRepository opinionaireRep,
  184. TableOperationRecordRepository tableorRep,
  185. EnterExitCostDraftRepository enterExitCostDraftRep,
  186. RestaurantRepository restaurantRep,
  187. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  188. GroupOrderPreInfoRepository grpOrderPreInfoRep
  189. )
  190. {
  191. _logger = logger;
  192. _mapper = mapper;
  193. _grpScheduleRep = grpScheduleRep;
  194. _groupRepository = groupRepository;
  195. _taskAssignmentRep = taskAssignmentRep;
  196. _airTicketResRep = airTicketResRep;
  197. _sqlSugar = sqlSugar;
  198. url = AppSettingsHelper.Get("ExcelBaseUrl");
  199. path = AppSettingsHelper.Get("ExcelBasePath");
  200. if (!System.IO.Directory.Exists(path))
  201. {
  202. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  203. }
  204. _decreasePaymentsRep = decreasePaymentsRep;
  205. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  206. _delegationEnDataRep = delegationEnDataRep;
  207. _enterExitCostRep = enterExitCostRep;
  208. _delegationVisaRep = delegationVisaRep;
  209. _message = message;
  210. _visaPriceRep = visaPriceRep;
  211. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  212. _checkBoxs = checkBoxs;
  213. _GroupCostRepository = GroupCostRepository;
  214. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  215. _GroupCostParameterRepository = GroupCostParameterRepository;
  216. _hotelPriceRep = hotelPriceRep;
  217. _customersRep = customersRep;
  218. _setDataRep = setDataRep;
  219. _tourClientListRep = tourClientListRep;
  220. _teamRateRep = teamRateRep;
  221. _hubContext = hubContext;
  222. _usersRep = usersRep;
  223. _juHeApi = juHeApi;
  224. _invertedListRep = invertedListRep;
  225. _visaFeeInfoRep = visaFeeInfoRep;
  226. _ticketBlackCodeRep = ticketBlackCodeRep;
  227. _hotelInquiryRep = hotelInquiryRep;
  228. _threeCodeRepository = threeCodeRepository;
  229. _feeAuditRep = feeAuditRep;
  230. _visaCommissionRep = visaCommissionRep;
  231. _ffrRep = ffrRep;
  232. _opinionaireRep = opinionaireRep;
  233. _currencyInit = new List<CurrencyInfo>()
  234. {
  235. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  236. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  237. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  238. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  239. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  240. };
  241. _portTypeData = new List<int>() { 2, 3 };
  242. _tableorRep = tableorRep;
  243. _enterExitCostDraftRep = enterExitCostDraftRep;
  244. _restaurantRep = restaurantRep;
  245. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  246. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  247. }
  248. #region 流程管控
  249. /// <summary>
  250. /// 获取团组流程管控信息
  251. /// </summary>
  252. /// <param name="_jsonDto">查询参数</param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  256. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  257. {
  258. if (string.IsNullOrEmpty(_jsonDto.Paras))
  259. {
  260. return Ok(JsonView(false, "参数为空"));
  261. }
  262. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  263. if (_ScheduleDto != null)
  264. {
  265. if (_ScheduleDto.SearchType == 2)//获取列表
  266. {
  267. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  268. return Ok(JsonView(_grpScheduleViewList));
  269. }
  270. else//获取对象
  271. {
  272. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  273. if (_grpScheduleView != null)
  274. {
  275. return Ok(JsonView(_grpScheduleView));
  276. }
  277. }
  278. }
  279. else
  280. {
  281. return Ok(JsonView(false, "参数反序列化失败"));
  282. }
  283. return Ok(JsonView(false, "暂无数据!"));
  284. }
  285. /// <summary>
  286. /// 修改团组流程管控详细表数据
  287. /// </summary>
  288. /// <param name="dto"></param>
  289. /// <returns></returns>
  290. [HttpPost]
  291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  292. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  293. {
  294. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  295. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  296. .SetColumns(it => it.Duty == _detail.Duty)
  297. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  298. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  299. .SetColumns(it => it.JobContent == _detail.JobContent)
  300. .SetColumns(it => it.Remark == _detail.Remark)
  301. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  302. .Where(s => s.Id == dto.Id)
  303. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  304. .ExecuteCommandAsync();
  305. if (result > 0)
  306. {
  307. return Ok(JsonView(true, "保存成功!"));
  308. }
  309. return Ok(JsonView(false, "保存失败!"));
  310. }
  311. /// <summary>
  312. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  313. /// </summary>
  314. /// <param name="dto"></param>
  315. /// <returns></returns>
  316. [HttpPost]
  317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  318. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  319. {
  320. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  321. _detail.IsDel = 1;
  322. _detail.DeleteUserId = dto.Duty;
  323. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  324. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  325. .SetColumns(it => it.IsDel == _detail.IsDel)
  326. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  327. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  328. .Where(it => it.Id == dto.Id)
  329. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  330. //.WhereColumns(s => s.Id == dto.Id)
  331. .ExecuteCommandAsync();
  332. if (result > 0)
  333. {
  334. return Ok(JsonView(true, "删除成功!"));
  335. }
  336. return Ok(JsonView(false, "删除失败!"));
  337. }
  338. /// <summary>
  339. /// 增加团组流程管控详细表数据
  340. /// </summary>
  341. /// <param name="dto"></param>
  342. /// <returns></returns>
  343. [HttpPost]
  344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  345. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  346. {
  347. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  348. if (DateTime.Now < _detail.ExpectBeginDt)
  349. {
  350. _detail.StepStatus = 0;
  351. }
  352. else
  353. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  354. _detail.StepStatus = 1;
  355. }
  356. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  357. if (result > 0)
  358. {
  359. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  360. return Ok(JsonView(true, "添加成功!", _result));
  361. }
  362. return Ok(JsonView(false, "添加失败!"));
  363. }
  364. #endregion
  365. #region 团组前期信息
  366. /// <summary>
  367. /// 团组前期信息H5-URL(员工对应地址)
  368. /// </summary>
  369. /// <param name="name">用户名称</param>
  370. /// <returns></returns>
  371. [HttpGet]
  372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  373. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  374. {
  375. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  376. .Where(x => x.IsDel == 0)
  377. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  378. .OrderBy(x => x.Id)
  379. .Select(x => new
  380. {
  381. name = x.CnName,
  382. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  383. })
  384. .ToListAsync();
  385. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  386. }
  387. /// <summary>
  388. /// 团组前期信息 List
  389. /// </summary>
  390. /// <returns></returns>
  391. [HttpPost]
  392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  393. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  394. {
  395. var search = dto.Search;
  396. int[] nameTempIds = new int[] { 1, 12, 28 },
  397. countryTempIds = new int[] { 2, 13, 29 },
  398. daysTempIds = new int[] { 4, 15, 31 },
  399. ppNumTempIds = new int[] { 6 };
  400. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  401. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  402. .Where((opi, u) => opi.IsDel == 0)
  403. .OrderByDescending((opi, u) => opi.CreateTime)
  404. .Select((opi, u) => new GroupOrderPreInfoListView()
  405. {
  406. Id = opi.Id,
  407. Name = opi.Name,
  408. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  409. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  410. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  411. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  412. Operator = u.CnName,
  413. OperationTime = opi.CreateTime
  414. })
  415. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  416. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  417. .ToListAsync();
  418. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  419. int total = list.Count;
  420. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  421. var listPageData1 = listPageData
  422. .Skip((dto.PageIndex - 1) * dto.PageSize)
  423. .Take(dto.PageSize)
  424. .ToList();
  425. var infoIds = listPageData1.Select(x => x.Id).ToList();
  426. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  427. .Where(x => x.IsDel == 0 && x.STid == 109)
  428. .ToArrayAsync();
  429. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  430. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  431. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  432. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  433. .ToListAsync();
  434. foreach (var item in listPageData1)
  435. {
  436. var typeDatas1 = typeDatas.Select(x => new
  437. {
  438. x.Id,
  439. x.Name,
  440. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  441. }).ToArray();
  442. item.VersionDetails = typeDatas1;
  443. }
  444. return Ok(JsonView(listPageData1, listPageData1.Count));
  445. }
  446. /// <summary>
  447. /// 团组前期信息 Init
  448. /// </summary>
  449. /// <returns></returns>
  450. [HttpGet("{userId}")]
  451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  452. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  453. {
  454. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  455. }
  456. /// <summary>
  457. /// 国家数据源
  458. /// </summary>
  459. /// <param name="pageIndex">当前页码</param>
  460. /// <param name="pageSize">每页条数</param>
  461. /// <param name="search">查询条件</param>
  462. /// <returns></returns>
  463. [HttpGet]
  464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  465. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  466. {
  467. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  468. if (pageIndex == 0 && pageSize == 0)
  469. {
  470. //所有数据
  471. return Ok(JsonView(countrys, countrys.Count));
  472. }
  473. //分页
  474. int skip = (pageIndex - 1) * pageSize;
  475. int take = pageSize;
  476. if (!string.IsNullOrEmpty(search))
  477. {
  478. IEnumerable<char> charSequence = search.Select(c => c);
  479. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  480. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  481. return Ok(JsonView(pageData, pageResult1.Count));
  482. }
  483. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  484. return Ok(JsonView(pageResult2, countrys.Count));
  485. }
  486. /// <summary>
  487. /// 城市数据源
  488. /// </summary>
  489. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  490. /// <param name="pageIndex">当前页码</param>
  491. /// <param name="pageSize">每页条数</param>
  492. /// <param name="search">查询条件</param>
  493. /// <returns></returns>
  494. [HttpGet("{countryLabel}")]
  495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  496. public async Task<IActionResult> CityByCountry(
  497. string countryLabel,
  498. [FromQuery] int pageIndex,
  499. [FromQuery] int pageSize,
  500. [FromQuery] string search)
  501. {
  502. countryLabel = HttpUtility.UrlDecode(countryLabel);
  503. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  504. var citys = Array.Empty<string?>();
  505. if (countryList.Any())
  506. {
  507. var cityDatas = await _sqlSugar
  508. .Queryable<Grp_NationalTravelFee>()
  509. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  510. .ToArrayAsync();
  511. foreach (var item in cityDatas)
  512. {
  513. if (item.City.Contains("城市"))
  514. {
  515. item.City = item.Country + "-所有城市";
  516. }
  517. }
  518. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  519. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  520. }
  521. if (pageIndex == 0 && pageSize == 0)
  522. {
  523. //所有数据
  524. return Ok(JsonView(citys, citys?.Length ?? 0));
  525. }
  526. //分页
  527. int skip = (pageIndex - 1) * pageSize;
  528. int take = pageSize;
  529. if (!string.IsNullOrEmpty(search))
  530. {
  531. IEnumerable<char> charSequence = search.Select(c => c);
  532. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  533. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  534. return Ok(JsonView(pageData, pageResult1.Count));
  535. }
  536. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  537. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  538. }
  539. /// <summary>
  540. /// 团组前期信息 Info
  541. /// </summary>
  542. /// <param name="dto">Id</param>
  543. /// <param name="portType">Id</param>
  544. /// <returns></returns>
  545. [HttpGet("{Id}/{TempId}")]
  546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  547. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto, int portType = 1)
  548. {
  549. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  550. }
  551. /// <summary>
  552. /// 团组前期信息 移动端 Info
  553. /// </summary>
  554. /// <param name="dto">Id</param>
  555. /// <returns></returns>
  556. [HttpGet("{Id}/{TempId}")]
  557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  558. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  559. {
  560. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  561. }
  562. /// <summary>
  563. /// 团组前期信息 Save
  564. /// </summary>
  565. /// <param name="dto">Id</param>
  566. /// <returns></returns>
  567. [HttpPost]
  568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  569. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  570. {
  571. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  572. }
  573. /// <summary>
  574. /// 团组前期信息 Del
  575. /// </summary>
  576. /// <param name="dto">Id</param>
  577. /// <returns></returns>
  578. [HttpPost]
  579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  580. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  581. {
  582. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  583. }
  584. /// <summary>
  585. /// 团组前期信息 文件下载
  586. /// </summary>
  587. /// <param name="dto">Id</param>
  588. /// <returns></returns>
  589. [HttpGet("{Id}/{TempId}")]
  590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  591. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  592. {
  593. int id = dto.Id, tempId = dto.TempId;
  594. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  595. var data = view.Data as GrpOrderPreInfoView;
  596. #region Excel
  597. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  598. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  599. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  600. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  601. var fileNamePrefix = string.Empty;
  602. if (tempId == 1405)
  603. {
  604. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  605. fileNamePrefix = $"{data.Name}_无商邀版";
  606. }
  607. else if (tempId == 1406)
  608. {
  609. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  610. fileNamePrefix = $"{data.Name}_有商邀版";
  611. }
  612. else
  613. {
  614. //tempId == 1404 默认下载
  615. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  616. fileNamePrefix = $"{data.Name}_单接送机";
  617. }
  618. foreach (var item in data.Items)
  619. {
  620. var obj = item.NewValue;
  621. if (obj == null) item.OriginVal = "";
  622. else if (obj.Equals("有") || obj.Equals("无"))
  623. {
  624. item.OriginVal = obj.ToString();
  625. }
  626. else if (obj is object[] objArray)
  627. {
  628. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  629. item.OriginVal = string.Join("、", stringArray);
  630. }
  631. else if (obj is string[] stringArray)
  632. {
  633. item.OriginVal = string.Join("、", stringArray);
  634. }
  635. else if (obj.Equals("-"))
  636. {
  637. item.OriginVal = "";
  638. }
  639. }
  640. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  641. fileName = CommonFun.ValidFileName(fileName);
  642. //载入模板
  643. var designer = new WorkbookDesigner
  644. {
  645. Workbook = new Workbook(tempPath)
  646. };
  647. if (tempId == 1406)
  648. {
  649. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  650. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  651. for (int i = 1; i <= view2.Length; i++)
  652. {
  653. view2[i - 1].Index = i;
  654. }
  655. designer.SetDataSource("View1", view1);
  656. designer.SetDataSource("View2", view2);
  657. }
  658. else
  659. {
  660. designer.SetDataSource("View", data.Items);
  661. }
  662. designer.Process();
  663. if (!Directory.Exists(savePath))
  664. {
  665. Directory.CreateDirectory(savePath);
  666. }
  667. string serverPath = $"{savePath}{fileName}";
  668. designer.Workbook.Save(serverPath);
  669. string rst = $"{servicePath}{ftpPath}{fileName}";
  670. #endregion
  671. return Ok(JsonView(new { url = rst }));
  672. }
  673. #endregion
  674. #region 团组基本信息
  675. /// <summary>
  676. /// 接团信息列表
  677. /// </summary>
  678. /// <param name="dto">团组列表请求dto</param>
  679. /// <returns></returns>
  680. [HttpPost]
  681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  682. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  683. {
  684. var groupData = await _groupRepository.GetGroupList(dto);
  685. if (groupData.Code != 0)
  686. {
  687. return Ok(JsonView(false, groupData.Msg));
  688. }
  689. return Ok(JsonView(groupData.Data));
  690. }
  691. /// <summary>
  692. /// 分页查询团组列表
  693. /// </summary>
  694. /// <param name="dto"></param>
  695. /// <returns></returns>
  696. [HttpPost]
  697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  698. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  699. {
  700. var watch = new Stopwatch();
  701. watch.Start();
  702. RefAsync<int> total = 0;
  703. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  704. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  705. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  706. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  707. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  708. .Distinct()
  709. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  710. watch.Stop();
  711. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  712. }
  713. /// <summary>
  714. /// 接团信息列表 Page Init
  715. /// </summary>
  716. /// <returns></returns>
  717. [HttpPost]
  718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  719. public async Task<IActionResult> PostGroupPageListInit()
  720. {
  721. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  722. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  723. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  724. var _view = new
  725. {
  726. depData = depDatas,
  727. rankData = rankDatas
  728. };
  729. return Ok(JsonView(true, "查询成功!", _view));
  730. }
  731. /// <summary>
  732. /// 接团信息列表 Page
  733. /// </summary>
  734. /// <param name="dto">团组列表请求dto</param>
  735. /// <returns></returns>
  736. [HttpPost]
  737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  738. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  739. {
  740. #region 参数验证
  741. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  742. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  743. #region 页面操作权限验证
  744. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  745. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  746. #endregion
  747. #endregion
  748. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  749. {
  750. string sqlWhere = string.Empty;
  751. if (dto.IsSure == 0) //未完成
  752. {
  753. sqlWhere += string.Format(@" And IsSure = 0");
  754. }
  755. else if (dto.IsSure == 1) //已完成
  756. {
  757. sqlWhere += string.Format(@" And IsSure = 1");
  758. }
  759. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  760. {
  761. string tj = dto.SearchCriteria;
  762. 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}%')",
  763. tj, tj, tj, tj, tj);
  764. }
  765. if (int.TryParse(dto.Rank, out int rankId))
  766. {
  767. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  768. }
  769. string sqlWhere1 = string.Empty;
  770. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  771. {
  772. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  773. }
  774. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  775. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  776. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  777. JietuanOperator,IsSure,CreateTime,IsBid
  778. From (
  779. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  780. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  781. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  782. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  783. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  784. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  785. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  786. From Grp_DelegationInfo gdi
  787. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  788. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  789. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  790. Where gdi.IsDel = 0 {0}
  791. ) temp {1}", sqlWhere, sqlWhere1);
  792. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  793. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  794. //处理 团组模块实际操作人
  795. _DelegationList.ForEach(async x => {
  796. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  797. var operatorNames = new StringBuilder();
  798. operatorNames.AppendLine("各模块实际操作人:");
  799. if (operators.Any())
  800. {
  801. operators.ForEach(y => {
  802. string label = string.Empty;
  803. if (y.OperationUsers.Any())
  804. {
  805. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  806. label = string.Join('、', users);
  807. }
  808. else label = "暂未指定";
  809. operatorNames.AppendLine($"{y.CTableName}:{label}");
  810. });
  811. }
  812. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  813. });
  814. var _view = new
  815. {
  816. PageFuncAuth = pageFunAuthView,
  817. Data = _DelegationList
  818. };
  819. return Ok(JsonView(true, "查询成功!", _view, total));
  820. }
  821. else
  822. {
  823. return Ok(JsonView(false, "查询失败"));
  824. }
  825. }
  826. /// <summary>
  827. /// 团组列表
  828. /// </summary>
  829. /// <returns></returns>
  830. [HttpPost]
  831. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  832. {
  833. #region 参数验证
  834. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  835. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  836. #region 页面操作权限验证
  837. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  838. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  839. #endregion
  840. #endregion
  841. if (dto.PortType != 1 && dto.PortType != 2)
  842. {
  843. return Ok(JsonView(false, "查询失败!"));
  844. }
  845. string orderbyStr = "order by gdi.CreateTime Desc";
  846. string sqlWhere = string.Empty;
  847. if (dto.IsSure == 0) //未完成
  848. {
  849. sqlWhere += string.Format(@" And IsSure = 0");
  850. }
  851. else if (dto.IsSure == 1) //已完成
  852. {
  853. sqlWhere += string.Format(@" And IsSure = 1");
  854. }
  855. //团组类型
  856. if (dto.TeamDid > 0)
  857. {
  858. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  859. }
  860. //团组名称
  861. if (!string.IsNullOrEmpty(dto.TeamName))
  862. {
  863. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  864. }
  865. //客户名称
  866. if (!string.IsNullOrEmpty(dto.ClientName))
  867. {
  868. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  869. }
  870. //客户单位
  871. if (!string.IsNullOrEmpty(dto.ClientUnit))
  872. {
  873. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  874. }
  875. //出访时间
  876. if (!string.IsNullOrEmpty(dto.visitDataTime))
  877. {
  878. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  879. orderbyStr = "order by gdi.VisitDate";
  880. }
  881. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  882. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  883. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  884. JietuanOperator,IsSure,CreateTime
  885. From (
  886. Select row_number() over({0}) as Row_Number,
  887. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  888. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  889. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  890. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  891. From Grp_DelegationInfo gdi
  892. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  893. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  894. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  895. Where gdi.IsDel = 0 {1}
  896. ) temp ", orderbyStr, sqlWhere);
  897. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  898. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  899. #region 处理所属部门
  900. /*
  901. * 1.sq 和 gyy 等显示 市场部
  902. * 2.王鸽和主管及张总还有管理员号统一国交部
  903. * 2-1. 4 管理员 ,21 张海麟
  904. */
  905. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  906. var userIds1 = new List<int>() { 4, 21 };
  907. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  908. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  909. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  910. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  911. .ToList();
  912. foreach (var item in _DelegationList)
  913. {
  914. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  915. }
  916. #endregion
  917. var _view = new
  918. {
  919. PageFuncAuth = pageFunAuthView,
  920. Data = _DelegationList
  921. };
  922. return Ok(JsonView(true, "查询成功!", _view, total));
  923. }
  924. /// <summary>
  925. /// 接团信息详情
  926. /// </summary>
  927. /// <param name="dto">团组info请求dto</param>
  928. /// <returns></returns>
  929. [HttpPost]
  930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  931. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  932. {
  933. var groupData = await _groupRepository.GetGroupInfo(dto);
  934. if (groupData.Code != 0)
  935. {
  936. return Ok(JsonView(false, groupData.Msg));
  937. }
  938. return Ok(JsonView(groupData.Data));
  939. }
  940. /// <summary>
  941. /// 接团信息 编辑添加
  942. /// 基础信息数据源
  943. /// </summary>
  944. /// <param name="dto"></param>
  945. /// <returns></returns>
  946. [HttpPost]
  947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  948. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  949. {
  950. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  951. if (groupData.Code != 0)
  952. {
  953. return Ok(JsonView(false, groupData.Msg));
  954. }
  955. return Ok(JsonView(groupData.Data));
  956. }
  957. /// <summary>
  958. /// 成本修改团组信息
  959. /// </summary>
  960. /// <param name="dto"></param>
  961. /// <returns></returns>
  962. [HttpPost]
  963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  964. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  965. {
  966. var jw = JsonView(false, "操作失败");
  967. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  968. if (di == null)
  969. {
  970. jw.Msg = "参数有误!";
  971. return Ok(jw);
  972. }
  973. #region 添加出访起止时间
  974. var startTime = new DateTime();
  975. var endTime = new DateTime();
  976. if (DateTime.TryParse(dto.VisitDate, out startTime))
  977. {
  978. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  979. }
  980. else
  981. {
  982. jw.Msg = "参数有误!";
  983. return Ok(jw);
  984. }
  985. #endregion
  986. di.VisitDate = startTime;
  987. di.VisitPNumber = dto.VisitPNumber;
  988. di.VisitDays = dto.VisitDays;
  989. di.VisitStartDate = startTime;
  990. di.VisitEndDate = endTime;
  991. var count = _sqlSugar.Updateable(di)
  992. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  993. .ExecuteCommand();
  994. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  995. }
  996. /// <summary>
  997. /// 接团信息 编辑添加
  998. /// 省份-城市 基础信息数据源
  999. /// </summary>
  1000. /// <param name="dto"></param>
  1001. /// <returns></returns>
  1002. [HttpPost]
  1003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1004. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1005. {
  1006. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1007. string search = dto.Search;
  1008. var data = await _groupRepository.CityBasicSource();
  1009. int total = data.Length;
  1010. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1011. .Skip((pageIndex - 1) * pageSize)
  1012. .Take(pageSize)
  1013. .ToArray();
  1014. return Ok(JsonView(data, total));
  1015. }
  1016. /// <summary>
  1017. /// 接团信息 操作(增改)
  1018. /// </summary>
  1019. /// <param name="dto"></param>
  1020. /// <returns></returns>
  1021. [HttpPost]
  1022. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1023. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1024. {
  1025. // 创建 Stopwatch 实例
  1026. Stopwatch stopwatch = Stopwatch.StartNew();
  1027. decimal ffrPrice = 0.00M;
  1028. DateTime? visitDt = null;
  1029. if (dto.Status == 2)
  1030. {
  1031. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1032. if (groupInfo != null)
  1033. {
  1034. ffrPrice = groupInfo.PaymentMoney;
  1035. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1036. }
  1037. }
  1038. var groupData = await _groupRepository.GroupOperation(dto);
  1039. if (groupData.Code != 0)
  1040. {
  1041. return Ok(JsonView(false, groupData.Msg));
  1042. }
  1043. int diId = 0;
  1044. try
  1045. {
  1046. //添加时 默认加入团组汇率
  1047. if (dto.Status == 1) //添加
  1048. {
  1049. diId = groupData.Data;
  1050. //添加默认币种
  1051. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1052. //默认分配权限
  1053. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1054. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1055. var _managerIds = new List<int>() { 22, 32, 21 };
  1056. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1057. if (userIds.Count > 0)
  1058. {
  1059. userIds.Add(208);
  1060. //创建团组管控
  1061. GroupStepForDelegation.CreateWorkStep(diId);
  1062. //发送消息
  1063. string groupName = dto.TeamName;
  1064. string createGroupUser = string.Empty;
  1065. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1066. if (userInfo != null) createGroupUser = userInfo.CnName;
  1067. string title = $"系统通知";
  1068. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1069. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1070. }
  1071. //默认创建倒推表
  1072. await _invertedListRep._Create(dto.UserId, diId);
  1073. }
  1074. else if (dto.Status == 2)
  1075. {
  1076. diId = dto.Id;
  1077. }
  1078. #region 签证人员团组时间通知
  1079. #region 计算出访起止时间
  1080. var startTime = new DateTime();
  1081. var endTime = new DateTime();
  1082. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1083. {
  1084. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1085. }
  1086. #endregion
  1087. #endregion
  1088. #region 团组操作默认添加/修改收款账单
  1089. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1090. {
  1091. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1092. .Where(x => x.IsDel == 0 &&
  1093. x.Diid == diId &&
  1094. x.Remark.Equals("预付款")
  1095. )
  1096. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1097. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1098. .FirstAsync();
  1099. ffrInfo = new Fin_ForeignReceivables()
  1100. {
  1101. Diid = diId,
  1102. PriceName = dto.ClientUnit,
  1103. Price = dto.PaymentMoney,
  1104. Count = 1,
  1105. Unit = $"元",
  1106. ItemSumPrice = dto.PaymentMoney,
  1107. Rate = 1.0000M,
  1108. Currency = 836,
  1109. AddingWay = 0,
  1110. CreateUserId = dto.UserId,
  1111. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1112. Remark = $"预付款"
  1113. };
  1114. if (ffrInfo == null) //Add
  1115. {
  1116. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1117. }
  1118. else //修改
  1119. {
  1120. await _sqlSugar.Updateable(ffrInfo)
  1121. .UpdateColumns(x => new
  1122. {
  1123. x.PriceName,
  1124. x.Price,
  1125. x.ItemSumPrice,
  1126. x.CreateTime,
  1127. x.CreateUserId
  1128. })
  1129. .WhereColumns(x => x.Id)
  1130. .ExecuteCommandAsync();
  1131. }
  1132. }
  1133. #endregion
  1134. if (diId > 0)
  1135. {
  1136. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1137. }
  1138. // 停止计时
  1139. stopwatch.Stop();
  1140. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1141. }
  1142. catch (Exception ex)
  1143. {
  1144. // 停止计时
  1145. stopwatch.Stop();
  1146. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1147. Logs(ex.Message);
  1148. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1149. }
  1150. // 停止计时
  1151. stopwatch.Stop();
  1152. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1153. }
  1154. /// <summary>
  1155. /// 接团流程操作(增改)
  1156. /// 安卓端使用 建团时添加客户名单
  1157. /// </summary>
  1158. /// <param name="dto"></param>
  1159. /// <returns></returns>
  1160. [HttpPost]
  1161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1162. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1163. {
  1164. #region 参数验证
  1165. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1166. #region 页面操作权限验证
  1167. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1168. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1169. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1170. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1171. #endregion
  1172. #endregion
  1173. try
  1174. {
  1175. //_sqlSugar.BeginTran();
  1176. decimal ffrPrice = 0.00M;
  1177. DateTime? visitDt = null;
  1178. if (dto.Status == 2)
  1179. {
  1180. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1181. if (groupInfo != null)
  1182. {
  1183. ffrPrice = groupInfo.PaymentMoney;
  1184. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1185. }
  1186. }
  1187. var _dto = new GroupOperationDto();
  1188. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1189. var groupData = await _groupRepository.GroupOperation(_dto);
  1190. if (groupData.Code != 0)
  1191. {
  1192. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1193. }
  1194. int diId = 0;
  1195. //添加时 默认加入团组汇率
  1196. if (dto.Status == 1) //添加
  1197. {
  1198. diId = groupData.Data;
  1199. //添加默认币种
  1200. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1201. //默认分配权限
  1202. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1203. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1204. var _managerIds = new List<int>() { 21, 22, 32 };
  1205. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1206. if (userIds.Count > 0)
  1207. {
  1208. userIds.Add(208);
  1209. //创建团组管控
  1210. GroupStepForDelegation.CreateWorkStep(diId);
  1211. //发送消息
  1212. string groupName = dto.TeamName;
  1213. string createGroupUser = string.Empty;
  1214. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1215. if (userInfo != null) createGroupUser = userInfo.CnName;
  1216. string title = $"系统通知";
  1217. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1218. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1219. }
  1220. #region 应用推送
  1221. try
  1222. {
  1223. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1224. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1225. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1226. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1227. {
  1228. var userList = new List<string>() { users.QiyeChatUserId };
  1229. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1230. }
  1231. }
  1232. catch (Exception ex)
  1233. {
  1234. }
  1235. #endregion
  1236. //默认创建倒推表
  1237. await _invertedListRep._Create(dto.UserId, diId);
  1238. }
  1239. if (dto.Status == 2)
  1240. {
  1241. diId = dto.Id;
  1242. if (diId == 0)
  1243. {
  1244. //_sqlSugar.RollbackTran();
  1245. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1246. }
  1247. }
  1248. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1249. if (viewData.Code != 0)
  1250. {
  1251. //_sqlSugar.RollbackTran();
  1252. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1253. }
  1254. #region 团组操作默认添加/修改收款账单
  1255. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1256. {
  1257. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1258. .Where(x => x.IsDel == 0 &&
  1259. x.Diid == diId &&
  1260. x.Remark.Equals("预付款")
  1261. )
  1262. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1263. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1264. .FirstAsync();
  1265. ffrInfo = new Fin_ForeignReceivables()
  1266. {
  1267. Diid = diId,
  1268. PriceName = dto.ClientUnit,
  1269. Price = dto.PaymentMoney,
  1270. Count = 1,
  1271. Unit = $"元",
  1272. ItemSumPrice = dto.PaymentMoney,
  1273. Rate = 1.0000M,
  1274. Currency = 836,
  1275. AddingWay = 0,
  1276. CreateUserId = dto.UserId,
  1277. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1278. Remark = $"预付款"
  1279. };
  1280. if (ffrInfo == null) //Add
  1281. {
  1282. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1283. }
  1284. else //修改
  1285. {
  1286. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1287. .UpdateColumns(x => new
  1288. {
  1289. x.PriceName,
  1290. x.Price,
  1291. x.ItemSumPrice,
  1292. x.CreateTime,
  1293. x.CreateUserId
  1294. })
  1295. .WhereColumns(x => x.Id)
  1296. .ExecuteCommandAsync();
  1297. }
  1298. }
  1299. #endregion
  1300. #region 签证人员团组时间通知
  1301. #region 计算出访起止时间
  1302. var startTime = new DateTime();
  1303. var endTime = new DateTime();
  1304. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1305. {
  1306. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1307. }
  1308. #endregion
  1309. if (diId > 0)
  1310. {
  1311. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1312. }
  1313. #endregion
  1314. //_sqlSugar.CommitTran();
  1315. return Ok(JsonView(true, "添加成功"));
  1316. }
  1317. catch (Exception ex)
  1318. {
  1319. _sqlSugar.RollbackTran();
  1320. return Ok(JsonView(false, ex.Message));
  1321. }
  1322. }
  1323. /// <summary>
  1324. /// 接团流程操作(增改)
  1325. /// 安卓端使用 建团时添加客户名单
  1326. /// </summary>
  1327. /// <param name="dto"></param>
  1328. /// <returns></returns>
  1329. [HttpPost]
  1330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1331. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1332. {
  1333. #region 参数验证
  1334. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1335. #region 页面操作权限验证
  1336. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1337. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1338. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1339. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1340. #endregion
  1341. #endregion
  1342. _sqlSugar.BeginTran();
  1343. decimal ffrPrice = 0.00M;
  1344. DateTime? visitDt = null;
  1345. if (dto.Status == 2)
  1346. {
  1347. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1348. if (groupInfo != null)
  1349. {
  1350. ffrPrice = groupInfo.PaymentMoney;
  1351. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1352. }
  1353. }
  1354. var _dto = new GroupOperationDto();
  1355. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1356. var groupData = await _groupRepository.GroupOperation(_dto);
  1357. if (groupData.Code != 0)
  1358. {
  1359. _sqlSugar.RollbackTran();
  1360. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1361. }
  1362. try
  1363. {
  1364. int diId = 0;
  1365. //添加时 默认加入团组汇率
  1366. if (dto.Status == 1) //添加
  1367. {
  1368. diId = groupData.Data;
  1369. //添加默认币种
  1370. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1371. //默认分配权限
  1372. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1373. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1374. var _managerIds = new List<int>() { 21, 22, 32 };
  1375. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1376. if (userIds.Count > 0)
  1377. {
  1378. userIds.Add(208);
  1379. //创建团组管控
  1380. GroupStepForDelegation.CreateWorkStep(diId);
  1381. //发送消息
  1382. string groupName = dto.TeamName;
  1383. string createGroupUser = string.Empty;
  1384. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1385. if (userInfo != null) createGroupUser = userInfo.CnName;
  1386. string title = $"系统通知";
  1387. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1388. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1389. }
  1390. #region 应用推送
  1391. try
  1392. {
  1393. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1394. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1395. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1396. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1397. {
  1398. var userList = new List<string>() { users.QiyeChatUserId };
  1399. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1400. }
  1401. }
  1402. catch (Exception ex)
  1403. {
  1404. _sqlSugar.CommitTran();
  1405. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1406. }
  1407. #endregion
  1408. //默认创建倒推表
  1409. await _invertedListRep._Create(dto.UserId, diId);
  1410. }
  1411. else if (dto.Status == 2)
  1412. {
  1413. diId = dto.Id;
  1414. if (diId == 0)
  1415. {
  1416. _sqlSugar.RollbackTran();
  1417. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1418. }
  1419. }
  1420. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1421. if (viewData.Code != 0)
  1422. {
  1423. _sqlSugar.RollbackTran();
  1424. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1425. }
  1426. #region 团组操作默认添加/修改收款账单
  1427. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1428. {
  1429. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1430. .Where(x => x.IsDel == 0 &&
  1431. x.Diid == diId &&
  1432. x.Remark.Equals("预付款")
  1433. )
  1434. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1435. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1436. .FirstAsync();
  1437. ffrInfo = new Fin_ForeignReceivables()
  1438. {
  1439. Diid = diId,
  1440. PriceName = dto.ClientUnit,
  1441. Price = dto.PaymentMoney,
  1442. Count = 1,
  1443. Unit = $"元",
  1444. ItemSumPrice = dto.PaymentMoney,
  1445. Rate = 1.0000M,
  1446. Currency = 836,
  1447. AddingWay = 0,
  1448. CreateUserId = dto.UserId,
  1449. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1450. Remark = $"预付款"
  1451. };
  1452. if (ffrInfo == null) //Add
  1453. {
  1454. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1455. }
  1456. else //修改
  1457. {
  1458. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1459. .UpdateColumns(x => new
  1460. {
  1461. x.PriceName,
  1462. x.Price,
  1463. x.ItemSumPrice,
  1464. x.CreateTime,
  1465. x.CreateUserId
  1466. })
  1467. .WhereColumns(x => x.Id)
  1468. .ExecuteCommandAsync();
  1469. }
  1470. }
  1471. #endregion
  1472. #region 签证人员团组时间通知
  1473. #region 计算出访起止时间
  1474. var startTime = new DateTime();
  1475. var endTime = new DateTime();
  1476. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1477. {
  1478. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1479. }
  1480. #endregion
  1481. if (diId > 0)
  1482. {
  1483. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1484. }
  1485. #endregion
  1486. _sqlSugar.CommitTran();
  1487. return Ok(JsonView(true));
  1488. }
  1489. catch (Exception ex)
  1490. {
  1491. _sqlSugar.RollbackTran();
  1492. return Ok(JsonView(false, ex.Message));
  1493. }
  1494. }
  1495. /// <summary>
  1496. /// 接团信息 操作(删除)
  1497. /// </summary>
  1498. /// <param name="dto"></param>
  1499. /// <returns></returns>
  1500. [HttpPost]
  1501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1502. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1503. {
  1504. var diId = dto.Id;
  1505. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1506. #region 删除 验证
  1507. /*
  1508. * 1、收款账单数据:0 条
  1509. * 2、收款退还数据:0 条
  1510. * 3、机票费用数据:0 条
  1511. * 4、签证费用数据:0 条
  1512. * 5、保险费用数据:0 条
  1513. * 6、酒店费用数据:0 条
  1514. * 7、公务出访数据:1 条
  1515. * 8、邀请公务活动费用数据:1 条
  1516. * 9、OP费用数据:5 条
  1517. * 10、其他费用数据:0 条
  1518. * 11、团组日付报销费用数据:0 条
  1519. *
  1520. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1521. */
  1522. //收款账单
  1523. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1524. //收款退还
  1525. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1526. //机票费用
  1527. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1528. //签证费用
  1529. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1530. //保险费用
  1531. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1532. //酒店费用
  1533. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1534. //公务出访
  1535. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1536. //邀请公务活动费用
  1537. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1538. //OP费用
  1539. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1540. //其他费用
  1541. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1542. //团组日付报销费用
  1543. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1544. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1545. if (feeCount > 0)
  1546. {
  1547. var delMsgTips = new StringBuilder();
  1548. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1549. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1550. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1551. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1552. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1553. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1554. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1555. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1556. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1557. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1558. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1559. delMsgTips.AppendLine($"");
  1560. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1561. return Ok(JsonView(false, delMsgTips.ToString()));
  1562. }
  1563. #endregion
  1564. var groupData = await _groupRepository.GroupDel(dto);
  1565. if (groupData.Code != 0)
  1566. {
  1567. return Ok(JsonView(false, groupData.Msg));
  1568. }
  1569. return Ok(JsonView(true));
  1570. }
  1571. /// <summary>
  1572. /// 获取团组销售报价号
  1573. /// 团组添加时 使用
  1574. /// </summary>
  1575. /// <returns></returns>
  1576. [HttpPost]
  1577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1578. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1579. {
  1580. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1581. if (groupData.Code != 0)
  1582. {
  1583. return Ok(JsonView(false, groupData.Msg));
  1584. }
  1585. object salesQuoteNo = new
  1586. {
  1587. SalesQuoteNo = groupData.Data
  1588. };
  1589. return Ok(JsonView(salesQuoteNo));
  1590. }
  1591. /// <summary>
  1592. /// 设置确认出团
  1593. /// </summary>
  1594. /// <param name="dto"></param>
  1595. /// <returns></returns>
  1596. [HttpPost]
  1597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1598. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1599. {
  1600. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1601. if (groupData.Code != 0)
  1602. {
  1603. return Ok(JsonView(false, groupData.Msg));
  1604. }
  1605. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1606. #region OA消息推送
  1607. try
  1608. {
  1609. string groupName = groupInfo.TeamName;
  1610. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1611. string title = $"系统通知";
  1612. string content = $"团组[{groupName}]已确认出团!";
  1613. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1614. }
  1615. catch (Exception ex)
  1616. {
  1617. }
  1618. #endregion
  1619. #region 应用推送
  1620. try
  1621. {
  1622. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1623. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1624. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1625. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1626. {
  1627. var userList = new List<string>() { users.QiyeChatUserId };
  1628. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1629. }
  1630. }
  1631. catch (Exception ex)
  1632. {
  1633. }
  1634. #endregion
  1635. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1636. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1637. }
  1638. /// <summary>
  1639. /// 获取团组名称data And 签证国别Data
  1640. /// </summary>
  1641. /// <param name="dto"></param>
  1642. /// <returns></returns>
  1643. [HttpPost]
  1644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1645. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1646. {
  1647. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1648. if (groupData.Code != 0)
  1649. {
  1650. return Ok(JsonView(false, groupData.Msg));
  1651. }
  1652. return Ok(JsonView(groupData.Data));
  1653. }
  1654. /// <summary>
  1655. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1656. /// </summary>
  1657. /// <returns></returns>
  1658. [HttpPost]
  1659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1660. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1661. {
  1662. try
  1663. {
  1664. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1665. if (groupData.Code != 0)
  1666. {
  1667. return Ok(JsonView(false, groupData.Msg));
  1668. }
  1669. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1670. }
  1671. catch (Exception ex)
  1672. {
  1673. return Ok(JsonView(false, ex.Message));
  1674. throw;
  1675. }
  1676. }
  1677. /// <summary>
  1678. /// 团组清单 Excel
  1679. /// </summary>
  1680. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1681. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1682. /// <returns></returns>
  1683. [HttpGet]
  1684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1685. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1686. {
  1687. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1688. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1689. if (!beginBool && !endBool)
  1690. {
  1691. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1692. }
  1693. string sql = string.Format(@"
  1694. SELECT
  1695. ROW_NUMBER,
  1696. Id,
  1697. SalesQuoteNo,
  1698. TourCode,
  1699. TeamTypeId,
  1700. TeamType,
  1701. TeamLevId,
  1702. TeamLev,
  1703. TeamName,
  1704. ClientName,
  1705. ClientUnit,
  1706. VisitDate,
  1707. VisitDays,
  1708. VisitPNumber,
  1709. JietuanOperatorId,
  1710. JietuanOperator,
  1711. IsSure,
  1712. CreateUserName,
  1713. IsBid
  1714. FROM
  1715. (
  1716. SELECT
  1717. ROW_NUMBER() OVER(
  1718. ORDER BY
  1719. gdi.VisitDate Desc
  1720. ) AS ROW_NUMBER,
  1721. gdi.Id,
  1722. SalesQuoteNo,
  1723. TourCode,
  1724. ssd.Id TeamTypeId,
  1725. ssd.Name TeamType,
  1726. ssd1.Id TeamLevId,
  1727. ssd1.Name TeamLev,
  1728. TeamName,
  1729. ClientName,
  1730. ClientUnit,
  1731. VisitDate,
  1732. VisitDays,
  1733. VisitPNumber,
  1734. JietuanOperator JietuanOperatorId,
  1735. su.CnName JietuanOperator,
  1736. IsSure,
  1737. gdi.CreateTime,
  1738. su1.CnName As CreateUserName,
  1739. gdi.IsBid
  1740. FROM
  1741. Grp_DelegationInfo gdi
  1742. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1743. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1744. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1745. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1746. WHERE
  1747. gdi.IsDel = 0
  1748. AND gdi.IsBid = 0
  1749. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1750. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1751. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1752. #region 处理所属部门
  1753. /*
  1754. * 1.sq 和 gyy 等显示 市场部
  1755. * 2.王鸽和主管及张总还有管理员号统一国交部
  1756. * 2-1. 4 管理员 ,21 张海麟
  1757. */
  1758. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1759. var userIds1 = new List<int>() { 4, 21 };
  1760. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1761. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1762. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1763. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1764. .ToListAsync();
  1765. var droupIds = groupList.Select(it => it.Id).ToList();
  1766. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1767. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1768. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1769. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1770. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1771. {
  1772. DiId = tcl.DiId,
  1773. LastName = dc.LastName,
  1774. FirstName = dc.FirstName,
  1775. Sex = dc.Sex,
  1776. Birthday = dc.BirthDay,
  1777. Company = cc.CompanyFullName,
  1778. Job = dc.Job,
  1779. CreateTime = tcl.CreateTime,
  1780. })
  1781. .ToList();
  1782. foreach (var item in groupList)
  1783. {
  1784. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1785. string groupFirstName = "";
  1786. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1787. if (currDatas.Any())
  1788. {
  1789. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1790. }
  1791. item.GroupFirst = groupFirstName;
  1792. }
  1793. #endregion
  1794. #region Excel
  1795. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1796. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1797. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1798. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1799. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1800. //载入模板
  1801. var designer = new WorkbookDesigner
  1802. {
  1803. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1804. };
  1805. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1806. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1807. dt.TableName = "GroupList";
  1808. designer.SetDataSource(dt);
  1809. designer.Process();
  1810. if (!Directory.Exists(savePath))
  1811. {
  1812. Directory.CreateDirectory(savePath);
  1813. }
  1814. string serverPath = $"{savePath}{fileName}";
  1815. designer.Workbook.Save(serverPath);
  1816. string rst = $"{servicePath}{ftpPath}{fileName}";
  1817. #endregion
  1818. return Ok(JsonView(true, "操作成功!", rst));
  1819. }
  1820. /// <summary>
  1821. /// 团组合同下载(1.付款80% 2.付全款)
  1822. /// </summary>
  1823. /// <param name="dto"></param>
  1824. /// <returns></returns>
  1825. /// <exception cref="Exception"></exception>
  1826. [HttpPost]
  1827. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1828. {
  1829. var jw = JsonView(false);
  1830. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1831. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1832. if (di == null)
  1833. {
  1834. jw.Msg = "团组Id有误!";
  1835. return Ok(jw);
  1836. }
  1837. #region 权限校验
  1838. var allDownFile = new List<int>() { 21 };
  1839. try
  1840. {
  1841. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1842. .First(x => x.Id == 1418 && x.IsDel == 0);
  1843. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1844. }
  1845. catch (Exception)
  1846. { }
  1847. var guojiaoDownFile = new List<int>() { 330 };
  1848. var shichangDownFile = new List<int>() { 95 };
  1849. if (allDownFile.Contains(dto.UserId))
  1850. {
  1851. }
  1852. else if (guojiaoDownFile.Contains(dto.UserId))
  1853. {
  1854. var guojiaobuDi = new List<int>() { 4, 21 };
  1855. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1856. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1857. .Where((d, u) => u.Id == di.JietuanOperator)
  1858. .Select((d, u) => d.DepName)
  1859. .First();
  1860. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1861. {
  1862. jw.Msg = "暂无下载权限!";
  1863. return Ok(jw);
  1864. }
  1865. }
  1866. else if (shichangDownFile.Contains(dto.UserId))
  1867. {
  1868. var dic = new Dictionary<int, int[]>()
  1869. {
  1870. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1871. };
  1872. try
  1873. {
  1874. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1875. if (sqSetting != null)
  1876. {
  1877. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1878. foreach (var item in result.Keys)
  1879. {
  1880. if (dic.ContainsKey(item))
  1881. {
  1882. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1883. Array.Copy(dic[item], dilatation, dic[item].Length);
  1884. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1885. dic[item] = dilatation;
  1886. }
  1887. else
  1888. {
  1889. dic.Add(item, result[item]);
  1890. }
  1891. }
  1892. }
  1893. if (!dic[95].Contains(di.CreateUserId))
  1894. {
  1895. jw.Msg = "暂无下载权限!";
  1896. return Ok(jw);
  1897. }
  1898. }
  1899. catch (Exception)
  1900. { }
  1901. }
  1902. else if (dto.UserId == di.CreateUserId)
  1903. {
  1904. }
  1905. else
  1906. {
  1907. jw.Msg = "暂无下载权限!";
  1908. return Ok(jw);
  1909. }
  1910. #endregion
  1911. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1912. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1913. .ToListAsync();
  1914. if (!blackCodeList.Any())
  1915. {
  1916. jw.Msg = "该团无机票行程代码!";
  1917. return Ok(jw);
  1918. }
  1919. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1920. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1921. if (groupEnterExitCost == null)
  1922. {
  1923. jw.Msg = "暂无三公费用信息!";
  1924. return Ok(jw);
  1925. }
  1926. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1927. rateList ??= new List<CurrencyInfo>();
  1928. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1929. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1930. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1931. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1932. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1933. .Select((x, a, b) => new
  1934. {
  1935. x.Index,
  1936. itemName = a.Name,
  1937. CurrencyStr = b.Name,
  1938. x.Cost,
  1939. x.SubTotal,
  1940. x.Remark
  1941. })
  1942. .OrderBy((x) => x.Index)
  1943. .ToList();
  1944. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1945. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1946. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1947. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1948. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1949. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1950. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1951. decimal subJJC = 0.00M,
  1952. subGWC = 0.00M,
  1953. subTDC = 0.00M;
  1954. //经济舱
  1955. if (groupEnterExitCost.SumJJC == 1)
  1956. {
  1957. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1958. }
  1959. //公务舱
  1960. if (groupEnterExitCost.SumGWC == 1)
  1961. {
  1962. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1963. }
  1964. //头等舱
  1965. if (groupEnterExitCost.SumTDC == 1)
  1966. {
  1967. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1968. }
  1969. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1970. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1971. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1972. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1973. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1974. .Select((x, s, dc, cc) => new groupClints
  1975. {
  1976. Id = x.Id,
  1977. Name = s.Name,
  1978. IsAccompany = x.IsAccompany,
  1979. CompanyFullName = cc.CompanyFullName
  1980. })
  1981. .ToListAsync();
  1982. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1983. //获取舱位人数
  1984. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1985. .GroupBy(x => x.Name)
  1986. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1987. .ToList();
  1988. string cityPath = string.Empty;
  1989. string startCity = string.Empty;
  1990. string endCity = string.Empty;
  1991. foreach (var item in blackCodeList)
  1992. {
  1993. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1994. cityPath += city + "\r\n";
  1995. if (item.Equals(blackCodeList.First()))
  1996. {
  1997. var sp = city.Split('-');
  1998. startCity = sp[0];
  1999. endCity = sp[^1];
  2000. }
  2001. }
  2002. var bookMarkDic = new Dictionary<string, string>
  2003. {
  2004. { "ClientUnit", di.ClientUnit },
  2005. { "VisitCountry", di.VisitCountry },
  2006. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2007. { "VisitPNumber", di.VisitPNumber.ToString() },
  2008. { "CityPath", cityPath },
  2009. { "StartCity", startCity },
  2010. { "EndCity", endCity },
  2011. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2012. };
  2013. Document doc = null;
  2014. var percentage = 0.8M;
  2015. var fileNameadd = "预付";
  2016. if (dto.FileType == 1)
  2017. {
  2018. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2019. }
  2020. else if (dto.FileType == 2)
  2021. {
  2022. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2023. percentage = 1;
  2024. fileNameadd = "全款";
  2025. }
  2026. else
  2027. {
  2028. throw new Exception("FileType有误!");
  2029. }
  2030. var builder = new DocumentBuilder(doc);
  2031. decimal totalPrice = 0.00M;
  2032. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2033. if (firstTable != null)
  2034. {
  2035. // 遍历表格的行和单元格
  2036. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2037. {
  2038. for (int i = 0; i < row.Cells.Count; i++)
  2039. {
  2040. var cell = row.Cells[i];
  2041. // 读取单元格内容
  2042. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2043. if (cellTextFirst.Contains("舱位"))
  2044. {
  2045. break;
  2046. }
  2047. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2048. {
  2049. if (i == 2)
  2050. {
  2051. if (cellTextFirst == "经济舱")
  2052. {
  2053. // 设置单元格内容
  2054. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2055. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2056. }
  2057. else
  2058. {
  2059. // 设置单元格内容
  2060. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2061. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2062. }
  2063. }
  2064. if (i == 3)
  2065. {
  2066. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2067. if (count != null)
  2068. {
  2069. // 设置单元格内容
  2070. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2071. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2072. }
  2073. }
  2074. if (i == 4)
  2075. {
  2076. var rowPrice = 0.00M;
  2077. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2078. count ??= 0;
  2079. if (cellTextFirst == "经济舱")
  2080. {
  2081. rowPrice = subJJC * (int)count;
  2082. }
  2083. else
  2084. {
  2085. rowPrice = subGWC * (int)count;
  2086. }
  2087. totalPrice += rowPrice;
  2088. // 设置单元格内容
  2089. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2090. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2091. }
  2092. }
  2093. }
  2094. }
  2095. }
  2096. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2097. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2098. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2099. //--合同表格部分
  2100. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2101. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2102. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2103. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2104. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2105. bookMarkDic.Add("CityPath1", cityPath);
  2106. bookMarkDic.Add("CityPath2", cityPath);
  2107. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2108. if (contractTable != null)
  2109. {
  2110. //数据源
  2111. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2112. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2113. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2114. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2115. .Select((it, y, s) => new
  2116. {
  2117. it.Cost,
  2118. it.SubTotal,
  2119. it.Type,
  2120. y.Id,
  2121. y.City,
  2122. s.Name,
  2123. CurrencyCodeCn = s.Remark
  2124. })
  2125. .ToList()
  2126. .Select(x => new
  2127. {
  2128. CurrencyCode = x.Name,
  2129. CityId = x.Id,
  2130. x.City,
  2131. di.VisitPNumber,
  2132. x.Type,
  2133. x.Cost,
  2134. x.SubTotal,
  2135. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2136. x.CurrencyCodeCn,
  2137. });
  2138. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2139. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2140. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2141. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2142. var tableSettings = new List<tableSetting>()
  2143. {
  2144. new(){ Index = 1 , Property = "City"},
  2145. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2146. new(){ Index = 3 , Property = "Cost"},
  2147. new(){ Index = 4 , Property = "VisitPNumber"},
  2148. //new tableSetting{ Index = 5 , Property = ""},
  2149. //new tableSetting{ Index = 6 , Property = ""},
  2150. new(){ Index = 7 , Property = "Rate"},
  2151. //new tableSetting{ Index = 8 , Property = ""},
  2152. };
  2153. //1.住宿费
  2154. int cloneRow = 8;
  2155. int startDayPrice = 8; //写入index
  2156. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2157. foreach (var dac in dac1)
  2158. {
  2159. var first = dac.First();
  2160. var dayCount = dac.Count();
  2161. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2162. for (int i = 1; i < row.Cells.Count; i++)
  2163. {
  2164. var cell = row.Cells[i];
  2165. var findProperty = tableSettings.Find(x => x.Index == i);
  2166. if (findProperty != null)
  2167. {
  2168. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2169. // 设置单元格内容
  2170. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2171. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2172. }
  2173. else
  2174. {
  2175. switch (i)
  2176. {
  2177. case 5:
  2178. cell.FirstParagraph.Runs.Clear();
  2179. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2180. break;
  2181. case 6:
  2182. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2183. cell.FirstParagraph.Runs.Clear();
  2184. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2185. break;
  2186. case 8:
  2187. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2188. cell.FirstParagraph.Runs.Clear();
  2189. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2190. ZSPriceSum += xiaojiRMB;
  2191. break;
  2192. default:
  2193. break;
  2194. }
  2195. }
  2196. }
  2197. startDayPrice++;
  2198. if (!dac1.Last().Equals(dac))
  2199. {
  2200. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2201. // 将克隆的行追加到原行后面
  2202. contractTable.Rows.Insert(startDayPrice, newRow);
  2203. }
  2204. else
  2205. {
  2206. cloneRow += dac1.Count + 1;
  2207. startDayPrice = cloneRow;
  2208. }
  2209. }
  2210. //2.伙食费
  2211. foreach (var dac in dac2)
  2212. {
  2213. var first = dac.First();
  2214. var dayCount = dac.Count();
  2215. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2216. for (int i = 1; i < row.Cells.Count; i++)
  2217. {
  2218. var cell = row.Cells[i];
  2219. var findProperty = tableSettings.Find(x => x.Index == i);
  2220. if (findProperty != null)
  2221. {
  2222. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2223. // 设置单元格内容
  2224. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2225. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2226. }
  2227. else
  2228. {
  2229. switch (i)
  2230. {
  2231. case 5:
  2232. cell.FirstParagraph.Runs.Clear();
  2233. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2234. break;
  2235. case 6:
  2236. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2237. cell.FirstParagraph.Runs.Clear();
  2238. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2239. break;
  2240. case 8:
  2241. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2242. cell.FirstParagraph.Runs.Clear();
  2243. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2244. HSPriceSum += xiaojiRMB;
  2245. break;
  2246. default:
  2247. break;
  2248. }
  2249. }
  2250. }
  2251. startDayPrice++;
  2252. if (!dac2.Last().Equals(dac))
  2253. {
  2254. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2255. // 将克隆的行追加到原行后面
  2256. contractTable.Rows.Insert(startDayPrice, newRow);
  2257. }
  2258. else
  2259. {
  2260. cloneRow += dac2.Count + 1;
  2261. startDayPrice = cloneRow;
  2262. }
  2263. }
  2264. //3.公杂费
  2265. foreach (var dac in dac3)
  2266. {
  2267. var first = dac.First();
  2268. var dayCount = dac.Count();
  2269. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2270. for (int i = 1; i < row.Cells.Count; i++)
  2271. {
  2272. var cell = row.Cells[i];
  2273. var findProperty = tableSettings.Find(x => x.Index == i);
  2274. if (findProperty != null)
  2275. {
  2276. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2277. // 设置单元格内容
  2278. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2279. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2280. }
  2281. else
  2282. {
  2283. switch (i)
  2284. {
  2285. case 5:
  2286. cell.FirstParagraph.Runs.Clear();
  2287. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2288. break;
  2289. case 6:
  2290. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2291. cell.FirstParagraph.Runs.Clear();
  2292. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2293. break;
  2294. case 8:
  2295. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2296. cell.FirstParagraph.Runs.Clear();
  2297. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2298. GZPriceSum += xiaojiRMB;
  2299. break;
  2300. default:
  2301. break;
  2302. }
  2303. }
  2304. }
  2305. startDayPrice++;
  2306. if (!dac3.Last().Equals(dac))
  2307. {
  2308. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2309. // 将克隆的行追加到原行后面
  2310. contractTable.Rows.Insert(startDayPrice, newRow);
  2311. }
  2312. else
  2313. {
  2314. cloneRow += dac3.Count + 1;
  2315. startDayPrice = cloneRow;
  2316. }
  2317. }
  2318. //合并单元格
  2319. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2320. {
  2321. var currentRow = contractTable.Rows[i];
  2322. var nextRow = contractTable.Rows[i + 1];
  2323. // 获取当前行和下一行的第一个单元格
  2324. Cell currentCell = currentRow.Cells[0];
  2325. Cell nextCell = nextRow.Cells[0];
  2326. // 检查单元格内容是否一致(去除尾部的换行符)
  2327. string currentText = currentCell.GetText().Trim();
  2328. string nextText = nextCell.GetText().Trim();
  2329. if (currentText == nextText)
  2330. {
  2331. // 如果当前单元格已经被合并,找到合并的起始单元格
  2332. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2333. {
  2334. // 找到合并的起始单元格
  2335. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2336. // 将下一行的单元格设置为合并的后续单元格
  2337. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2338. }
  2339. else
  2340. {
  2341. // 如果当前单元格是合并的起始单元格
  2342. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2343. // 将下一行的单元格设置为合并的后续单元格
  2344. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2345. }
  2346. }
  2347. else
  2348. {
  2349. // 如果内容不一致,重置当前单元格的合并属性
  2350. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2351. {
  2352. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2353. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2354. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2355. }
  2356. else
  2357. {
  2358. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2359. }
  2360. }
  2361. }
  2362. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2363. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2364. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2365. }
  2366. foreach (var bookmarkName in bookMarkDic.Keys)
  2367. {
  2368. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2369. if (bookmark != null)
  2370. {
  2371. if (bookmarkName == "ClientUnit")
  2372. {
  2373. // 移动到书签位置
  2374. builder.MoveTo(bookmark.BookmarkStart);
  2375. // 设置字体样式为下划线
  2376. builder.Font.Underline = Aspose.Words.Underline.Single;
  2377. // 插入书签值
  2378. builder.Write(bookMarkDic[bookmarkName]);
  2379. // 清除字体格式,避免影响后续文本
  2380. builder.Font.ClearFormatting();
  2381. }
  2382. else
  2383. {
  2384. builder.MoveToBookmark(bookmarkName);
  2385. builder.Write(bookMarkDic[bookmarkName]);
  2386. }
  2387. }
  2388. }
  2389. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2390. doc.Save(savePaht);
  2391. jw.Msg = "生成成功!";
  2392. jw.Code = 200;
  2393. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2394. return Ok(jw);
  2395. }
  2396. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2397. {
  2398. int index = rowIndex;
  2399. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2400. {
  2401. index--;
  2402. }
  2403. return index;
  2404. }
  2405. #endregion
  2406. #region 团组&签证
  2407. /// <summary>
  2408. /// 根据团组Id获取签证客户信息List
  2409. /// </summary>
  2410. /// <param name="dto">请求dto</param>
  2411. /// <returns></returns>
  2412. [HttpPost]
  2413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2414. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2415. {
  2416. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2417. if (groupData.Code != 0)
  2418. {
  2419. return Ok(JsonView(false, groupData.Msg));
  2420. }
  2421. return Ok(JsonView(groupData.Data));
  2422. }
  2423. /// <summary>
  2424. /// IOS获取团组签证拍照上传进度01(团组列表)
  2425. /// </summary>
  2426. /// <param name="dto">请求dto</param>
  2427. /// <returns></returns>
  2428. [HttpPost]
  2429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2430. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2431. {
  2432. if (dto == null)
  2433. {
  2434. return Ok(JsonView(false, "参数为空"));
  2435. }
  2436. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2437. return Ok(JsonView(visaList));
  2438. }
  2439. /// <summary>
  2440. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2441. /// </summary>
  2442. /// <returns></returns>
  2443. [HttpPost]
  2444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2445. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2446. {
  2447. if (dto == null)
  2448. {
  2449. return Ok(JsonView(false, "请求错误:"));
  2450. }
  2451. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2452. return Ok(JsonView(list));
  2453. }
  2454. /// <summary>
  2455. /// IOS获取团组签证拍照上传进度03(相册)
  2456. /// </summary>
  2457. /// <returns></returns>
  2458. [HttpPost]
  2459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2460. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2461. {
  2462. if (dto == null)
  2463. {
  2464. return Ok(JsonView(false, "请求错误:"));
  2465. }
  2466. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2467. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2468. list.ForEach(s => s.url = url);
  2469. return Ok(JsonView(list));
  2470. }
  2471. /// <summary>
  2472. /// IOS获取团组签证拍照上传进度04(图片上传)
  2473. /// </summary>
  2474. /// <param name="dto"></param>
  2475. /// <returns></returns>
  2476. [HttpPost]
  2477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2478. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2479. {
  2480. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2481. //if (!string.IsNullOrEmpty(result))
  2482. //{
  2483. //}
  2484. //else {
  2485. // return Ok(JsonView(false, "上传失败"));
  2486. //}
  2487. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2488. int sucNum = 0;
  2489. try
  2490. {
  2491. foreach (var item in dto.base64DataList)
  2492. {
  2493. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2494. string result = DecodeBase64ToImage(item, imageName);
  2495. if (!string.IsNullOrEmpty(result))
  2496. {
  2497. var pic = new Grp_VisaProgressCustomerPicture
  2498. {
  2499. CreateUserId = dto.CreateUserId,
  2500. PicName = imageName,
  2501. PicPath = result,
  2502. VisaProgressCustomerId = dto.visaProgressCustomerId
  2503. };
  2504. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2505. if (insertResult > 0)
  2506. {
  2507. sucNum++;
  2508. }
  2509. }
  2510. }
  2511. }
  2512. catch (Exception ex)
  2513. {
  2514. return Ok(JsonView(false, ex.Message));
  2515. }
  2516. string msg = string.Format(@"成功上传{0}张", sucNum);
  2517. return Ok(JsonView(true, msg));
  2518. }
  2519. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2520. {
  2521. string filename = "";//声明一个string类型的相对路径
  2522. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2523. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2524. try//会有异常抛出,try,catch一下
  2525. {
  2526. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2527. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2528. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2529. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2530. //文件名称
  2531. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2532. //上传的文件的路径
  2533. string filePath = "";
  2534. if (!Directory.Exists(fileDir))
  2535. {
  2536. Directory.CreateDirectory(fileDir);
  2537. }
  2538. //上传的文件的路径
  2539. filePath = fileDir + filename;
  2540. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2541. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2542. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2543. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2544. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2545. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2546. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2547. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2548. bitmap.Dispose();
  2549. }
  2550. catch (Exception e)
  2551. {
  2552. string massage = e.Message;
  2553. Logs("IOS图片上传Error:" + massage);
  2554. //filename = e.Message;
  2555. }
  2556. return filename;//返回相对路径
  2557. }
  2558. /// <summary>
  2559. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2560. /// </summary>
  2561. /// <param name="dto"></param>
  2562. /// <returns></returns>
  2563. [HttpPost]
  2564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2565. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2566. {
  2567. if (dto == null)
  2568. {
  2569. return Ok(JsonView(false, "请求错误:"));
  2570. }
  2571. string msg = "参数错误";
  2572. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2573. {
  2574. try
  2575. {
  2576. //_delegationVisaRep.BeginTran();
  2577. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2578. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2579. .Where(s => s.Id == dto.visaProgressCustomerId)
  2580. .ExecuteCommandAsync();
  2581. if (updCount > 0 && dto.publishCode == 1)
  2582. {
  2583. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2584. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2585. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2586. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2587. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2588. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2589. if (groupData == null)
  2590. {
  2591. _delegationVisaRep.RollbackTran();
  2592. }
  2593. string title = string.Format(@"[签证进度更新]");
  2594. string content = string.Format(@"测试文本");
  2595. bool rst = await _message.AddMsg(new MessageDto()
  2596. {
  2597. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2598. IssuerId = dto.publisher,
  2599. Title = title,
  2600. Content = content,
  2601. ReleaseTime = DateTime.Now,
  2602. UIdList = new List<int> {
  2603. 234
  2604. }
  2605. });
  2606. if (rst)
  2607. {
  2608. return Ok(JsonView(true, "发送通知成功"));
  2609. }
  2610. }
  2611. //_delegationVisaRep.CommitTran();
  2612. }
  2613. catch (Exception)
  2614. {
  2615. //_delegationVisaRep.RollbackTran();
  2616. }
  2617. }
  2618. return Ok(JsonView(true, msg));
  2619. }
  2620. #endregion
  2621. #region 团组任务分配
  2622. /// <summary>
  2623. /// 团组任务分配初始化
  2624. /// </summary>
  2625. /// <returns></returns>
  2626. [HttpPost]
  2627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2628. public async Task<IActionResult> GetTaskAssignmen()
  2629. {
  2630. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2631. if (groupData.Code != 0)
  2632. {
  2633. return Ok(JsonView(false, groupData.Msg));
  2634. }
  2635. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2636. }
  2637. /// <summary>
  2638. /// 团组任务分配查询
  2639. /// </summary>
  2640. /// <param name="dto"></param>
  2641. /// <returns></returns>
  2642. [HttpPost]
  2643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2644. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2645. {
  2646. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2647. if (groupData.Code != 0)
  2648. {
  2649. return Ok(JsonView(false, groupData.Msg));
  2650. }
  2651. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2652. }
  2653. /// <summary>
  2654. /// 团组任务分配操作
  2655. /// </summary>
  2656. /// <param name="dto"></param>
  2657. /// <returns></returns>
  2658. [HttpPost]
  2659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2660. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2661. {
  2662. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2663. if (groupData.Code != 0)
  2664. {
  2665. return Ok(JsonView(false, groupData.Msg));
  2666. }
  2667. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2668. }
  2669. /// <summary>
  2670. /// 团组任务分配
  2671. /// 批量分配
  2672. /// 查询团组
  2673. /// </summary>
  2674. /// <param name="dto"></param>
  2675. /// <returns></returns>
  2676. [HttpPost]
  2677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2678. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2679. {
  2680. //参数验证
  2681. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2682. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2683. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2684. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2685. }
  2686. /// <summary>
  2687. /// 团组任务分配
  2688. /// 批量分配
  2689. /// </summary>
  2690. /// <param name="dto"></param>
  2691. /// <returns></returns>
  2692. [HttpPost]
  2693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2694. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2695. {
  2696. //参数验证
  2697. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2698. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2699. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2700. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2701. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2702. }
  2703. #endregion
  2704. #region 团组费用审核
  2705. /// <summary>
  2706. /// 费用审核
  2707. /// 团组列表 Page
  2708. /// </summary>
  2709. /// <param name="_dto">团组列表请求dto</param>
  2710. /// <returns></returns>
  2711. [HttpPost]
  2712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2713. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2714. {
  2715. #region 参数验证
  2716. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2717. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2718. #region 页面操作权限验证
  2719. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2720. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2721. #endregion
  2722. #endregion
  2723. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2724. {
  2725. string sqlWhere = string.Empty;
  2726. if (_dto.IsSure == 0) //未完成
  2727. {
  2728. sqlWhere += string.Format(@" And IsSure = 0");
  2729. }
  2730. else if (_dto.IsSure == 1) //已完成
  2731. {
  2732. sqlWhere += string.Format(@" And IsSure = 1");
  2733. }
  2734. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2735. {
  2736. string tj = _dto.SearchCriteria;
  2737. 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}%')",
  2738. tj, tj, tj, tj, tj);
  2739. }
  2740. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2741. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2742. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2743. From (
  2744. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2745. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2746. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2747. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2748. From Grp_DelegationInfo gdi
  2749. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2750. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2751. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2752. Where gdi.IsDel = 0 {0}
  2753. ) temp ", sqlWhere);
  2754. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2755. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2756. var _view = new
  2757. {
  2758. PageFuncAuth = pageFunAuthView,
  2759. Data = _DelegationList
  2760. };
  2761. return Ok(JsonView(true, "查询成功!", _view, total));
  2762. }
  2763. else
  2764. {
  2765. return Ok(JsonView(false, "查询失败"));
  2766. }
  2767. }
  2768. /// <summary>
  2769. /// 获取团组费用审核
  2770. /// </summary>
  2771. /// <param name="_dto"></param>
  2772. /// <returns></returns>
  2773. [HttpPost]
  2774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2775. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2776. {
  2777. try
  2778. {
  2779. #region 参数验证
  2780. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2781. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2782. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2783. #region 页面操作权限验证
  2784. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2785. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2786. #endregion
  2787. #endregion
  2788. var _view = new Grp_CreditCardPaymentView();
  2789. var clientNameList = GetSimplClientList(_dto.DiId);
  2790. #region 费用清单
  2791. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2792. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2793. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2794. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2795. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2796. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2797. /*
  2798. * 76://酒店预订
  2799. */
  2800. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2801. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2802. /*
  2803. * 79://车/导游地接
  2804. */
  2805. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2806. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2807. /*
  2808. * 80: //签证
  2809. */
  2810. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2811. /*
  2812. *81: //邀请/公务活动
  2813. */
  2814. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2815. /*
  2816. * 82: //团组客户保险
  2817. */
  2818. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2819. /*
  2820. * Lable = 85 机票预订
  2821. */
  2822. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2823. /*
  2824. * 85 机票预定
  2825. */
  2826. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2827. /*
  2828. * 98 其他款项
  2829. */
  2830. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2831. /*
  2832. * 285:收款退还
  2833. */
  2834. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2835. /*
  2836. * 1015: //超支费用
  2837. */
  2838. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2839. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2840. /*
  2841. * 币种信息
  2842. */
  2843. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2844. /*
  2845. * 车/导游地接 费用类型
  2846. */
  2847. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2848. /*
  2849. * 车/导游地接 费用类型
  2850. */
  2851. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2852. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2853. /*
  2854. * 用户信息
  2855. */
  2856. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2857. /*
  2858. * 费用模块
  2859. */
  2860. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2861. string priceModule = string.Empty;
  2862. if (sdPriceName != null)
  2863. {
  2864. priceModule = sdPriceName.Name;
  2865. }
  2866. /*
  2867. * 成本信息
  2868. */
  2869. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2870. decimal _groupRate = 0.0000M;
  2871. string _groupCurrencyCode = "-";
  2872. if (groupCost != null)
  2873. {
  2874. _groupRate = groupCost.Rate;
  2875. if (int.TryParse(groupCost.Currency, out int _currency))
  2876. {
  2877. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2878. }
  2879. else _groupCurrencyCode = groupCost.Currency;
  2880. }
  2881. string costContentSql = $"Select * From Grp_GroupCost";
  2882. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2883. //处理日期为空的天数
  2884. for (int i = 0; i < groupCostDetails.Count; i++)
  2885. if (i != 0)
  2886. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2887. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2888. /*
  2889. * 处理详情数据
  2890. */
  2891. foreach (var entity in entityList)
  2892. {
  2893. var _detail = new Grp_CreditCardPaymentDetailView
  2894. {
  2895. Id = entity.Id,
  2896. PriceName = priceModule,
  2897. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  2898. };
  2899. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2900. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2901. //处理金额
  2902. if (entity.CTable == 1015)
  2903. {
  2904. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2905. if (czInfo != null)
  2906. {
  2907. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2908. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2909. }
  2910. }
  2911. /*
  2912. * 应付款金额
  2913. */
  2914. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2915. string PaymentCurrency_WaitPay = "Unknown";
  2916. string hotelCurrncyCode = "Unknown";
  2917. string hotelCurrncyName = "Unknown";
  2918. if (sdPaymentCurrency_WaitPay != null)
  2919. {
  2920. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2921. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2922. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2923. if (hotelCurrncyCode.Equals("CNY"))
  2924. {
  2925. entity.DayRate = 1.0000M;
  2926. }
  2927. }
  2928. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2929. /*
  2930. * 此次付款金额
  2931. */
  2932. decimal CurrPayStr = 0.00M,
  2933. OriginalCurrPay = 0.00M;
  2934. if (entity.PayPercentage == 0)
  2935. {
  2936. if (entity.PayThenMoney != 0)
  2937. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2938. }
  2939. else
  2940. {
  2941. if (entity.PayMoney != 0)
  2942. {
  2943. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2944. }
  2945. }
  2946. //if (_dto.Label == 79)
  2947. //{
  2948. // string original = string.Empty;
  2949. // if (hotelCurrncyCode.Equals("CNY"))
  2950. // {
  2951. // OriginalCurrPay = CurrPayStr;
  2952. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2953. // }
  2954. // else
  2955. // {
  2956. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2957. // //760 EUR(7600.00 CNY)
  2958. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2959. // }
  2960. //}
  2961. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2962. string original = string.Empty;
  2963. if (hotelCurrncyCode.Equals("CNY"))
  2964. {
  2965. OriginalCurrPay = CurrPayStr;
  2966. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2967. }
  2968. else
  2969. {
  2970. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2971. //760 EUR(7600.00 CNY)
  2972. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  2973. }
  2974. /*
  2975. * 剩余尾款
  2976. */
  2977. decimal BalanceStr = 0;
  2978. if (CurrPayStr != 0)
  2979. {
  2980. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2981. BalanceStr = 0;
  2982. else
  2983. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2984. }
  2985. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2986. /*
  2987. * Bus名称
  2988. */
  2989. _detail.BusName = "待增加";
  2990. /*
  2991. *费用所属
  2992. */
  2993. switch (entity.CTable)
  2994. {
  2995. case 76://酒店预订
  2996. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2997. if (hotelReservations != null)
  2998. {
  2999. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3000. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3001. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3002. string roomFeeStr = "", roomFeestr1 = "";
  3003. //是否比较房型价格
  3004. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3005. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3006. roomFeeStr += $"<br/>";
  3007. var roomTotal = 0.00M;
  3008. if (hotelReservations.SingleRoomPrice > 0)
  3009. {
  3010. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3011. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3012. //__isSingle = true;
  3013. roomTotal += fee;
  3014. }
  3015. if (hotelReservations.DoubleRoomPrice > 0)
  3016. {
  3017. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3018. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3019. // __isDouble = true;
  3020. roomTotal += fee;
  3021. }
  3022. if (hotelReservations.SuiteRoomPrice > 0)
  3023. {
  3024. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3025. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3026. //__isSuite = true;
  3027. roomTotal += fee;
  3028. }
  3029. if (hotelReservations.OtherRoomPrice > 0)
  3030. {
  3031. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3032. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3033. //__isOther = true;
  3034. roomTotal += fee;
  3035. }
  3036. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3037. else roomFeeStr += " 0.00 * 0";
  3038. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3039. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3040. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3041. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3042. /*
  3043. * 费用类型
  3044. * 1:房费
  3045. * 2:早餐
  3046. * 3:地税
  3047. * 4:城市税
  3048. * </summary>
  3049. */
  3050. //地税
  3051. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3052. if (governmentRentData != null)
  3053. {
  3054. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3055. governmentRentFee = governmentRentData.Price;
  3056. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3057. if (governmentRentCurrData != null)
  3058. {
  3059. governmentRentCode = governmentRentCurrData.Name;
  3060. governmentRentName = $"({governmentRentCurrData.Remark})";
  3061. }
  3062. }
  3063. //城市税
  3064. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3065. if (cityTaxData != null)
  3066. {
  3067. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3068. cityTaxFee = cityTaxData.Price;
  3069. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3070. if (cityTaxCurrData != null)
  3071. {
  3072. cityTaxCode = cityTaxCurrData.Name;
  3073. cityTaxName = $"({cityTaxCurrData.Remark})";
  3074. }
  3075. }
  3076. //酒店早餐
  3077. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3078. if (breakfastData != null)
  3079. {
  3080. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3081. breakfastFee = breakfastData.Price;
  3082. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3083. if (breakfastCurrData != null)
  3084. {
  3085. breakfastCode = breakfastCurrData.Name;
  3086. breakfastName = $"({breakfastCurrData.Remark})";
  3087. }
  3088. }
  3089. //房间费用
  3090. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3091. if (roomData != null)
  3092. {
  3093. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3094. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3095. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3096. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3097. roomFee = roomData.Price;
  3098. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3099. if (roomCurrData != null)
  3100. {
  3101. roomCode = roomCurrData.Name;
  3102. roomName = $"({roomCurrData.Remark})";
  3103. }
  3104. }
  3105. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3106. string hotelCostStr = "";
  3107. decimal hotelCsotTotal = 0.00M;
  3108. if (groupCost != null)
  3109. {
  3110. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3111. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3112. }
  3113. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3114. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3115. string hotelCost_day = "";
  3116. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3117. foreach (var item in hotelCostDetails1)
  3118. {
  3119. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3120. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3121. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3122. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3123. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3124. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3125. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3126. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3127. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3128. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3129. hotelCost_day += @$"<br/>";
  3130. }
  3131. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3132. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3133. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3134. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3135. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3136. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3137. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3138. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3139. $"房间说明: {hotelReservations.Remark} <br/>" +
  3140. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3141. $"{hotelBreakfastStr}" +
  3142. $"{hotelGovernmentRentStr}" +
  3143. $"{hotelCityTaxStr}";
  3144. _detail.PriceNameContent = hotelReservations.HotelName;
  3145. }
  3146. break;
  3147. case 79://车/导游地接
  3148. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3149. if (touristGuideGroundReservations != null)
  3150. {
  3151. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3152. {
  3153. _detail.BusName = touristGuideGroundReservations.BusName;
  3154. }
  3155. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3156. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3157. //if (isInt)
  3158. //{
  3159. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3160. // if (cityInfo != null)
  3161. // {
  3162. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3163. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3164. // if (carFeeItem != null)
  3165. // {
  3166. // nameContent += $@"({carFeeItem.Name})";
  3167. // }
  3168. // _detail.PriceNameContent = nameContent;
  3169. // }
  3170. //}
  3171. //else
  3172. //{
  3173. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3174. //}
  3175. var touristGuideGroundReservationsContents =
  3176. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3177. var opContent_sb = new StringBuilder();
  3178. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3179. opContent_sb.AppendLine(contetTitle);
  3180. foreach (var item in touristGuideGroundReservationsContents)
  3181. {
  3182. string typeName = "Unknown";
  3183. string carCurrencyCode = "Unknown";
  3184. string carCurrencyName = "Unknown";
  3185. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3186. if (carTypeData != null) typeName = carTypeData.Name;
  3187. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3188. if (currencyData != null)
  3189. {
  3190. carCurrencyCode = currencyData.Name;
  3191. carCurrencyName = currencyData.Remark;
  3192. }
  3193. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3194. bool IsCurrencyAgreement = false;
  3195. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3196. string opCostStr = string.Empty;
  3197. decimal opCostTypePrice = 0.00M;
  3198. #region 处理成本各项费用
  3199. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3200. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3201. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3202. costOPFeeCNY = 0.00M, //团组成本 op费用
  3203. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3204. if (opCost.Count > 0)
  3205. {
  3206. switch (item.SId)
  3207. {
  3208. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3209. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3210. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3211. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3212. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3213. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3214. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3215. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3216. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3217. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3218. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3219. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3220. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3221. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3222. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3223. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3224. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3225. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3226. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3227. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3228. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3229. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3230. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3231. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3232. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3233. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3234. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3235. }
  3236. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3237. costOPFeeCNY = opCostTypePrice * _groupRate;
  3238. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3239. }
  3240. #endregion
  3241. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3242. aduitOPFeeCNY = item.Price * entity.DayRate;
  3243. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3244. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3245. $"{opTypeStr} {opCostStr}<br/>" +
  3246. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3247. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3248. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3249. {
  3250. if (IsCurrencyAgreement)
  3251. {
  3252. if (item.Price > opCostTypePrice)
  3253. {
  3254. opContent_sb.Append("<span style='color:red;'>");
  3255. opContent_sb.Append(opContent);
  3256. opContent_sb.Append("</span>");
  3257. opContent_sb.AppendLine();
  3258. }
  3259. else
  3260. {
  3261. opContent_sb.Append(opContent);
  3262. opContent_sb.AppendLine();
  3263. }
  3264. }
  3265. else
  3266. {
  3267. //验证是否超成本 按付款比例计算
  3268. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3269. {
  3270. opContent_sb.Append("<span style='color:red;'>");
  3271. opContent_sb.Append(opContent);
  3272. opContent_sb.Append("</span>");
  3273. opContent_sb.AppendLine();
  3274. }
  3275. else
  3276. {
  3277. opContent_sb.Append(opContent);
  3278. opContent_sb.AppendLine();
  3279. }
  3280. }
  3281. }
  3282. else
  3283. {
  3284. opContent_sb.Append(opContent);
  3285. opContent_sb.AppendLine();
  3286. }
  3287. }
  3288. _detail.PriceMsgContent = opContent_sb.ToString();
  3289. }
  3290. break;
  3291. case 80: //签证
  3292. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3293. if (visaInfo != null)
  3294. {
  3295. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  3296. _detail.PriceNameContent = visaInfo.VisaDescription;
  3297. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3298. }
  3299. break;
  3300. case 81: //邀请/公务活动
  3301. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3302. if (_ioa != null)
  3303. {
  3304. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3305. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3306. sendCurrName = "Unknown", //快递费用币种 Name
  3307. sendCurrCode = "Unknown", //快递费用币种 Code
  3308. eventsCurrName = "Unknown", //公务活动费币种 Name
  3309. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3310. translateCurrName = "Unknown", //公务翻译费 Name
  3311. translateCurrCode = "Unknown"; //公务翻译费 Code
  3312. #region 处理费用币种
  3313. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3314. if (inviteCurrData != null)
  3315. {
  3316. inviteCurrName = inviteCurrData.Remark;
  3317. inviteCurrCode = inviteCurrData.Name;
  3318. }
  3319. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3320. if (sendCurrData != null)
  3321. {
  3322. sendCurrName = sendCurrData.Remark;
  3323. sendCurrCode = sendCurrData.Name;
  3324. }
  3325. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3326. if (eventsCurrData != null)
  3327. {
  3328. eventsCurrName = eventsCurrData.Remark;
  3329. eventsCurrCode = eventsCurrData.Name;
  3330. }
  3331. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3332. if (translateCurrData != null)
  3333. {
  3334. translateCurrName = translateCurrData.Remark;
  3335. translateCurrCode = translateCurrData.Name;
  3336. }
  3337. #endregion
  3338. _detail.PriceNameContent = _ioa.InviterArea;
  3339. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3340. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3341. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3342. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3343. $@"备注:" + _ioa.Remark + "<br/>";
  3344. }
  3345. break;
  3346. case 82: //团组客户保险
  3347. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3348. if (customers != null)
  3349. {
  3350. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3351. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3352. }
  3353. break;
  3354. case 85: //机票预订
  3355. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3356. if (jpRes != null)
  3357. {
  3358. string FlightsDescription = jpRes.FlightsDescription;
  3359. string PriceDescription = jpRes.PriceDescription;
  3360. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3361. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3362. }
  3363. break;
  3364. case 98://其他款项
  3365. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3366. if (gdpRes != null)
  3367. {
  3368. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3369. _detail.PriceNameContent = gdpRes.PriceName;
  3370. }
  3371. break;
  3372. case 285://收款退还
  3373. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3374. if (refundAndOtherMoney != null)
  3375. {
  3376. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3377. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3378. }
  3379. break;
  3380. case 751://酒店早餐
  3381. break;
  3382. case 1015://超支费用
  3383. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3384. if (groupExtraCost != null)
  3385. {
  3386. _detail.PriceNameContent = groupExtraCost.PriceName;
  3387. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3388. }
  3389. break;
  3390. default:
  3391. break;
  3392. }
  3393. /*
  3394. * 申请人
  3395. */
  3396. string operatorName = " - ";
  3397. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3398. if (_opUser != null)
  3399. {
  3400. operatorName = _opUser.CnName;
  3401. }
  3402. _detail.OperatorName = operatorName;
  3403. /*
  3404. * 审核人
  3405. */
  3406. string auditOperatorName = " - ";
  3407. if (entity.IsAuditGM != 0)
  3408. {
  3409. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3410. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3411. else
  3412. {
  3413. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3414. if (_adUser != null)
  3415. {
  3416. auditOperatorName = _adUser.CnName;
  3417. }
  3418. }
  3419. }
  3420. _detail.AuditOperatorName = auditOperatorName;
  3421. /*
  3422. * 超预算比例
  3423. */
  3424. string overBudgetStr = "";
  3425. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3426. else if (entity.ExceedBudget == 0)
  3427. {
  3428. if (entity.CTable == 76 || entity.CTable == 79)
  3429. {
  3430. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3431. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3432. }
  3433. else
  3434. {
  3435. overBudgetStr = "未超预算";
  3436. }
  3437. }
  3438. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3439. _detail.OverBudget = overBudgetStr;
  3440. decimal auditFee = 0.00M; //已审核金额 人名币
  3441. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3442. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3443. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3444. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3445. {
  3446. auditedFeeOriginal = entity.PayMoney;
  3447. auditFee = CurrPayStr;
  3448. }
  3449. else if (entity.IsAuditGM == 0)
  3450. {
  3451. unAuditFeeCNY = CurrPayStr;
  3452. unAuditFeeOriginal = OriginalCurrPay;
  3453. OriginalCurrPay = 0.00M;
  3454. }
  3455. /*
  3456. * 费用总计
  3457. */
  3458. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3459. {
  3460. CurrencyId = entity.PaymentCurrency,
  3461. CurrencyName = PaymentCurrency_WaitPay,
  3462. AmountPayable = entity.PayMoney,
  3463. ThisPayment = OriginalCurrPay,
  3464. BalancePayment = BalanceStr,
  3465. AuditedFunds = auditFee,
  3466. AuditedFundsOriginal = auditedFeeOriginal,
  3467. UnAuditFundsCNY = unAuditFeeCNY,
  3468. UnAuditFundsOriginal = unAuditFeeOriginal
  3469. });
  3470. _detail.IsAuditGM = entity.IsAuditGM;
  3471. detailList.Add(_detail);
  3472. }
  3473. #endregion
  3474. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3475. /*
  3476. * 下方描述处理
  3477. */
  3478. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3479. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3480. if (ccpCurrencyPrice != null)
  3481. {
  3482. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3483. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3484. }
  3485. else
  3486. {
  3487. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3488. }
  3489. string amountPayableStr = string.Format(@"应付款总金额: ");
  3490. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3491. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3492. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3493. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3494. foreach (var item in nonDuplicat)
  3495. {
  3496. var currencyName = item.CurrencyName;
  3497. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3498. if (strs.Count > 0)
  3499. {
  3500. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3501. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3502. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3503. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3504. //单独处理此次付款金额
  3505. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3506. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3507. //单独处理已审核费用
  3508. //if (item.CurrencyId == 836) //人民币
  3509. //{
  3510. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3511. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3512. //}
  3513. //else
  3514. //{
  3515. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3516. //}
  3517. if (currencyName.Equals("CNY"))
  3518. {
  3519. //已审核费用
  3520. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3521. //未审核费用
  3522. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3523. }
  3524. else
  3525. {
  3526. //已审核费用
  3527. 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"));
  3528. //未审核费用
  3529. 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"));
  3530. }
  3531. }
  3532. }
  3533. _view.TotalStr1 = amountPayableStr[..^1];
  3534. _view.TotalStr2 = thisPaymentStr[..^1];
  3535. _view.TotalStr3 = balancePaymentStr[..^1];
  3536. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3537. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3538. var _view1 = new
  3539. {
  3540. PageFuncAuth = pageFunAuthView,
  3541. Data = _view
  3542. };
  3543. return Ok(JsonView(_view1));
  3544. }
  3545. catch (Exception ex)
  3546. {
  3547. return Ok(JsonView(false, ex.Message));
  3548. }
  3549. }
  3550. /// <summary>
  3551. /// 费用审核
  3552. /// 修改团组费用审核状态
  3553. /// </summary>
  3554. /// <param name="_dto">参数Json字符串</param>
  3555. /// <returns></returns>
  3556. [HttpPost]
  3557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3558. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3559. {
  3560. #region 参数验证
  3561. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3562. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3563. #endregion
  3564. #region 页面操作权限验证
  3565. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3566. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3567. #endregion
  3568. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3569. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3570. DateTime dtNow = DateTime.Now;
  3571. _groupRepository.BeginTran();
  3572. int rst = 0;
  3573. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3574. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3575. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3576. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3577. var msgDatas = new List<dynamic>();
  3578. var dic_ccp_user = new Dictionary<int, int>() { };
  3579. foreach (var item in idList)
  3580. {
  3581. int CreditId = int.Parse(item);
  3582. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3583. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3584. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3585. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3586. .Where(s => s.Id == CreditId)
  3587. .ExecuteCommandAsync();
  3588. if (result < 1)
  3589. {
  3590. rst = -1;
  3591. _groupRepository.RollbackTran();
  3592. return Ok(JsonView(false, "操作失败并回滚!"));
  3593. }
  3594. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3595. if (creditData != null)
  3596. {
  3597. #region 应用通知配置
  3598. try
  3599. {
  3600. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3601. }
  3602. catch (Exception ex)
  3603. {
  3604. }
  3605. #endregion
  3606. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3607. string groupNameStr = string.Empty;
  3608. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3609. if (groupData != null) groupNameStr = groupData.TeamName;
  3610. string creditTypeStr = string.Empty;
  3611. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3612. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3613. string creditCurrency = string.Empty;
  3614. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3615. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3616. if (creditCurrency.Equals("CNY"))
  3617. {
  3618. creditData.DayRate = 1.0000M;
  3619. }
  3620. if (creditData.PayPercentage == 0.00M)
  3621. {
  3622. creditData.PayPercentage = 100M;
  3623. }
  3624. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3625. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3626. string msgContent = "";
  3627. if (creditCurrency.Equals("CNY"))
  3628. {
  3629. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3630. }
  3631. else
  3632. {
  3633. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3634. }
  3635. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3636. }
  3637. }
  3638. if (rst == 0)
  3639. {
  3640. _groupRepository.CommitTran();
  3641. foreach (var item in msgDatas)
  3642. {
  3643. //发送消息
  3644. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3645. }
  3646. #region 应用推送
  3647. try
  3648. {
  3649. foreach (var ccpId in dic_ccp_user.Keys)
  3650. {
  3651. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3652. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3653. }
  3654. }
  3655. catch (Exception)
  3656. {
  3657. }
  3658. #endregion
  3659. return Ok(JsonView(true, "操作成功!"));
  3660. }
  3661. return Ok(JsonView(false, "操作失败!"));
  3662. }
  3663. #endregion
  3664. #region 机票费用录入
  3665. /// <summary>
  3666. /// 机票录入当前登录人可操作团组
  3667. /// </summary>
  3668. /// <param name="dto"></param>
  3669. /// <returns></returns>
  3670. [HttpPost]
  3671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3672. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3673. {
  3674. try
  3675. {
  3676. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3677. if (groupData.Code != 0)
  3678. {
  3679. return Ok(JsonView(false, groupData.Msg));
  3680. }
  3681. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3682. }
  3683. catch (Exception ex)
  3684. {
  3685. return Ok(JsonView(false, ex.Message));
  3686. }
  3687. }
  3688. /// <summary>
  3689. /// 机票费用录入列表
  3690. /// </summary>
  3691. /// <param name="dto"></param>
  3692. /// <returns></returns>
  3693. [HttpPost]
  3694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3695. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3696. {
  3697. try
  3698. {
  3699. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3700. if (groupData.Code != 0)
  3701. {
  3702. return Ok(JsonView(false, groupData.Msg));
  3703. }
  3704. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3705. }
  3706. catch (Exception ex)
  3707. {
  3708. return Ok(JsonView(false, ex.Message));
  3709. throw;
  3710. }
  3711. }
  3712. /// <summary>
  3713. /// 根据id查询费用录入信息
  3714. /// </summary>
  3715. /// <param name="dto"></param>
  3716. /// <returns></returns>
  3717. [HttpPost]
  3718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3719. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3720. {
  3721. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3722. if (groupData.Code != 0)
  3723. {
  3724. return Ok(JsonView(false, groupData.Msg));
  3725. }
  3726. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3727. }
  3728. /// <summary>
  3729. /// 机票费用录入操作(Status:1.新增,2.修改)
  3730. /// </summary>
  3731. /// <param name="dto"></param>
  3732. /// <returns></returns>
  3733. [HttpPost]
  3734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3735. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3736. {
  3737. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3738. if (groupData.Code != 0)
  3739. {
  3740. return Ok(JsonView(false, groupData.Msg));
  3741. }
  3742. #region 应用推送
  3743. try
  3744. {
  3745. var diId = dto.AirTicketResOpData.DiId;
  3746. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3747. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3748. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3749. //自动审核
  3750. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  3751. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  3752. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  3753. $"GroupId:{diId};airId:{dataId};",
  3754. status,
  3755. auditMsg);
  3756. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3757. //2024-10-21 新增LZ UID
  3758. var userIds = new List<int>() { 21 };
  3759. string title = $"系统通知";
  3760. string content = "";
  3761. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3762. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3763. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3764. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3765. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3766. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3767. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3768. }
  3769. catch (Exception ex)
  3770. {
  3771. }
  3772. #endregion
  3773. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3774. }
  3775. /// <summary>
  3776. /// 机票费用自动审核 AI识别方式
  3777. /// </summary>
  3778. /// <returns></returns>
  3779. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  3780. {
  3781. var ecoTypeIds = new List<int>() {
  3782. 459, //超经舱
  3783. 460, //经济舱
  3784. 1430, //公务舱(实际经济舱)
  3785. 1432, //头等舱(实际经济舱)
  3786. };
  3787. var bizTypeIds = new List<int>() {
  3788. 457, //头等舱
  3789. 458, //公务舱
  3790. 1431, //头等舱(实际公务舱)
  3791. };
  3792. var auditFeeTypeIds = new List<int>() { };
  3793. auditFeeTypeIds.AddRange(ecoTypeIds);
  3794. auditFeeTypeIds.AddRange(bizTypeIds);
  3795. int currModule = 85;
  3796. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  3797. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  3798. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  3799. .Select((x, y) => new
  3800. {
  3801. x.Id,
  3802. CcpId = y.Id,
  3803. x.FlightsDate,
  3804. x.PrePrice,
  3805. x.CType,
  3806. x.ClientNum,
  3807. x.DIId
  3808. })
  3809. .FirstAsync();
  3810. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  3811. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  3812. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  3813. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  3814. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  3815. var groupCostContents = await _sqlSugar
  3816. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  3817. .Where(x => x.IsDel == 0 && x.Diid == diId)
  3818. .ToListAsync();
  3819. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  3820. //处理 成本详细信息日期为空 填装费用信息
  3821. var airFeeLabel = new StringBuilder();
  3822. airFeeLabel.AppendLine("费用成本:");
  3823. for (int i = 0; i < groupCostContents.Count; i++)
  3824. {
  3825. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  3826. {
  3827. int index = i - 1;
  3828. if (index >= 0)
  3829. {
  3830. groupCostContents[i].Date = groupCostContents[index].Date;
  3831. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3832. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3833. }
  3834. }
  3835. else
  3836. {
  3837. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3838. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3839. }
  3840. var item = groupCostContents[i];
  3841. airFeeLabel.AppendLine($"{item.Date}");
  3842. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  3843. }
  3844. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  3845. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  3846. //访问Kimi AI 返回价格结果
  3847. var msgs = new List<SeedMessages>()
  3848. {
  3849. new ()
  3850. {
  3851. Role = KimiRole.user,
  3852. Content = airFeeLabel.ToString()
  3853. }
  3854. };
  3855. var client = new KiMiApiClient();
  3856. var kimiApiResult = await client.SeedMessage(msgs);
  3857. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3858. string clients = kimiApiResult_JObject["content"].ToString();
  3859. decimal ecoPri_kimiAI = 0.00M,
  3860. bizPri_kimiAI = 0.00M;
  3861. //单个价格: 经济舱价格
  3862. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  3863. //价格文本包含/:/前经济舱价格 /后公务舱价格
  3864. if (clients.Contains('/'))
  3865. {
  3866. var priArray = clients.Split('/');
  3867. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  3868. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  3869. }
  3870. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  3871. var isAutoAudit = false;
  3872. //价格验证处理
  3873. //经济舱
  3874. if (ecoTypeIds.Contains(airInfo.CType))
  3875. {
  3876. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  3877. }
  3878. //公务舱
  3879. else if (bizTypeIds.Contains(airInfo.CType))
  3880. {
  3881. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  3882. }
  3883. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  3884. //是否执行自动审核
  3885. if (isAutoAudit)
  3886. {
  3887. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3888. .SetColumns(x => x.IsAuditGM == 3)
  3889. .SetColumns(x => x.AuditGMOperate == 4)
  3890. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  3891. .Where(x => x.Id == airInfo.CcpId)
  3892. .ExecuteCommandAsync();
  3893. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  3894. }
  3895. return (false, "当前费用超过成本费用,不可自动审核!");
  3896. }
  3897. /// <summary>
  3898. /// 机票费用录入
  3899. /// 自动审核测试 - AI 识别
  3900. /// </summary>
  3901. /// <param name="groupId"></param>
  3902. /// <param name="Id"></param>
  3903. /// <returns></returns>
  3904. [HttpPost]
  3905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3906. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  3907. {
  3908. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  3909. return Ok(JsonView(status, msg));
  3910. }
  3911. /// <summary>
  3912. /// 根据舱位类型查询接团客户名单信息
  3913. /// </summary>
  3914. /// <param name="dto"></param>
  3915. /// <returns></returns>
  3916. [HttpPost]
  3917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3918. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  3919. {
  3920. try
  3921. {
  3922. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  3923. if (crm_Groups.Count != 0)
  3924. {
  3925. var Customer = new List<dynamic>();
  3926. foreach (var item in crm_Groups)
  3927. {
  3928. var data = new
  3929. {
  3930. item.Id,
  3931. item.Pinyin,
  3932. Name = item.LastName + item.FirstName
  3933. };
  3934. Customer.Add(data);
  3935. }
  3936. return Ok(JsonView(true, "查询成功!", Customer));
  3937. }
  3938. return Ok(JsonView(true, "暂无数据", crm_Groups));
  3939. }
  3940. catch (Exception ex)
  3941. {
  3942. return Ok(JsonView(false, "程序错误!"));
  3943. throw;
  3944. }
  3945. }
  3946. /// <summary>
  3947. /// 根据团号获取客户信息
  3948. /// </summary>
  3949. /// <param name="dto"></param>
  3950. /// <returns></returns>
  3951. [HttpPost]
  3952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3953. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3954. {
  3955. var jw = JsonView(false);
  3956. if (dto.DIID < 1)
  3957. {
  3958. jw.Msg += "请输入正确的diid";
  3959. return Ok(jw);
  3960. }
  3961. var arr = GetSimplClientList(dto.DIID);
  3962. jw = JsonView(true, "获取成功!", arr);
  3963. return Ok(jw);
  3964. }
  3965. private List<SimplClientInfo> GetSimplClientList(int diId)
  3966. {
  3967. 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);
  3968. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3969. foreach (var item in arr)
  3970. {
  3971. EncryptionProcessor.DecryptProperties(item);
  3972. }
  3973. return arr;
  3974. }
  3975. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  3976. {
  3977. string result = origin;
  3978. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3979. {
  3980. string[] temparr = origin.Split(',');
  3981. string fistrStr = temparr[0];
  3982. int count = temparr.Length;
  3983. bool success = int.TryParse(fistrStr, out int tempId);
  3984. if (success)
  3985. {
  3986. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3987. if (tempInfo != null)
  3988. {
  3989. if (count > 1)
  3990. {
  3991. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3992. }
  3993. else
  3994. {
  3995. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3996. }
  3997. }
  3998. }
  3999. }
  4000. return result;
  4001. }
  4002. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4003. {
  4004. string result = origin;
  4005. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4006. {
  4007. string[] temparr = origin.Split(',');
  4008. result = "";
  4009. foreach (var item in temparr)
  4010. {
  4011. bool success = int.TryParse(item, out int tempId);
  4012. if (success)
  4013. {
  4014. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4015. if (tempInfo != null)
  4016. {
  4017. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4018. }
  4019. }
  4020. }
  4021. }
  4022. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4023. return result;
  4024. }
  4025. /// <summary>
  4026. /// 机票费用录入,删除
  4027. /// </summary>
  4028. /// <param name="dto"></param>
  4029. /// <returns></returns>
  4030. [HttpPost]
  4031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4032. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4033. {
  4034. try
  4035. {
  4036. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4037. if (res)
  4038. {
  4039. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4040. {
  4041. IsDel = 1,
  4042. DeleteUserId = dto.DeleteUserId,
  4043. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4044. }).ExecuteCommandAsync();
  4045. return Ok(JsonView(true, "删除成功!"));
  4046. }
  4047. return Ok(JsonView(false, "删除失败!"));
  4048. }
  4049. catch (Exception ex)
  4050. {
  4051. return Ok(JsonView(false, "程序错误!"));
  4052. throw;
  4053. }
  4054. }
  4055. /// <summary>
  4056. /// 导出机票录入报表
  4057. /// </summary>
  4058. /// <param name="dto"></param>
  4059. /// <returns></returns>
  4060. [HttpPost]
  4061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4062. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4063. {
  4064. try
  4065. {
  4066. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4067. if (groupData.Code != 0)
  4068. {
  4069. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4070. }
  4071. else
  4072. {
  4073. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4074. if (AirTicketReservations.Count != 0)
  4075. {
  4076. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4077. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4078. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4079. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4080. var designer = new WorkbookDesigner
  4081. {
  4082. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4083. };
  4084. decimal countCost = 0;
  4085. foreach (var item in AirTicketReservations)
  4086. {
  4087. #region 处理客人姓名
  4088. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4089. item.ClientName = clientNames;
  4090. #endregion
  4091. if (item.BankType == "其他")
  4092. {
  4093. item.BankNo = "--";
  4094. }
  4095. else
  4096. {
  4097. if (!string.IsNullOrEmpty(item.BankType))
  4098. {
  4099. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  4100. }
  4101. }
  4102. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4103. item.Price = System.Decimal.Round(item.Price, 2);
  4104. countCost += Convert.ToDecimal(item.Price);
  4105. }
  4106. designer.SetDataSource("Export", AirTicketReservations);
  4107. designer.SetDataSource("ExportDiCode", diCode);
  4108. designer.SetDataSource("ExportDiName", diName);
  4109. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4110. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4111. designer.Process();
  4112. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4113. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4114. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4115. return Ok(JsonView(true, "成功", url = rst));
  4116. }
  4117. else
  4118. {
  4119. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4120. }
  4121. }
  4122. }
  4123. catch (Exception ex)
  4124. {
  4125. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4126. throw;
  4127. }
  4128. }
  4129. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4130. /// <summary>
  4131. /// 行程单导出
  4132. /// </summary>
  4133. /// <param name="dto"></param>
  4134. /// <returns></returns>
  4135. [HttpPost]
  4136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4137. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4138. {
  4139. try
  4140. {
  4141. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4142. if (groupData.Code != 0)
  4143. {
  4144. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4145. }
  4146. else
  4147. {
  4148. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4149. if (dto.Language == "CN")
  4150. {
  4151. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4152. var builder = new DocumentBuilder(doc);
  4153. int tableIndex = 0;//表格索引
  4154. //得到文档中的第一个表格
  4155. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4156. foreach (var item in _AirTicketReservations)
  4157. {
  4158. #region 处理固定数据
  4159. string[] FlightsCode = item.FlightsCode.Split('/');
  4160. if (FlightsCode.Length != 0)
  4161. {
  4162. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4163. if (_AirCompany != null)
  4164. {
  4165. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4166. }
  4167. else
  4168. {
  4169. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4170. }
  4171. }
  4172. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4173. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4174. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4175. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4176. string name = "";
  4177. foreach (string clientName in nameArray)
  4178. {
  4179. if (!name.Contains(clientName))
  4180. {
  4181. name += clientName + ",";
  4182. }
  4183. }
  4184. if (!string.IsNullOrWhiteSpace(name))
  4185. {
  4186. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4187. }
  4188. else
  4189. {
  4190. table.Range.Bookmarks["ClientName"].Text = "--";
  4191. }
  4192. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4193. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4194. table.Range.Bookmarks["JointTicket"].Text = "--";
  4195. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4196. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4197. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4198. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4199. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4200. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4201. #endregion
  4202. #region 循环数据处理
  4203. var airs = new List<AirInfo>();
  4204. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4205. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4206. for (int i = 0; i < FlightsCode.Length; i++)
  4207. {
  4208. var air = new AirInfo();
  4209. string[] tempstr = DayArray[i]
  4210. .Replace("\r\n", string.Empty)
  4211. .Replace("\\r\\n", string.Empty)
  4212. .TrimStart().TrimEnd()
  4213. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4214. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4215. string starCity = "";
  4216. if (star_Three != null)
  4217. {
  4218. starCity = star_Three.AirPort;
  4219. }
  4220. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4221. string EndCity = "";
  4222. if (End_Three != null)
  4223. {
  4224. EndCity = End_Three.AirPort;
  4225. }
  4226. air.Destination = starCity + "/" + EndCity;
  4227. air.Flight = FlightsCode[i];
  4228. air.SeatingClass = item.CTypeName;
  4229. string dateTime = tempstr[2];
  4230. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4231. air.FlightDate = DateTemp;
  4232. air.DepartureTime = tempstr[5];
  4233. air.LandingTime = tempstr[6];
  4234. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4235. air.TicketStatus = "--";
  4236. air.Luggage = "--";
  4237. air.DepartureTerminal = "--";
  4238. air.LandingTerminal = "--";
  4239. airs.Add(air);
  4240. }
  4241. int row = 13;
  4242. for (int i = 0; i < airs.Count; i++)
  4243. {
  4244. if (airs.Count > 2)
  4245. {
  4246. for (int j = 0; j < airs.Count - 2; j++)
  4247. {
  4248. var CopyRow = table.Rows[12].Clone(true);
  4249. table.Rows.Add(CopyRow);
  4250. }
  4251. }
  4252. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4253. int index = 0;
  4254. foreach (PropertyInfo property in properties)
  4255. {
  4256. string value = property.GetValue(airs[i]).ToString();
  4257. Cell ishcel0 = table.Rows[row].Cells[index];
  4258. var p = new Paragraph(doc);
  4259. string s = value;
  4260. p.AppendChild(new Run(doc, s));
  4261. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4262. ishcel0.AppendChild(p);
  4263. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4264. index++;
  4265. }
  4266. row++;
  4267. }
  4268. #endregion
  4269. var lastParagraph = new Paragraph(doc);
  4270. //第一个表格末尾加段落
  4271. table.ParentNode.InsertAfter(lastParagraph, table);
  4272. //复制第一个表格
  4273. Table cloneTable = (Table)table.Clone(true);
  4274. //在文档末尾段落后面加入复制的表格
  4275. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4276. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4277. {
  4278. int rownewsIndex = 13;
  4279. for (int i = 0; i < 2; i++)
  4280. {
  4281. var CopyRow = table.Rows[12].Clone(true);
  4282. table.Rows.RemoveAt(13);
  4283. table.Rows.Add(CopyRow);
  4284. rownewsIndex++;
  4285. }
  4286. }
  4287. else
  4288. {
  4289. table.Rows.RemoveAt(12);
  4290. }
  4291. cloneTable.Rows.RemoveAt(12);
  4292. }
  4293. if (_AirTicketReservations.Count != 0)
  4294. {
  4295. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4296. if (FlightsCode.Length != 0)
  4297. {
  4298. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4299. if (_AirCompany != null)
  4300. {
  4301. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4302. }
  4303. else
  4304. {
  4305. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4306. }
  4307. }
  4308. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4309. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4310. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4311. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4312. string name = "";
  4313. foreach (string clientName in nameArray)
  4314. {
  4315. if (!name.Contains(clientName))
  4316. {
  4317. name += clientName + ",";
  4318. }
  4319. }
  4320. if (!string.IsNullOrWhiteSpace(name))
  4321. {
  4322. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4323. }
  4324. else
  4325. {
  4326. table.Range.Bookmarks["ClientName"].Text = "--";
  4327. }
  4328. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4329. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4330. table.Range.Bookmarks["JointTicket"].Text = "--";
  4331. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4332. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4333. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4334. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4335. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4336. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4337. }
  4338. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4339. //保存合并后的文档
  4340. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4341. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4342. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4343. return Ok(JsonView(true, "成功!", rst));
  4344. }
  4345. else
  4346. {
  4347. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4348. var builder = new DocumentBuilder(doc);
  4349. int tableIndex = 0;//表格索引
  4350. //得到文档中的第一个表格
  4351. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4352. var texts = new List<string>();
  4353. foreach (var item in _AirTicketReservations)
  4354. {
  4355. string[] FlightsCode = item.FlightsCode.Split('/');
  4356. if (FlightsCode.Length != 0)
  4357. {
  4358. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4359. if (_AirCompany != null)
  4360. {
  4361. if (!transDic.ContainsKey(_AirCompany.CnName))
  4362. {
  4363. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4364. }
  4365. }
  4366. else
  4367. {
  4368. if (!transDic.ContainsKey("--"))
  4369. {
  4370. transDic.Add("--", "--");
  4371. }
  4372. }
  4373. }
  4374. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4375. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4376. string name = "";
  4377. foreach (string clientName in nameArray)
  4378. {
  4379. name += clientName + ",";
  4380. }
  4381. if (!texts.Contains(name))
  4382. {
  4383. texts.Add(name);
  4384. }
  4385. var airs = new List<AirInfo>();
  4386. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4387. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4388. for (int i = 0; i < FlightsCode.Length; i++)
  4389. {
  4390. var air = new AirInfo();
  4391. string[] tempstr = DayArray[i]
  4392. .Replace("\r\n", string.Empty)
  4393. .Replace("\\r\\n", string.Empty)
  4394. .TrimStart().TrimEnd()
  4395. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4396. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4397. if (star_Three != null)
  4398. {
  4399. if (!transDic.ContainsKey(star_Three.AirPort))
  4400. {
  4401. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4402. }
  4403. }
  4404. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4405. if (End_Three != null)
  4406. {
  4407. if (!transDic.ContainsKey(End_Three.AirPort))
  4408. {
  4409. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4410. }
  4411. }
  4412. if (!texts.Contains(item.CTypeName))
  4413. {
  4414. texts.Add(item.CTypeName);
  4415. }
  4416. }
  4417. }
  4418. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4419. if (transData.Count > 0)
  4420. {
  4421. foreach (TranslateResult item in transData)
  4422. {
  4423. if (!transDic.ContainsKey(item.Query))
  4424. {
  4425. transDic.Add(item.Query, item.Translation);
  4426. }
  4427. }
  4428. }
  4429. foreach (var item in _AirTicketReservations)
  4430. {
  4431. #region 处理固定数据
  4432. string[] FlightsCode = item.FlightsCode.Split('/');
  4433. if (FlightsCode.Length != 0)
  4434. {
  4435. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4436. if (_AirCompany != null)
  4437. {
  4438. string str = "--";
  4439. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4440. if (!string.IsNullOrEmpty(translateResult))
  4441. {
  4442. str = translateResult;
  4443. str = _airTicketResRep.Processing(str);
  4444. }
  4445. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4446. }
  4447. else
  4448. {
  4449. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4450. }
  4451. }
  4452. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4453. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4454. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4455. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4456. string names = "";
  4457. foreach (string clientName in nameArray)
  4458. {
  4459. names += clientName + ",";
  4460. }
  4461. if (!string.IsNullOrWhiteSpace(names))
  4462. {
  4463. string str = "--";
  4464. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4465. if (!string.IsNullOrEmpty(translateResult))
  4466. {
  4467. str = translateResult;
  4468. str = _airTicketResRep.Processing(str);
  4469. }
  4470. table.Range.Bookmarks["ClientName"].Text = str;
  4471. }
  4472. else
  4473. {
  4474. table.Range.Bookmarks["ClientName"].Text = "--";
  4475. }
  4476. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4477. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4478. table.Range.Bookmarks["JointTicket"].Text = "--";
  4479. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4480. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4481. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4482. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4483. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4484. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4485. #endregion
  4486. #region 循环数据处理
  4487. var airs = new List<AirInfo>();
  4488. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4489. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4490. for (int i = 0; i < FlightsCode.Length; i++)
  4491. {
  4492. var air = new AirInfo();
  4493. string[] tempstr = DayArray[i]
  4494. .Replace("\r\n", string.Empty)
  4495. .Replace("\\r\\n", string.Empty)
  4496. .TrimStart().TrimEnd()
  4497. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4498. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4499. string starCity = "";
  4500. if (star_Three != null)
  4501. {
  4502. string str2 = "--";
  4503. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4504. if (!string.IsNullOrEmpty(translateResult2))
  4505. {
  4506. str2 = translateResult2;
  4507. str2 = _airTicketResRep.Processing(str2);
  4508. }
  4509. starCity = str2;
  4510. }
  4511. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4512. string EndCity = "";
  4513. if (End_Three != null)
  4514. {
  4515. string str1 = "--";
  4516. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4517. if (!string.IsNullOrEmpty(translateResult1))
  4518. {
  4519. str1 = translateResult1;
  4520. str1 = _airTicketResRep.Processing(str1);
  4521. }
  4522. EndCity = str1;
  4523. }
  4524. air.Destination = starCity + "/" + EndCity;
  4525. air.Flight = FlightsCode[i];
  4526. string str = "--";
  4527. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4528. if (!string.IsNullOrEmpty(translateResult))
  4529. {
  4530. str = translateResult;
  4531. str = _airTicketResRep.Processing(str);
  4532. }
  4533. air.SeatingClass = str;
  4534. string dateTime = tempstr[2];
  4535. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4536. air.FlightDate = DateTemp;
  4537. air.DepartureTime = tempstr[5];
  4538. air.LandingTime = tempstr[6];
  4539. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4540. air.TicketStatus = "--";
  4541. air.Luggage = "--";
  4542. air.DepartureTerminal = "--";
  4543. air.LandingTerminal = "--";
  4544. airs.Add(air);
  4545. }
  4546. int row = 13;
  4547. for (int i = 0; i < airs.Count; i++)
  4548. {
  4549. if (airs.Count > 2)
  4550. {
  4551. for (int j = 0; j < airs.Count - 2; j++)
  4552. {
  4553. var CopyRow = table.Rows[12].Clone(true);
  4554. table.Rows.Add(CopyRow);
  4555. }
  4556. }
  4557. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4558. int index = 0;
  4559. foreach (PropertyInfo property in properties)
  4560. {
  4561. string value = property.GetValue(airs[i]).ToString();
  4562. Cell ishcel0 = table.Rows[row].Cells[index];
  4563. var p = new Paragraph(doc);
  4564. string s = value;
  4565. p.AppendChild(new Run(doc, s));
  4566. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4567. ishcel0.AppendChild(p);
  4568. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4569. //ishcel0.CellFormat.VerticalAlignment=
  4570. index++;
  4571. }
  4572. row++;
  4573. }
  4574. #endregion
  4575. var lastParagraph = new Paragraph(doc);
  4576. //第一个表格末尾加段落
  4577. table.ParentNode.InsertAfter(lastParagraph, table);
  4578. //复制第一个表格
  4579. Table cloneTable = (Table)table.Clone(true);
  4580. //在文档末尾段落后面加入复制的表格
  4581. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4582. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4583. {
  4584. int rownewsIndex = 13;
  4585. for (int i = 0; i < 2; i++)
  4586. {
  4587. var CopyRow = table.Rows[12].Clone(true);
  4588. table.Rows.RemoveAt(13);
  4589. table.Rows.Add(CopyRow);
  4590. rownewsIndex++;
  4591. }
  4592. }
  4593. else
  4594. {
  4595. table.Rows.RemoveAt(12);
  4596. }
  4597. cloneTable.Rows.RemoveAt(12);
  4598. }
  4599. if (_AirTicketReservations.Count != 0)
  4600. {
  4601. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4602. if (FlightsCode.Length != 0)
  4603. {
  4604. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4605. if (_AirCompany != null)
  4606. {
  4607. string str = "--";
  4608. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4609. if (!string.IsNullOrEmpty(translateResult))
  4610. {
  4611. str = translateResult;
  4612. str = _airTicketResRep.Processing(str);
  4613. }
  4614. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4615. }
  4616. else
  4617. {
  4618. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4619. }
  4620. }
  4621. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4622. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4623. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4624. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4625. string names = "";
  4626. foreach (string clientName in nameArray)
  4627. {
  4628. names += clientName + ",";
  4629. }
  4630. if (!string.IsNullOrWhiteSpace(names))
  4631. {
  4632. string str = "--";
  4633. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4634. if (!string.IsNullOrEmpty(translateResult))
  4635. {
  4636. str = translateResult;
  4637. str = _airTicketResRep.Processing(str);
  4638. }
  4639. table.Range.Bookmarks["ClientName"].Text = str;
  4640. }
  4641. else
  4642. {
  4643. table.Range.Bookmarks["ClientName"].Text = "--";
  4644. }
  4645. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4646. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4647. table.Range.Bookmarks["JointTicket"].Text = "--";
  4648. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4649. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4650. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4651. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4652. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4653. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4654. }
  4655. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4656. //保存合并后的文档
  4657. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4658. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4659. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4660. return Ok(JsonView(true, "成功!", rst));
  4661. }
  4662. }
  4663. }
  4664. catch (Exception ex)
  4665. {
  4666. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4667. throw;
  4668. }
  4669. }
  4670. #endregion
  4671. #region 团组增减款项 --> 其他款项
  4672. /// <summary>
  4673. /// 团组增减款项下拉框绑定
  4674. /// </summary>
  4675. /// <param name="dto"></param>
  4676. /// <returns></returns>
  4677. [HttpPost]
  4678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4679. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4680. {
  4681. #region 参数验证
  4682. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4683. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4684. #endregion
  4685. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4686. }
  4687. /// <summary>
  4688. /// 根据团组Id查询团组增减款项
  4689. /// </summary>
  4690. /// <param name="dto"></param>
  4691. /// <returns></returns>
  4692. [HttpPost]
  4693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4694. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4695. {
  4696. #region 参数验证
  4697. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4698. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4699. #endregion
  4700. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4701. }
  4702. /// <summary>
  4703. /// 团组增减款项操作(Status:1.新增,2.修改)
  4704. /// </summary>
  4705. /// <param name="dto"></param>
  4706. /// <returns></returns>
  4707. [HttpPost]
  4708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4709. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4710. {
  4711. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4712. if (groupData.Code != 200)
  4713. {
  4714. return Ok(JsonView(false, groupData.Msg));
  4715. }
  4716. #region 应用推送
  4717. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4718. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4719. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4720. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4721. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4722. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4723. //自动审核
  4724. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4725. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4726. //2024-10-21 新增LZ UID
  4727. var userIds = new List<int>() { 21 };
  4728. string title = $"系统通知";
  4729. string content = "";
  4730. var diId = dto.DiId;
  4731. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4732. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4733. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4734. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4735. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4736. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4737. #endregion
  4738. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4739. }
  4740. /// <summary>
  4741. /// 团组增减款项操作 删除
  4742. /// </summary>
  4743. /// <param name="dto"></param>
  4744. /// <returns></returns>
  4745. [HttpPost]
  4746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4747. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4748. {
  4749. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4750. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4751. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4752. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  4753. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  4754. }
  4755. /// <summary>
  4756. /// 根据团组增减款项Id查询
  4757. /// </summary>
  4758. /// <param name="dto"></param>
  4759. /// <returns></returns>
  4760. [HttpPost]
  4761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4762. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4763. {
  4764. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4765. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4766. }
  4767. /// <summary>
  4768. /// 查询供应商名称
  4769. /// </summary>
  4770. /// <param name="dto"></param>
  4771. /// <returns></returns>
  4772. [HttpPost]
  4773. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4774. {
  4775. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4776. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4777. ?? new List<Grp_DecreasePayments>();
  4778. dbResult = dbResult.Distinct(new
  4779. ProductComparer()).ToList();
  4780. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4781. {
  4782. x.Id,
  4783. x.SupplierAddress,
  4784. x.SupplierArea,
  4785. x.SupplierContact,
  4786. x.SupplierContactNumber,
  4787. x.SupplierEmail,
  4788. x.SupplierName,
  4789. x.SupplierSocialAccount,
  4790. x.SupplierTypeId,
  4791. }).ToList());
  4792. return Ok(jw);
  4793. }
  4794. /// <summary>
  4795. /// 团组增减款项 OTA匹配
  4796. /// </summary>
  4797. /// <param name="file"></param>
  4798. /// <returns></returns>
  4799. [HttpPost]
  4800. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4801. {
  4802. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4803. string fileName = file.FileName;
  4804. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4805. {
  4806. return Ok(JsonView(false, "请上传Excel文件!"));
  4807. }
  4808. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4809. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4810. if (!Directory.Exists(path))
  4811. {
  4812. Directory.CreateDirectory(path);
  4813. }
  4814. var filePath = @$"{path}/{fileName}";
  4815. //保存文件
  4816. using (FileStream fs = System.IO.File.Create(filePath))
  4817. {
  4818. file.CopyTo(fs);
  4819. fs.Flush();
  4820. }
  4821. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4822. //读取ExcelFile
  4823. DataTable dt = ConvertExcelToDataTable(filePath);
  4824. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4825. dt.TableName = "TB";
  4826. //修改table列名
  4827. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4828. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4829. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4830. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4831. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4832. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4833. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4834. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4835. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4836. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4837. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4838. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4839. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4840. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4841. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4842. var otaOrderNos = new List<string>();
  4843. foreach (DataRow item in dt.Rows)
  4844. {
  4845. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4846. }
  4847. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4848. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4849. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4850. .Select((dp, di) => new
  4851. {
  4852. dp.PriceName,
  4853. dp.OTAOrderNo,
  4854. dp.FeeTotal,
  4855. di.TeamName,
  4856. })
  4857. .ToListAsync();
  4858. foreach (DataRow item in dt.Rows)
  4859. {
  4860. var otaOrderNo = item["OTAOrderNo"].ToString();
  4861. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4862. if (oaData == null) continue;
  4863. item["GroupName"] = oaData.TeamName;
  4864. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4865. }
  4866. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  4867. var pairs = new Dictionary<string, object>();
  4868. var datas = new List<DataTable>
  4869. {
  4870. dt
  4871. };
  4872. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4873. return Ok(JsonView(true, "操作成功", new { url }));
  4874. }
  4875. #region
  4876. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  4877. {
  4878. // 创建Workbook对象
  4879. var workbook = new Workbook(excelFilePath);
  4880. // 获取第一个工作表
  4881. var worksheet = workbook.Worksheets[0];
  4882. // 将工作表转换为DataTable
  4883. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4884. return dataTable;
  4885. }
  4886. #endregion
  4887. /// <summary>
  4888. /// 世运会数据
  4889. /// </summary>
  4890. /// <returns></returns>
  4891. [HttpGet]
  4892. public IActionResult WorldGamesData()
  4893. {
  4894. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  4895. var groupMenu = setData.GroupBy(x => x.T0);
  4896. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  4897. foreach (var item in groupMenu)
  4898. {
  4899. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  4900. {
  4901. Data = new SetDataView
  4902. {
  4903. Name = item.Key
  4904. },
  4905. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  4906. });
  4907. }
  4908. return Ok(JsonView(true, "success", resultArr));
  4909. }
  4910. #endregion
  4911. #region 文件上传、删除
  4912. /// <summary>
  4913. /// region 文件上传 可以带参数
  4914. /// </summary>
  4915. /// <param name="file"></param>
  4916. /// <returns></returns>
  4917. [HttpPost]
  4918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4919. public async Task<IActionResult> UploadProject(IFormFile file)
  4920. {
  4921. //var TypeName = Request.Headers["TypeName"].ToString();
  4922. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4923. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4924. ////文件名称
  4925. //string projectFileName = file.FileName;
  4926. ////上传的文件的路径
  4927. //string filePath = $"{fileDir}/{projectFileName}";
  4928. //if (TypeName == "A")//A代表团组增减款项
  4929. //{
  4930. // filePath = fileDir + $@"\团组增减款项相关文件";
  4931. // if (!Directory.Exists(filePath))
  4932. // {
  4933. // Directory.CreateDirectory(filePath);
  4934. // }
  4935. // //上传的文件的路径
  4936. // filePath += $@"\{projectFileName}";
  4937. //}
  4938. //else if (TypeName == "B")//B代表商邀相关文件
  4939. //{
  4940. // //上传的文件的路径
  4941. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4942. // if (!Directory.Exists(filePath))
  4943. // {
  4944. // Directory.CreateDirectory(filePath);
  4945. // }
  4946. // //上传的文件的路径
  4947. // filePath = $@"\{projectFileName}";
  4948. //}
  4949. //try
  4950. //{
  4951. // using (FileStream fs = System.IO.File.Create(filePath))
  4952. // {
  4953. // file.CopyTo(fs);
  4954. // fs.Flush();
  4955. // }
  4956. //}
  4957. //catch (Exception ex)
  4958. //{
  4959. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4960. //}
  4961. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4962. try
  4963. {
  4964. var TypeName = Request.Headers["TypeName"].ToString();
  4965. if (file != null)
  4966. {
  4967. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4968. //文件名称
  4969. string projectFileName = file.FileName;
  4970. //上传的文件的路径
  4971. string filePath = $"{fileDir}/{projectFileName}";
  4972. if (TypeName == "A")//A代表团组增减款项
  4973. {
  4974. if (!Directory.Exists(fileDir))
  4975. {
  4976. Directory.CreateDirectory(fileDir);
  4977. }
  4978. //上传的文件的路径
  4979. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4980. }
  4981. else if (TypeName == "B")//B代表商邀相关文件
  4982. {
  4983. if (!Directory.Exists(fileDir))
  4984. {
  4985. Directory.CreateDirectory(fileDir);
  4986. }
  4987. //上传的文件的路径
  4988. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4989. }
  4990. using (FileStream fs = System.IO.File.Create(filePath))
  4991. {
  4992. file.CopyTo(fs);
  4993. fs.Flush();
  4994. }
  4995. return Ok(JsonView(true, "上传成功!", projectFileName));
  4996. }
  4997. else
  4998. {
  4999. return Ok(JsonView(false, "上传失败!"));
  5000. }
  5001. }
  5002. catch (Exception ex)
  5003. {
  5004. return Ok(JsonView(false, ex.Message));
  5005. }
  5006. }
  5007. /// <summary>
  5008. /// 删除指定文件
  5009. /// </summary>
  5010. /// <param name="dto"></param>
  5011. /// <returns></returns>
  5012. [HttpPost]
  5013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5014. public async Task<IActionResult> DelFile(DelFileDto dto)
  5015. {
  5016. try
  5017. {
  5018. var TypeName = Request.Headers["TypeName"].ToString();
  5019. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5020. string filePath = "";
  5021. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5022. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5023. int id = 0;
  5024. if (TypeName == "A")
  5025. {
  5026. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5027. // 删除该文件
  5028. System.IO.File.Delete(filePath);
  5029. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5030. .Where(a => a.Id == dto.Id)
  5031. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5032. .ExecuteCommandAsync();
  5033. }
  5034. else if (TypeName == "B")
  5035. {
  5036. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5037. // 删除该文件
  5038. System.IO.File.Delete(filePath);
  5039. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5040. if (info != null)
  5041. {
  5042. string[] files = Array.Empty<string>();
  5043. if (!string.IsNullOrEmpty(info.Attachment))
  5044. {
  5045. try
  5046. {
  5047. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5048. }
  5049. catch (Exception)
  5050. {
  5051. files = new List<string>() { info.Attachment }.ToArray();
  5052. }
  5053. }
  5054. if (files.Length > 0)
  5055. {
  5056. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5057. string filePath2 = string.Empty;
  5058. if (files1.Length > 0)
  5059. {
  5060. filePath2 = JsonConvert.SerializeObject(files1);
  5061. }
  5062. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5063. .Where(a => a.Id == dto.Id)
  5064. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5065. .ExecuteCommandAsync();
  5066. }
  5067. }
  5068. }
  5069. if (id != 0)
  5070. {
  5071. return Ok(JsonView(true, "成功!"));
  5072. }
  5073. else
  5074. {
  5075. return Ok(JsonView(false, "失败!"));
  5076. }
  5077. }
  5078. catch (Exception ex)
  5079. {
  5080. return Ok(JsonView(false, "程序错误!"));
  5081. throw;
  5082. }
  5083. }
  5084. /// <summary>
  5085. /// 文件上传多个文件 可以带参数
  5086. /// </summary>
  5087. /// <param name="files"></param>
  5088. /// <returns></returns>
  5089. [HttpPost]
  5090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5091. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5092. {
  5093. try
  5094. {
  5095. var TypeName = Request.Headers["TypeName"].ToString();
  5096. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5097. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5098. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5099. var filePahts = new List<string>();
  5100. foreach (var file in files)
  5101. {
  5102. //文件名称
  5103. string projectFileName = file.FileName;
  5104. //上传的文件的路径
  5105. string filePath = $"{fileDir}/{projectFileName}";
  5106. if (TypeName == "A")//A代表团组增减款项
  5107. {
  5108. if (!Directory.Exists(fileDir))
  5109. {
  5110. Directory.CreateDirectory(fileDir);
  5111. }
  5112. //上传的文件的路径
  5113. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5114. }
  5115. else if (TypeName == "B")//B代表商邀相关文件
  5116. {
  5117. if (!Directory.Exists(fileDir))
  5118. {
  5119. Directory.CreateDirectory(fileDir);
  5120. }
  5121. //上传的文件的路径
  5122. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5123. }
  5124. using (FileStream fs = System.IO.File.Create(filePath))
  5125. {
  5126. file.CopyTo(fs);
  5127. fs.Flush();
  5128. }
  5129. filePahts.Add(projectFileName);
  5130. }
  5131. return Ok(JsonView(true, "上传成功!", filePahts));
  5132. }
  5133. catch (Exception ex)
  5134. {
  5135. return Ok(JsonView(false, ex.Message));
  5136. }
  5137. }
  5138. #endregion
  5139. #region 商邀费用录入
  5140. /// <summary>
  5141. /// 根据团组Id查询商邀费用列表
  5142. /// </summary>
  5143. /// <param name="dto"></param>
  5144. /// <returns></returns>
  5145. [HttpPost]
  5146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5147. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5148. {
  5149. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5150. if (groupData.Code != 0)
  5151. {
  5152. return Ok(JsonView(false, groupData.Msg));
  5153. }
  5154. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5155. }
  5156. /// <summary>
  5157. /// 商邀费用列表
  5158. /// 下载文件
  5159. /// </summary>
  5160. /// <param name="id"></param>
  5161. /// <returns></returns>
  5162. [HttpGet("{id}")]
  5163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5164. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5165. {
  5166. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5167. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5168. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5169. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5170. var filePaths = new List<string>();
  5171. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5172. try
  5173. {
  5174. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5175. }
  5176. catch (Exception ex)
  5177. {
  5178. filePaths.Add(info.Attachment);
  5179. }
  5180. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5181. for (int i = 0; i < filePaths.Count; i++)
  5182. {
  5183. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5184. }
  5185. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5186. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5187. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5188. {
  5189. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5190. {
  5191. foreach (string filePath in filePaths)
  5192. {
  5193. if (System.IO.File.Exists(filePath))
  5194. {
  5195. // 获取文件名
  5196. string fileName = Path.GetFileName(filePath);
  5197. // 将文件添加到ZIP归档中
  5198. zipArchive.CreateEntryFromFile(filePath, fileName);
  5199. }
  5200. }
  5201. }
  5202. }
  5203. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5204. }
  5205. /// <summary>
  5206. /// 商邀费用 Info Page 基础数据源
  5207. /// </summary>
  5208. /// <returns></returns>
  5209. [HttpPost]
  5210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5211. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5212. {
  5213. try
  5214. {
  5215. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5216. if (groupData.Code != 0)
  5217. {
  5218. return Ok(JsonView(false, groupData.Msg));
  5219. }
  5220. return Ok(JsonView(true, "操作成功", groupData.Data));
  5221. }
  5222. catch (Exception ex)
  5223. {
  5224. return Ok(JsonView(false, ex.Message));
  5225. throw;
  5226. }
  5227. }
  5228. /// <summary>
  5229. /// 根据商邀费用ID查询C表和商邀费用数据
  5230. /// </summary>
  5231. /// <param name="dto"></param>
  5232. /// <returns></returns>
  5233. [HttpPost]
  5234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5235. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5236. {
  5237. try
  5238. {
  5239. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5240. if (groupData.Code != 0)
  5241. {
  5242. return Ok(JsonView(false, groupData.Msg));
  5243. }
  5244. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5245. }
  5246. catch (Exception ex)
  5247. {
  5248. return Ok(JsonView(false, ex.Message));
  5249. throw;
  5250. }
  5251. }
  5252. /// <summary>
  5253. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5254. /// </summary>
  5255. /// <param name="dto"></param>
  5256. /// <returns></returns>
  5257. [HttpPost]
  5258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5259. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5260. {
  5261. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5262. if (groupData.Code != 0)
  5263. {
  5264. return Ok(JsonView(false, groupData.Msg));
  5265. }
  5266. #region 应用推送
  5267. try
  5268. {
  5269. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5270. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5271. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5272. //2024-10-21 新增LZ UID
  5273. var userIds = new List<int>() { 21 };
  5274. string title = $"系统通知";
  5275. string content = "";
  5276. var diId = dto.DiId;
  5277. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5278. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5279. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5280. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5281. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5282. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5283. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5284. }
  5285. catch (Exception ex)
  5286. {
  5287. }
  5288. #endregion
  5289. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5290. }
  5291. /// <summary>
  5292. /// 商邀删除
  5293. /// </summary>
  5294. /// <param name="dto"></param>
  5295. /// <returns></returns>
  5296. [HttpPost]
  5297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5298. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5299. {
  5300. try
  5301. {
  5302. _sqlSugar.BeginTran();
  5303. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5304. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5305. {
  5306. IsDel = 1,
  5307. DeleteUserId = dto.DeleteUserId,
  5308. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5309. })
  5310. .Where(it => it.Id == dto.Id)
  5311. .ExecuteCommand();
  5312. if (res1 > 0)
  5313. {
  5314. int _diId = 0;
  5315. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5316. if (_ioaInfo != null)
  5317. {
  5318. _diId = _ioaInfo.DiId;
  5319. }
  5320. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5321. .SetColumns(a => new Grp_CreditCardPayment()
  5322. {
  5323. IsDel = 1,
  5324. DeleteUserId = dto.DeleteUserId,
  5325. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5326. })
  5327. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5328. .ExecuteCommand();
  5329. if (res2 > 0)
  5330. {
  5331. _sqlSugar.CommitTran();
  5332. return Ok(JsonView(true, "删除成功!"));
  5333. }
  5334. }
  5335. _sqlSugar.RollbackTran();
  5336. return Ok(JsonView(false, "删除失败"));
  5337. }
  5338. catch (Exception ex)
  5339. {
  5340. _sqlSugar.RollbackTran();
  5341. return Ok(JsonView(false, ex.Message));
  5342. }
  5343. }
  5344. #endregion
  5345. #region 票据上传
  5346. /// <summary>
  5347. /// 团组模块文件上传
  5348. /// </summary>
  5349. /// <param name="dto"></param>
  5350. /// <returns></returns>
  5351. [HttpPost]
  5352. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5353. {
  5354. var jw = JsonView(false);
  5355. long M = 1024 * 1024;
  5356. if (dto.Files == null || dto.Files.Count == 0)
  5357. {
  5358. jw.Msg = "无文件信息!";
  5359. return Ok(jw);
  5360. }
  5361. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5362. {
  5363. jw.Msg = "文件大小超过20M!";
  5364. return Ok(jw);
  5365. }
  5366. //var nameSp = dto.File.FileName.Split(".");
  5367. //if (nameSp.Length < 2)
  5368. //{
  5369. // jw.Msg = "拓展名称有误!";
  5370. // return Ok(jw);
  5371. //}
  5372. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5373. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5374. //{
  5375. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5376. // return Ok(jw);
  5377. //}
  5378. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5379. if (Ctable == null)
  5380. {
  5381. jw.Msg = "Ctable指向有误!";
  5382. return Ok(jw);
  5383. }
  5384. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5385. if (groupInfo == null)
  5386. {
  5387. jw.Msg = "团组信息不存在!";
  5388. return Ok(jw);
  5389. }
  5390. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5391. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5392. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5393. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5394. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5395. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5396. try
  5397. {
  5398. if (!Directory.Exists(fileBase))
  5399. {
  5400. Directory.CreateDirectory(fileBase);
  5401. }
  5402. var saveArr = new List<Grp_GroupModelFile>();
  5403. foreach (var fileStream in dto.Files)
  5404. {
  5405. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5406. var file = new Grp_GroupModelFile()
  5407. {
  5408. Cid = dto.Cid,
  5409. CreateTime = DateTime.Now,
  5410. CreateUserId = dto.Userid,
  5411. Ctable = dto.Ctable,
  5412. Diid = dto.Diid,
  5413. IsDel = 0,
  5414. FilePath = saveFilePath,
  5415. FileName = fileStream.FileName
  5416. };
  5417. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5418. {
  5419. fileStream.CopyTo(fs);
  5420. fs.Flush();
  5421. }
  5422. saveArr.Add(file);
  5423. }
  5424. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5425. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5426. jw = JsonView(true, "保存成功!", new
  5427. {
  5428. count = addResult,
  5429. filesName = saveArr.Select(x => x.FileName)
  5430. });
  5431. }
  5432. catch (Exception ex)
  5433. {
  5434. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5435. {
  5436. count = 0,
  5437. filesName = Array.Empty<string>(),
  5438. });
  5439. }
  5440. return Ok(jw);
  5441. }
  5442. /// <summary>
  5443. /// 查询各模块已保存文件
  5444. /// </summary>
  5445. /// <param name="dto"></param>
  5446. /// <returns></returns>
  5447. [HttpPost]
  5448. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5449. {
  5450. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5451. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5452. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5453. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5454. {
  5455. expression = Expressionable.Create<Grp_GroupModelFile>()
  5456. .And(x => visaIds.Contains(x.CreateUserId));
  5457. }
  5458. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5459. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5460. .Where(expression.ToExpression())
  5461. .ToList();
  5462. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5463. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5464. {
  5465. x.FileName,
  5466. x.Id,
  5467. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5468. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5469. })));
  5470. }
  5471. /// <summary>
  5472. /// 下载该团组下的所有文件
  5473. /// </summary>
  5474. /// <param name="dto"></param>
  5475. /// <returns></returns>
  5476. [HttpPost]
  5477. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5478. {
  5479. var jw = JsonView(false);
  5480. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5481. if (groupInfo == null)
  5482. {
  5483. jw.Msg = "团组信息不存在!";
  5484. return Ok(jw);
  5485. }
  5486. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5487. var isModule = Convert.ToBoolean(dto.isModule);
  5488. var Zips = new Dictionary<string, Stream>();
  5489. var io = new IOOperatorHelper();
  5490. if (isModule)
  5491. {
  5492. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5493. foreach (var moduleArr in moduleGroup)
  5494. {
  5495. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5496. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5497. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5498. var chiZips = new Dictionary<string, Stream>();
  5499. foreach (var item in moduleArr)
  5500. {
  5501. if (System.IO.File.Exists(item.FilePath))
  5502. {
  5503. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5504. {
  5505. byte[] bytes = new byte[fileStream.Length];
  5506. fileStream.Read(bytes, 0, bytes.Length);
  5507. fileStream.Close();
  5508. Stream stream = new MemoryStream(bytes);
  5509. chiZips.Add(item.FileName, stream);
  5510. }
  5511. }
  5512. }
  5513. if (chiZips.Count > 0)
  5514. {
  5515. var byts = io.ConvertZipStream(chiZips);
  5516. Stream stream = new MemoryStream(byts);
  5517. Zips.Add(key.Name + "_.zip", stream);
  5518. }
  5519. }
  5520. }
  5521. else
  5522. {
  5523. foreach (var item in dbQuery)
  5524. {
  5525. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5526. {
  5527. byte[] bytes = new byte[fileStream.Length];
  5528. fileStream.Read(bytes, 0, bytes.Length);
  5529. fileStream.Close();
  5530. var stream = new MemoryStream(bytes);
  5531. while (Zips.ContainsKey(item.FileName))
  5532. {
  5533. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5534. }
  5535. Zips.Add(item.FileName, stream);
  5536. }
  5537. }
  5538. }
  5539. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5540. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5541. if (Zips.Count > 0)
  5542. {
  5543. var byts = io.ConvertZipStream(Zips);
  5544. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5545. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5546. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5547. }
  5548. else
  5549. {
  5550. jw.Msg = "暂无生成文件!";
  5551. }
  5552. return Ok(jw);
  5553. }
  5554. /// <summary>
  5555. /// 下载该团组下此模块的所有文件
  5556. /// </summary>
  5557. /// <param name="dto"></param>
  5558. /// <returns></returns>
  5559. [HttpPost]
  5560. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5561. {
  5562. var jw = JsonView(false);
  5563. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5564. if (groupInfo == null)
  5565. {
  5566. jw.Msg = "团组信息不存在!";
  5567. return Ok(jw);
  5568. }
  5569. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5570. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5571. && x.IsDel == 0);
  5572. if (key == null)
  5573. {
  5574. jw.Msg = "Ctable指向错误!";
  5575. return Ok(jw);
  5576. }
  5577. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5578. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5579. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5580. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5581. var io = new IOOperatorHelper();
  5582. var Zips = new Dictionary<string, Stream>();
  5583. foreach (var item in dbQuery)
  5584. {
  5585. if (System.IO.File.Exists(item.FilePath))
  5586. {
  5587. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5588. {
  5589. byte[] bytes = new byte[fileStream.Length];
  5590. fileStream.Read(bytes, 0, bytes.Length);
  5591. fileStream.Close();
  5592. var stream = new MemoryStream(bytes);
  5593. while (Zips.ContainsKey(item.FileName))
  5594. {
  5595. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5596. }
  5597. Zips.Add(item.FileName, stream);
  5598. }
  5599. }
  5600. }
  5601. if (Zips.Count > 0)
  5602. {
  5603. var byts = io.ConvertZipStream(Zips);
  5604. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5605. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5606. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5607. }
  5608. else
  5609. {
  5610. jw.Msg = "暂无生成文件!";
  5611. }
  5612. return Ok(jw);
  5613. }
  5614. /// <summary>
  5615. /// 删除该团组下的指定文件
  5616. /// </summary>
  5617. /// <param name="dto"></param>
  5618. /// <returns></returns>
  5619. [HttpPost]
  5620. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5621. {
  5622. var jw = JsonView(false);
  5623. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5624. if (sing == null)
  5625. {
  5626. jw.Msg = "暂无";
  5627. return Ok(jw);
  5628. }
  5629. if (System.IO.File.Exists(sing.FilePath))
  5630. {
  5631. try
  5632. {
  5633. System.IO.File.Delete(sing.FilePath);
  5634. }
  5635. catch (Exception ex)
  5636. {
  5637. jw.Msg = "删除失败!" + ex.Message;
  5638. return Ok(jw);
  5639. }
  5640. }
  5641. sing.IsDel = 1;
  5642. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5643. sing.DeleteUserId = dto.UserId;
  5644. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5645. jw = JsonView(true, "删除成功!");
  5646. return Ok(jw);
  5647. }
  5648. #endregion
  5649. #region 共享文件上传
  5650. /// <summary>
  5651. /// 共享文件数据初始化
  5652. /// </summary>
  5653. /// <returns></returns>
  5654. [HttpGet]
  5655. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5656. {
  5657. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5658. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5659. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5660. .Select(x => x.Id)
  5661. .ToList()
  5662. .Contains(userid);
  5663. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5664. .Where(x => x.STid == 111 && x.IsDel == 0)
  5665. .Select(x => new
  5666. {
  5667. x.Name,
  5668. x.Id,
  5669. }).ToList();
  5670. if (isMarketingDepartment)
  5671. {
  5672. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5673. }
  5674. if (portType == 1)
  5675. {
  5676. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5677. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5678. .Where(x => x.IsDel == 0)
  5679. .OrderByDescending(x => x.VisitDate)
  5680. .Select(x => new
  5681. {
  5682. x.TeamName,
  5683. x.Id,
  5684. x.CityId,
  5685. })
  5686. .ToList()
  5687. .Select(x =>
  5688. {
  5689. var provinceId = x.CityId;
  5690. var isDefualtVal = true;
  5691. if (provinceId > 0)
  5692. {
  5693. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5694. if (parentId != null)
  5695. {
  5696. isDefualtVal = false;
  5697. provinceId = (int)parentId;
  5698. }
  5699. }
  5700. if (isDefualtVal)
  5701. {
  5702. provinceId = 122; //默认四川
  5703. }
  5704. return new
  5705. {
  5706. x.TeamName,
  5707. x.Id,
  5708. provinceId,
  5709. };
  5710. })
  5711. .ToList();
  5712. return Ok(JsonView(true, "SUCCESS!", new
  5713. {
  5714. dropDownType,
  5715. dropDownGroupList,
  5716. isMarketingDepartment
  5717. }));
  5718. }
  5719. else if (portType == 2 || portType == 3)
  5720. {
  5721. return Ok(JsonView(true, "SUCCESS!", new
  5722. {
  5723. dropDownType,
  5724. isMarketingDepartment
  5725. }));
  5726. }
  5727. else
  5728. {
  5729. return Ok(JsonView(false, "portType有误!"));
  5730. }
  5731. }
  5732. /// <summary>
  5733. /// 共享文件上传
  5734. /// </summary>
  5735. /// <param name="dto"></param>
  5736. /// <returns></returns>
  5737. [HttpPost]
  5738. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5739. {
  5740. var isGroup = new List<int> { 1412 };
  5741. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5742. {
  5743. return Ok(JsonView(false, "该文件需要关联团组!"));
  5744. }
  5745. if (dto.Files == null || dto.Files.Count == 0)
  5746. {
  5747. return Ok(JsonView(false, "无文件信息!"));
  5748. }
  5749. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5750. {
  5751. return Ok(JsonView(false, "文件大小超过20M!"));
  5752. }
  5753. if (dto.Userid < 1)
  5754. {
  5755. return Ok(JsonView(false, "请传入有效的Userid!"));
  5756. }
  5757. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5758. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5759. .Select((u, j) => new
  5760. {
  5761. u.CnName,
  5762. UserId = u.Id,
  5763. j.JobName,
  5764. })
  5765. .First();
  5766. if (jobInfo == null)
  5767. {
  5768. return Ok(JsonView(false, "请传入有效的Userid!"));
  5769. }
  5770. var commonFileExtensions = new List<string>
  5771. {
  5772. // 文本文件
  5773. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5774. // 图片文件
  5775. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5776. // 视频文件
  5777. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5778. // 音频文件
  5779. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5780. // 压缩文件
  5781. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5782. // 数据文件
  5783. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5784. };
  5785. try
  5786. {
  5787. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5788. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5789. commonFileExtensions.AddRange(settingExtend);
  5790. }
  5791. catch (Exception)
  5792. { }
  5793. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5794. if (setdata == null)
  5795. {
  5796. return Ok(JsonView(false, "请传入有效的FileType!"));
  5797. }
  5798. var insertList = new List<Grp_GroupShareFile>();
  5799. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5800. if (!Directory.Exists(winPath))
  5801. {
  5802. Directory.CreateDirectory(winPath);
  5803. }
  5804. foreach (var item in dto.Files)
  5805. {
  5806. var houzui = Path.GetExtension(item.FileName);
  5807. if (!commonFileExtensions.Contains(houzui))
  5808. {
  5809. return Ok(JsonView(false, "未知后缀名称!"));
  5810. }
  5811. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5812. var saveFilePath = winPath + fileName;
  5813. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5814. {
  5815. item.CopyTo(fs);
  5816. fs.Flush();
  5817. }
  5818. var fileDetail = new Grp_GroupShareFile()
  5819. {
  5820. CreateUserId = dto.Userid,
  5821. CreateTime = DateTime.Now,
  5822. UploadJob = jobInfo.JobName,
  5823. FileName = fileName,
  5824. FileType = dto.FileType,
  5825. Diid = dto.Diid,
  5826. FilePath = winPath + fileName,
  5827. };
  5828. insertList.Add(fileDetail);
  5829. }
  5830. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5831. return Ok(JsonView(true, "保存成功!"));
  5832. }
  5833. /// <summary>
  5834. /// 查询共享文件列表
  5835. /// </summary>
  5836. /// <param name="dto"></param>
  5837. /// <returns></returns>
  5838. [HttpPost]
  5839. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5840. {
  5841. var isGroup = new List<int> { 1412 };
  5842. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5843. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5844. .And(x => x.Diid == dto.Diid)
  5845. .And(x => x.FileType == dto.FileType)
  5846. .And(x => x.IsDel == 0)
  5847. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5848. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5849. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5850. int totalCount = 0;
  5851. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5852. .Where(queryExpression.ToExpression())
  5853. .OrderBy(x => x.UploadJob)
  5854. .Select(x => new
  5855. {
  5856. x.Id,
  5857. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5858. x.FileName,
  5859. x.FileType,
  5860. x.CreateTime,
  5861. })
  5862. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5863. return Ok(JsonView(true, "SUCCESS!", new
  5864. {
  5865. FileList = dbQuery,
  5866. dto.PageSize,
  5867. dto.PageIndex,
  5868. totalCount
  5869. }));
  5870. }
  5871. /// <summary>
  5872. /// 删除共享文件模块下的指定文件
  5873. /// </summary>
  5874. /// <param name="dto"></param>
  5875. /// <returns></returns>
  5876. [HttpPost]
  5877. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5878. {
  5879. var jw = JsonView(false);
  5880. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5881. if (sing == null)
  5882. {
  5883. jw.Msg = "暂无文件信息!";
  5884. return Ok(jw);
  5885. }
  5886. if (sing.CreateUserId != dto.UserId)
  5887. {
  5888. jw.Msg = "只能删除自己上传的文件!";
  5889. return Ok(jw);
  5890. }
  5891. if (System.IO.File.Exists(sing.FilePath))
  5892. {
  5893. try
  5894. {
  5895. System.IO.File.Delete(sing.FilePath);
  5896. }
  5897. catch (Exception ex)
  5898. {
  5899. jw.Msg = "删除失败!" + ex.Message;
  5900. return Ok(jw);
  5901. }
  5902. }
  5903. sing.IsDel = 1;
  5904. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5905. sing.DeleteUserId = dto.UserId;
  5906. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5907. jw = JsonView(true, "删除成功!");
  5908. return Ok(jw);
  5909. }
  5910. #endregion
  5911. #region 团组英文资料
  5912. /// <summary>
  5913. /// 查询团组英文所有资料
  5914. /// </summary>
  5915. /// <param name="dto"></param>
  5916. /// <returns></returns>
  5917. [HttpPost]
  5918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5919. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5920. {
  5921. try
  5922. {
  5923. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5924. if (groupData.Code != 0)
  5925. {
  5926. return Ok(JsonView(false, groupData.Msg));
  5927. }
  5928. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5929. }
  5930. catch (Exception ex)
  5931. {
  5932. return Ok(JsonView(false, ex.Message));
  5933. throw;
  5934. }
  5935. }
  5936. /// <summary>
  5937. /// 团组英文资料操作(Status:1.新增,2.修改)
  5938. /// </summary>
  5939. /// <param name="dto"></param>
  5940. /// <returns></returns>
  5941. [HttpPost]
  5942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5943. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5944. {
  5945. try
  5946. {
  5947. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5948. if (groupData.Code != 0)
  5949. {
  5950. return Ok(JsonView(false, groupData.Msg));
  5951. }
  5952. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5953. }
  5954. catch (Exception ex)
  5955. {
  5956. return Ok(JsonView(false, ex.Message));
  5957. throw;
  5958. }
  5959. }
  5960. /// <summary>
  5961. /// 团组英文资料Id查询数据
  5962. /// </summary>
  5963. /// <param name="dto"></param>
  5964. /// <returns></returns>
  5965. [HttpPost]
  5966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5967. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5968. {
  5969. try
  5970. {
  5971. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5972. if (_DelegationEnData != null)
  5973. {
  5974. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5975. }
  5976. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5977. }
  5978. catch (Exception ex)
  5979. {
  5980. return Ok(JsonView(false, "程序错误!"));
  5981. throw;
  5982. }
  5983. }
  5984. /// <summary>
  5985. /// 团组英文资料删除
  5986. /// </summary>
  5987. /// <param name="dto"></param>
  5988. /// <returns></returns>
  5989. [HttpPost]
  5990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5991. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5992. {
  5993. try
  5994. {
  5995. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5996. if (!res)
  5997. {
  5998. return Ok(JsonView(false, "删除失败"));
  5999. }
  6000. return Ok(JsonView(true, "删除成功!"));
  6001. }
  6002. catch (Exception ex)
  6003. {
  6004. return Ok(JsonView(false, ex.Message));
  6005. throw;
  6006. }
  6007. }
  6008. #endregion
  6009. #region 导出邀请函
  6010. /// <summary>
  6011. /// 导出邀请函页面初始化
  6012. /// </summary>
  6013. /// <param name="dto"></param>
  6014. /// <returns></returns>
  6015. [HttpPost]
  6016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6017. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6018. {
  6019. try
  6020. {
  6021. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6022. var crm_Deles = new List<Crm_DeleClient>();
  6023. if (dto.DiId == 0)
  6024. {
  6025. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6026. }
  6027. else
  6028. {
  6029. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6030. }
  6031. return Ok(JsonView(true, "查询成功!", new
  6032. {
  6033. deleClient = crm_Deles,
  6034. delegations = grp_Delegations
  6035. }));
  6036. }
  6037. catch (Exception ex)
  6038. {
  6039. return Ok(JsonView(false, "程序错误!"));
  6040. throw;
  6041. }
  6042. }
  6043. /// <summary>
  6044. /// 导出邀请函
  6045. /// </summary>
  6046. /// <param name="dto"></param>
  6047. /// <returns></returns>
  6048. [HttpPost]
  6049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6050. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6051. {
  6052. #region 参数验证
  6053. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6054. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6055. #endregion
  6056. try
  6057. {
  6058. var transDic = new Dictionary<string, string>();
  6059. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6060. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6061. From Grp_TourClientList tcl
  6062. Left Join
  6063. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6064. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6065. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6066. From Crm_DeleClient dc
  6067. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6068. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6069. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6070. Where dc.IsDel = 0) temp
  6071. On temp.DcId =tcl.ClientId
  6072. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6073. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6074. var texts = new List<string>();
  6075. if (datas.Count != 0)
  6076. {
  6077. foreach (TourClientListDetailsView item in datas)
  6078. {
  6079. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6080. {
  6081. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6082. }
  6083. else
  6084. {
  6085. string name = item.LastName + item.FirstName;
  6086. texts.Add(name);
  6087. }
  6088. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6089. {
  6090. if (!transDic.ContainsKey(item.Job))
  6091. {
  6092. texts.Add(item.Job);
  6093. }
  6094. }
  6095. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6096. {
  6097. texts.Add(item.CompanyFullName);
  6098. }
  6099. }
  6100. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6101. if (transData.Count > 0)
  6102. {
  6103. foreach (TranslateResult item in transData)
  6104. {
  6105. if (!transDic.ContainsKey(item.Query))
  6106. {
  6107. transDic.Add(item.Query, item.Translation);
  6108. }
  6109. }
  6110. }
  6111. var list = new List<GuestList>();
  6112. foreach (var dele in datas)
  6113. {
  6114. var guestList = new GuestList();
  6115. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6116. {
  6117. guestList.Name = dele.Pinyin;
  6118. }
  6119. else
  6120. {
  6121. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6122. guestList.Name = Name;
  6123. }
  6124. if (dele.Sex == 0)
  6125. {
  6126. guestList.Sex = "Male";
  6127. }
  6128. else if (dele.Sex == 1)
  6129. {
  6130. guestList.Sex = "Female";
  6131. }
  6132. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6133. if (!string.IsNullOrEmpty(dele.Job))
  6134. {
  6135. guestList.Job = dele.Job;
  6136. }
  6137. list.Add(guestList);
  6138. }
  6139. //载入模板
  6140. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6141. var builder = new DocumentBuilder(doc);
  6142. //获取word里所有表格
  6143. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6144. //获取所填表格的序数
  6145. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6146. var rowStart = tableOne.Rows[0]; //获取第1行
  6147. //循环赋值
  6148. for (int i = 0; i < list.Count; i++)
  6149. {
  6150. builder.MoveToCell(0, i + 1, 0, 0);
  6151. builder.Write(list[i].Name.ToString());
  6152. builder.MoveToCell(0, i + 1, 1, 0);
  6153. builder.Write(list[i].Sex.ToString());
  6154. builder.MoveToCell(0, i + 1, 2, 0);
  6155. builder.Write(list[i].DOB.ToString());
  6156. builder.MoveToCell(0, i + 1, 3, 0);
  6157. builder.Write(list[i].Job.ToString());
  6158. }
  6159. //删除多余行
  6160. while (tableOne.Rows.Count > list.Count + 1)
  6161. {
  6162. tableOne.Rows.RemoveAt(list.Count + 1);
  6163. }
  6164. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6165. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6166. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6167. doc.Save(filePath);
  6168. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6169. return Ok(JsonView(true, "操作成功!", Url));
  6170. }
  6171. else
  6172. {
  6173. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6174. }
  6175. }
  6176. catch (Exception ex)
  6177. {
  6178. return Ok(JsonView(false, ex.Message));
  6179. throw;
  6180. }
  6181. }
  6182. #endregion
  6183. #region 团组经理模块 出入境费用
  6184. /// <summary>
  6185. /// 团组模块 - 出入境费用 - 省份基础数据源
  6186. /// </summary>
  6187. /// <returns></returns>
  6188. [HttpGet]
  6189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6190. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6191. {
  6192. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6193. }
  6194. /// <summary>
  6195. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6196. /// </summary>
  6197. /// <param name="dto"></param>
  6198. /// <returns></returns>
  6199. [HttpPost]
  6200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6201. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6202. {
  6203. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6204. var groupNamFirst = groupNameData.FirstOrDefault();
  6205. //SetDataInfoView
  6206. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6207. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6208. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6209. //验证城市归属并给默认值
  6210. int provinceId = 122;
  6211. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6212. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6213. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6214. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6215. return Ok(JsonView(true, "查询成功!", new
  6216. {
  6217. GroupNameData = groupNameData,
  6218. CurrencyData = _CurrencyData,
  6219. WordTypeData = wordTypeData,
  6220. ExcelTypeData = excelTypeData,
  6221. CurrencyInit = _currencyInfos,
  6222. ViewPermissionData = viewPermissionData
  6223. }));
  6224. }
  6225. /// <summary>
  6226. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6227. /// </summary>
  6228. /// <returns></returns>
  6229. [HttpGet("{provinceId}")]
  6230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6231. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6232. {
  6233. //验证城市归属并给默认值
  6234. if (provinceId < 1) provinceId = 122;
  6235. /*
  6236. * 122 四川
  6237. * 108 贵州
  6238. * 103 重庆
  6239. * 132 云南
  6240. */
  6241. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6242. return Ok(JsonView(true, "查询成功!", new
  6243. {
  6244. WordTypeData = wordTypeData,
  6245. ExcelTypeData = excelTypeData,
  6246. }));
  6247. }
  6248. /// <summary>
  6249. /// 团组模块 - 出入境费用
  6250. /// 实时汇率 tips
  6251. /// 签证费用 tips
  6252. /// 机票费用 tips
  6253. /// </summary>
  6254. /// <returns></returns>
  6255. [HttpPost]
  6256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6257. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6258. {
  6259. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6260. //默认币种显示
  6261. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6262. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6263. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6264. return Ok(JsonView(true, "查询成功!", new
  6265. {
  6266. //GroupNameData = groupNameData.Data,
  6267. visaData = visaData.Data,
  6268. airData,
  6269. reteInfos
  6270. }));
  6271. }
  6272. /// <summary>
  6273. /// 团组模块 - 出入境费用 - Info
  6274. /// </summary>
  6275. /// <param name="dto"></param>
  6276. /// <returns></returns>
  6277. [HttpPost]
  6278. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6280. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6281. {
  6282. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6283. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6284. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6285. }
  6286. /// <summary>
  6287. /// 团组模块 - 出入境费用 - 设置view权限
  6288. /// </summary>
  6289. /// <returns></returns>
  6290. [HttpPost]
  6291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6292. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6293. {
  6294. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6295. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6296. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6297. var permissions = new List<Grp_EnterExitCostPermission>();
  6298. foreach (var userId in dto.UserIds)
  6299. {
  6300. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6301. }
  6302. if (permissions.Any())
  6303. {
  6304. _sqlSugar.BeginTran();
  6305. try
  6306. {
  6307. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6308. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6309. if (result < 1)
  6310. {
  6311. _sqlSugar.RollbackTran();
  6312. return Ok(JsonView(false));
  6313. }
  6314. }
  6315. catch (Exception ex)
  6316. {
  6317. _sqlSugar.RollbackTran();
  6318. return Ok(JsonView(false, ex.Message));
  6319. }
  6320. _sqlSugar.CommitTran();
  6321. return Ok(JsonView(true));
  6322. }
  6323. return Ok(JsonView(false));
  6324. }
  6325. /// <summary>
  6326. /// 团组模块 - 出入境费用 - Add And Update
  6327. /// </summary>
  6328. /// <returns></returns>
  6329. [HttpPost]
  6330. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6332. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6333. {
  6334. try
  6335. {
  6336. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6337. if (dto.DayOtherPriceData.Any())
  6338. {
  6339. var inserList = dto.DayOtherPriceData
  6340. .Where(x => x.Id == 0)
  6341. .Select(x => new Grp_DayOtherPrice
  6342. {
  6343. Cost = x.Cost,
  6344. Id = x.Id,
  6345. CreateTime = DateTime.Now,
  6346. CreateUserId = dto.UserId,
  6347. Currency = x.Currency,
  6348. Diid = x.DiId,
  6349. Index = x.Index,
  6350. IsDel = 0,
  6351. SetDataId = x.SetDataId,
  6352. SubTotal = x.SubTotal,
  6353. Remark = x.Remark
  6354. })
  6355. .ToList();
  6356. var updateList = dto.DayOtherPriceData
  6357. .Where(x => x.Id != 0)
  6358. .Select(x => new Grp_DayOtherPrice
  6359. {
  6360. Cost = x.Cost,
  6361. Id = x.Id,
  6362. CreateTime = DateTime.Now,
  6363. CreateUserId = dto.UserId,
  6364. Currency = x.Currency,
  6365. Diid = x.DiId,
  6366. Index = x.Index,
  6367. IsDel = 0,
  6368. SetDataId = x.SetDataId,
  6369. SubTotal = x.SubTotal,
  6370. Remark = x.Remark
  6371. })
  6372. .ToList();
  6373. //添加
  6374. _sqlSugar.BeginTran();
  6375. if (inserList.Any())
  6376. {
  6377. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6378. }
  6379. if (updateList.Any())
  6380. {
  6381. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6382. }
  6383. _sqlSugar.CommitTran();
  6384. }
  6385. if (data.Code != 0)
  6386. {
  6387. return Ok(JsonView(false, data.Msg));
  6388. }
  6389. //生成默认文件pdf并且通知人员
  6390. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6391. {
  6392. DiId = dto.DiId,
  6393. ExportType = 1,
  6394. SubTypeId = 1005
  6395. }, "pdf");
  6396. //发送通知
  6397. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6398. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6399. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6400. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6401. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6402. //汇率信息记录
  6403. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6404. return Ok(JsonView(true, data.Msg, data.Data));
  6405. }
  6406. catch (Exception ex)
  6407. {
  6408. return Ok(JsonView(false, ex.Message));
  6409. }
  6410. }
  6411. /// <summary>
  6412. /// 团组模块 - 出入境费用 - Confirm 费用
  6413. /// </summary>
  6414. /// <returns></returns>
  6415. [HttpPost]
  6416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6417. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6418. {
  6419. //TODO:测试完毕需把对应的用户ID更改
  6420. //1、数据表添加字段
  6421. //2、更改字段接口()
  6422. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6423. //3、确认成功 给财务发送消息
  6424. if (_view.Code == 200)
  6425. {
  6426. if (dto.Type == 1)
  6427. {
  6428. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6429. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6430. }
  6431. }
  6432. return Ok(_view);
  6433. }
  6434. /// <summary>
  6435. /// 团组模块 - 出入境费用 - File download
  6436. /// </summary>
  6437. /// <param name="dto"></param>
  6438. /// <returns></returns>
  6439. [HttpPost]
  6440. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6442. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6443. {
  6444. try
  6445. {
  6446. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6447. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6448. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6449. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6450. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6451. 3 团组成员名单 1 团组成员名单", ""));
  6452. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6453. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6454. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6455. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6456. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6457. //数据源
  6458. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6459. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6460. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6461. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6462. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6463. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6464. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6465. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6466. .Select((x, a, b) => new
  6467. {
  6468. x.Index,
  6469. itemName = a.Name,
  6470. CurrencyStr = b.Name,
  6471. x.Cost,
  6472. x.SubTotal,
  6473. x.Remark
  6474. })
  6475. .OrderBy((x) => x.Index)
  6476. .ToList(); //其他款项费用
  6477. var peiceItemCurrencys = new List<string>();
  6478. if (_DayAndCosts.Any())
  6479. {
  6480. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6481. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6482. }
  6483. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6484. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6485. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6486. {
  6487. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6488. }
  6489. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6490. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6491. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6492. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6493. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6494. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6495. .Select((tcl, dc, cc) => new ClientInfo
  6496. {
  6497. LastName = dc.LastName,
  6498. FirstName = dc.FirstName,
  6499. Sex = dc.Sex,
  6500. Birthday = dc.BirthDay,
  6501. Company = cc.CompanyFullName,
  6502. Job = dc.Job
  6503. })
  6504. .ToList();
  6505. foreach (var item in DeleClientList)
  6506. {
  6507. EncryptionProcessor.DecryptProperties(item);
  6508. }
  6509. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6510. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6511. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6512. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6513. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6514. if (dto.ExportType == 1) //明细表
  6515. {
  6516. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6517. {
  6518. //获取模板
  6519. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6520. //载入模板
  6521. var doc = new Document(tempPath);
  6522. var builder = new DocumentBuilder(doc);
  6523. var dic = new Dictionary<string, string>();
  6524. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6525. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6526. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6527. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6528. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6529. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6530. //境内费用(其他费用)
  6531. if (_EnterExitCosts.ChoiceOne == 1)
  6532. {
  6533. string row1_1 = "";
  6534. if (_EnterExitCosts.Visa > 0)
  6535. {
  6536. //insidePayTotal += _EnterExitCosts.Visa;
  6537. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 人民币/人";
  6538. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6539. //{
  6540. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6541. //}
  6542. }
  6543. string row1_2 = "";
  6544. if (_EnterExitCosts.YiMiao > 0)
  6545. {
  6546. //insidePayTotal += _EnterExitCosts.YiMiao;
  6547. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 人民币/人";
  6548. }
  6549. if (_EnterExitCosts.HeSuan > 0)
  6550. {
  6551. //insidePayTotal += _EnterExitCosts.HeSuan;
  6552. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 人民币/人";
  6553. }
  6554. if (_EnterExitCosts.Service > 0)
  6555. {
  6556. //insidePayTotal += _EnterExitCosts.Service;
  6557. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 人民币/人";
  6558. }
  6559. string row1_3 = "";
  6560. if (_EnterExitCosts.Safe > 0)
  6561. {
  6562. //insidePayTotal += _EnterExitCosts.Safe;
  6563. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 人民币/人";
  6564. }
  6565. if (_EnterExitCosts.Ticket > 0)
  6566. {
  6567. //insidePayTotal += _EnterExitCosts.Ticket;
  6568. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 人民币/人";
  6569. }
  6570. string row1 = "";
  6571. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6572. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6573. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6574. row1 += $"备注:{_EnterExitCosts.Remark}";
  6575. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6576. dic.Add("Row1Str", row1);
  6577. }
  6578. string airTotalStr = string.Empty,
  6579. airPriceStr = string.Empty;
  6580. //经济舱
  6581. if (_EnterExitCosts.SumJJC == 1)
  6582. {
  6583. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  6584. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  6585. }
  6586. //公务舱
  6587. if (_EnterExitCosts.SumGWC == 1)
  6588. {
  6589. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  6590. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  6591. }
  6592. //头等舱
  6593. if (_EnterExitCosts.SumTDC == 1)
  6594. {
  6595. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  6596. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  6597. }
  6598. //汇率描述
  6599. string rateStr = "";
  6600. if (peiceItemCurrencyInfos.Any())
  6601. {
  6602. rateStr = "\r\n汇率描述:";
  6603. foreach (var item in peiceItemCurrencyInfos)
  6604. {
  6605. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  6606. }
  6607. }
  6608. string twoItemRemark = "备注:";
  6609. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6610. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6611. dic.Add("AirTotalStr", airTotalStr);
  6612. dic.Add("AirPriceStr", airPriceStr);
  6613. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6614. dic.Add("TwoItemRemark", twoItemRemark);
  6615. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6616. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6617. int table1Row = 0,
  6618. table2Row = 0,
  6619. table3Row = 0,
  6620. table4Row = 0,
  6621. table5Row = 0;
  6622. //住宿费
  6623. if (_EnterExitCosts.ChoiceThree == 1)
  6624. {
  6625. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6626. table1Row = dac1.Count;
  6627. #region 填充word表格内容
  6628. for (int i = 0; i < dac1.Count; i++)
  6629. {
  6630. Grp_DayAndCost dac = dac1[i];
  6631. if (dac == null) continue;
  6632. builder.MoveToCell(0, i, 0, 0);
  6633. builder.Write("第" + dac.Days.ToString() + "晚:");
  6634. builder.MoveToCell(0, i, 1, 0);
  6635. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6636. //builder.Write(dac.Place == null ? "" : dac.Place);
  6637. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6638. builder.MoveToCell(0, i, 2, 0);
  6639. builder.Write("费用标准:");
  6640. string curr = "";
  6641. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6642. if (currData != null)
  6643. {
  6644. curr = currData.Name;
  6645. }
  6646. builder.MoveToCell(0, i, 3, 0);
  6647. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6648. builder.MoveToCell(0, i, 4, 0);
  6649. builder.Write("费用小计:");
  6650. builder.MoveToCell(0, i, 5, 0);
  6651. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6652. }
  6653. #endregion
  6654. }
  6655. else dic.Add("SubZS", "0.00");
  6656. //删除多余行
  6657. while (table1.Rows.Count > table1Row)
  6658. {
  6659. table1.Rows.RemoveAt(table1Row);
  6660. }
  6661. //伙食费
  6662. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6663. if (_EnterExitCosts.ChoiceFour == 1)
  6664. {
  6665. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6666. table2Row = dac2.Count;
  6667. #region 填充word表格内容
  6668. for (int i = 0; i < dac2.Count; i++)
  6669. {
  6670. Grp_DayAndCost dac = dac2[i];
  6671. if (dac == null) continue;
  6672. builder.MoveToCell(1, i, 0, 0);
  6673. builder.Write("第" + dac.Days.ToString() + "天:");
  6674. builder.MoveToCell(1, i, 1, 0);
  6675. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6676. builder.MoveToCell(1, i, 2, 0);
  6677. builder.Write("费用标准:");
  6678. string curr = "";
  6679. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6680. if (currData != null)
  6681. {
  6682. curr = currData.Name;
  6683. }
  6684. builder.MoveToCell(1, i, 3, 0);
  6685. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6686. builder.MoveToCell(1, i, 4, 0);
  6687. builder.Write("费用小计:");
  6688. builder.MoveToCell(1, i, 5, 0);
  6689. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6690. }
  6691. #endregion
  6692. }
  6693. else dic.Add("SubHS", "0.00");
  6694. //删除多余行
  6695. while (table2.Rows.Count > table2Row)
  6696. {
  6697. table2.Rows.RemoveAt(table2Row);
  6698. }
  6699. //公杂费
  6700. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6701. if (_EnterExitCosts.ChoiceFive == 1)
  6702. {
  6703. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6704. table3Row = dac3.Count;
  6705. #region 填充word表格内容
  6706. for (int i = 0; i < dac3.Count; i++)
  6707. {
  6708. Grp_DayAndCost dac = dac3[i];
  6709. if (dac == null) continue;
  6710. builder.MoveToCell(2, i, 0, 0);
  6711. builder.Write("第" + dac.Days.ToString() + "天:");
  6712. builder.MoveToCell(2, i, 1, 0);
  6713. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6714. builder.MoveToCell(2, i, 2, 0);
  6715. builder.Write("费用标准:");
  6716. string curr = "";
  6717. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6718. if (currData != null)
  6719. {
  6720. curr = currData.Name;
  6721. }
  6722. builder.MoveToCell(2, i, 3, 0);
  6723. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6724. builder.MoveToCell(2, i, 4, 0);
  6725. builder.Write("费用小计:");
  6726. builder.MoveToCell(2, i, 5, 0);
  6727. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6728. }
  6729. //删除多余行
  6730. while (table3.Rows.Count > table3Row)
  6731. {
  6732. table3.Rows.RemoveAt(table3Row);
  6733. }
  6734. #endregion
  6735. }
  6736. else dic.Add("SubGZF", "0.00");
  6737. //删除多余行
  6738. while (table3.Rows.Count > table3Row)
  6739. {
  6740. table3.Rows.RemoveAt(table3Row);
  6741. }
  6742. //培训费
  6743. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6744. if (_EnterExitCosts.ChoiceSix == 1)
  6745. {
  6746. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  6747. dic.Add("SubPX", pxStr);
  6748. table4Row = dac4.Count;
  6749. #region 填充word表格内容
  6750. for (int i = 0; i < dac4.Count; i++)
  6751. {
  6752. Grp_DayAndCost dac = dac4[i];
  6753. if (dac == null) continue;
  6754. builder.MoveToCell(3, i, 0, 0);
  6755. builder.Write("第" + dac.Days.ToString() + "天:");
  6756. builder.MoveToCell(3, i, 1, 0);
  6757. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6758. builder.MoveToCell(3, i, 2, 0);
  6759. builder.Write("费用标准:");
  6760. string curr = "";
  6761. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6762. if (currData != null)
  6763. {
  6764. curr = currData.Name;
  6765. }
  6766. builder.MoveToCell(3, i, 3, 0);
  6767. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6768. builder.MoveToCell(3, i, 4, 0);
  6769. builder.Write("费用小计:");
  6770. builder.MoveToCell(3, i, 5, 0);
  6771. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6772. }
  6773. #endregion
  6774. }
  6775. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6776. //删除多余行
  6777. while (table4.Rows.Count > table4Row)
  6778. {
  6779. table4.Rows.RemoveAt(table4Row);
  6780. }
  6781. //其他费用
  6782. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6783. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6784. {
  6785. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  6786. dic.Add("titleQi", qtStr);
  6787. table5Row = dac5.Count;
  6788. #region 填充word表格内容
  6789. for (int i = 0; i < dac5.Count; i++)
  6790. {
  6791. var dac = dac5[i];
  6792. if (dac == null) continue;
  6793. builder.MoveToCell(4, i, 0, 0);
  6794. builder.Write("第" + dac.Index.ToString() + "项:");
  6795. builder.MoveToCell(4, i, 1, 0);
  6796. builder.Write(dac.itemName);
  6797. builder.MoveToCell(4, i, 2, 0);
  6798. builder.Write("费用标准:");
  6799. builder.MoveToCell(4, i, 3, 0);
  6800. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6801. builder.MoveToCell(4, i, 4, 0);
  6802. builder.Write("费用小计:");
  6803. builder.MoveToCell(4, i, 5, 0);
  6804. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6805. builder.MoveToCell(4, i, 6, 0);
  6806. builder.Write("备注:");
  6807. builder.MoveToCell(4, i, 7, 0);
  6808. builder.Write(dac.Remark);
  6809. }
  6810. #endregion
  6811. }
  6812. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6813. //删除多余行
  6814. while (table5.Rows.Count > table5Row)
  6815. {
  6816. table5.Rows.RemoveAt(table5Row);
  6817. }
  6818. //加上其他费用
  6819. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6820. decimal subJJC = 0.00M,
  6821. subGWC = 0.00M,
  6822. subTDC = 0.00M;
  6823. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6824. string totalLabel = string.Format("全部费用总计:");
  6825. //经济舱
  6826. if (_EnterExitCosts.SumJJC == 1)
  6827. {
  6828. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6829. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  6830. }
  6831. //公务舱
  6832. if (_EnterExitCosts.SumGWC == 1)
  6833. {
  6834. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6835. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  6836. }
  6837. //头等舱
  6838. if (_EnterExitCosts.SumTDC == 1)
  6839. {
  6840. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6841. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  6842. }
  6843. //TotalLabel
  6844. dic.Add("TotalLabel", totalLabel);
  6845. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6846. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6847. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6848. #region 填充word模板书签内容
  6849. foreach (var key in dic.Keys)
  6850. {
  6851. Bookmark bookmark = doc.Range.Bookmarks[key];
  6852. if (bookmark != null)
  6853. {
  6854. builder.MoveToBookmark(key);
  6855. builder.Write(dic[key]);
  6856. }
  6857. }
  6858. #endregion
  6859. #region 设置页眉
  6860. string userLabel = string.Empty;
  6861. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6862. if (currUserInfo != null)
  6863. {
  6864. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6865. if (userInfo != null)
  6866. {
  6867. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6868. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6869. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6870. }
  6871. }
  6872. //设置页脚
  6873. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6874. #endregion
  6875. //文件名
  6876. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6877. AsposeHelper.removewatermark_v2180();
  6878. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6879. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6880. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6881. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6882. }
  6883. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6884. {
  6885. //获取模板
  6886. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6887. //载入模板
  6888. var doc = new Document(tempPath);
  6889. var builder = new DocumentBuilder(doc);
  6890. var dic = new Dictionary<string, string>();
  6891. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6892. {
  6893. var list = new List<string>();
  6894. try
  6895. {
  6896. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6897. foreach (var item in spilitArr)
  6898. {
  6899. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6900. var depCode = spDotandEmpty[2].Substring(0, 3);
  6901. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6902. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6903. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6904. list.Add(depName);
  6905. list.Add(arrName);
  6906. }
  6907. list = list.Distinct().ToList();
  6908. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6909. }
  6910. catch (Exception)
  6911. {
  6912. dic.Add("ReturnCode", "行程录入不正确!");
  6913. }
  6914. }
  6915. else
  6916. {
  6917. dic.Add("ReturnCode", "未录入行程!");
  6918. }
  6919. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6920. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6921. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6922. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6923. {
  6924. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6925. dic.Add("Day", sp.Days.ToString());
  6926. }
  6927. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6928. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6929. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6930. //dic.Add("Names", Names);
  6931. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6932. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6933. decimal dac1totalPrice = 0.00M;
  6934. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6935. foreach (var dac in dac1)
  6936. {
  6937. if (dac.SubTotal == 0.00M)
  6938. {
  6939. continue;
  6940. }
  6941. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6942. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6943. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6944. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6945. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6946. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6947. builder.Write(currency);//币种
  6948. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6949. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6950. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6951. builder.Write("");//人数
  6952. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6953. builder.Write("");//天数
  6954. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6955. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6956. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6957. decimal rate = 0.00M;
  6958. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6959. builder.Write(rate.ToString("#0.0000"));//汇率
  6960. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6961. decimal rbmPrice = dac.SubTotal;
  6962. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6963. accommodationStartIndex++;
  6964. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6965. }
  6966. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6967. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6968. {
  6969. table1.Rows.RemoveAt(i - 1);
  6970. foodandotherStartIndex--;
  6971. }
  6972. if (dac2.Count == dac3.Count)//国家 币种 金额
  6973. {
  6974. for (int i = 0; i < dac2.Count; i++)
  6975. {
  6976. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6977. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6978. }
  6979. }
  6980. decimal dac2totalPrice = 0.00M;
  6981. foreach (var dac in dac2)
  6982. {
  6983. if (dac.SubTotal == 0)
  6984. {
  6985. continue;
  6986. }
  6987. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6988. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6989. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6990. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6991. builder.Write(currency);//币种
  6992. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6993. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6994. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6995. builder.Write("");//人数
  6996. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6997. builder.Write("");//天数
  6998. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6999. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7000. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7001. decimal rate = 0.00M;
  7002. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7003. builder.Write(rate.ToString("#0.0000"));//汇率
  7004. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7005. decimal rbmPrice = dac.SubTotal;
  7006. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7007. foodandotherStartIndex++;
  7008. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7009. }
  7010. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7011. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7012. {
  7013. table1.Rows.RemoveAt(i - 1);
  7014. }
  7015. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7016. string otherFeeStr = "";
  7017. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7018. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7019. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7020. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7021. foreach (var otherInfo in dac5)
  7022. {
  7023. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7024. }
  7025. #endregion
  7026. if (otherFeeStr.Length > 0)
  7027. {
  7028. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7029. otherFeeStr = $"({otherFeeStr})";
  7030. dic.Add("OtherFeeStr", otherFeeStr);
  7031. }
  7032. //总计
  7033. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7034. //国际旅费
  7035. string outsideAir = string.Empty;
  7036. string allPriceAir = string.Empty;
  7037. if (_EnterExitCosts.SumJJC == 1)
  7038. {
  7039. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7040. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7041. }
  7042. if (_EnterExitCosts.SumGWC == 1)
  7043. {
  7044. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7045. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7046. }
  7047. if (_EnterExitCosts.SumTDC == 1)
  7048. {
  7049. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7050. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7051. }
  7052. dic.Add("InTravelPrice", $"({outsideAir})");
  7053. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7054. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7055. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7056. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7057. foreach (var key in dic.Keys)
  7058. {
  7059. builder.MoveToBookmark(key);
  7060. builder.Write(dic[key]);
  7061. }
  7062. //模板文件名
  7063. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7064. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7065. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7066. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7067. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7068. }
  7069. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7070. {
  7071. //获取模板
  7072. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7073. //载入模板
  7074. var designer = new WorkbookDesigner
  7075. {
  7076. Workbook = new Workbook(tempPath)
  7077. };
  7078. var dic = new Dictionary<string, string>();
  7079. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7080. {
  7081. var list = new List<string>();
  7082. try
  7083. {
  7084. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7085. foreach (var item in spilitArr)
  7086. {
  7087. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7088. var depCode = spDotandEmpty[2].Substring(0, 3);
  7089. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7090. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7091. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7092. list.Add(depName);
  7093. list.Add(arrName);
  7094. }
  7095. list = list.Distinct().ToList();
  7096. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7097. }
  7098. catch (Exception)
  7099. {
  7100. dic.Add("ReturnCode", "行程录入不正确!");
  7101. }
  7102. }
  7103. else
  7104. {
  7105. dic.Add("ReturnCode", "未录入行程!");
  7106. }
  7107. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7108. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7109. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7110. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7111. {
  7112. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7113. dic.Add("Day", sp.Days.ToString());
  7114. }
  7115. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7116. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7117. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7118. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7119. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7120. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7121. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7122. designer.SetDataSource("Name", Names);
  7123. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7124. designer.SetDataSource("Day", dic["Day"] + "天");
  7125. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7126. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7127. int startIndex = 10;
  7128. const int startIndexcopy = 10;
  7129. if (dac2.Count == dac3.Count)//国家 币种 金额
  7130. {
  7131. for (int i = 0; i < dac2.Count; i++)
  7132. {
  7133. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7134. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7135. }
  7136. }
  7137. var dtdac1 = new DataTable();
  7138. var place = new List<string>();
  7139. dtdac1.Columns.AddRange(new DataColumn[] {
  7140. new(){ ColumnName = "city"},
  7141. new(){ ColumnName = "curr"},
  7142. new(){ ColumnName = "criterion"},
  7143. new(){ ColumnName = "number",DataType = typeof(int)},
  7144. new(){ ColumnName = "day",DataType = typeof(int)},
  7145. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7146. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7147. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7148. });
  7149. var dtdac2 = new DataTable();
  7150. dtdac2.Columns.AddRange(new DataColumn[] {
  7151. new(){ ColumnName = "city"},
  7152. new(){ ColumnName = "curr"},
  7153. new(){ ColumnName = "criterion"},
  7154. new(){ ColumnName = "number",DataType = typeof(int)},
  7155. new(){ ColumnName = "day",DataType = typeof(int)},
  7156. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7157. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7158. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7159. });
  7160. dtdac1.TableName = "tb1";
  7161. dtdac2.TableName = "tb2";
  7162. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7163. foreach (var item in dac1)
  7164. {
  7165. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7166. if (place.Contains(item.Place))
  7167. {
  7168. continue;
  7169. }
  7170. DataRow row = dtdac1.NewRow();
  7171. row["city"] = item.Place;
  7172. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7173. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7174. row["curr"] = currency;
  7175. row["rate"] = rate.ToString("#0.0000");
  7176. row["criterion"] = item.Cost.ToString("#0.00");
  7177. row["number"] = 1;
  7178. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7179. //row["costRMB"] = rbmPrice;
  7180. dtdac1.Rows.Add(row);
  7181. place.Add(item.Place);
  7182. }
  7183. place = new List<string>();
  7184. foreach (var item in dac2)
  7185. {
  7186. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7187. if (place.Contains(item.Place))
  7188. {
  7189. continue;
  7190. }
  7191. DataRow row = dtdac2.NewRow();
  7192. row["city"] = item.Place;
  7193. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7194. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7195. row["curr"] = currency;
  7196. row["rate"] = rate.ToString("#0.0000");
  7197. row["criterion"] = item.Cost.ToString("#0.00");
  7198. row["number"] = 1;
  7199. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7200. //row["cost"] = item.SubTotal;
  7201. //row["costRMB"] = rbmPrice;
  7202. dtdac2.Rows.Add(row);
  7203. place.Add(item.Place);
  7204. //dac2totalPrice += rbmPrice;
  7205. }
  7206. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7207. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7208. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7209. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7210. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7211. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7212. string cell4Str1 = string.Empty;
  7213. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7214. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7215. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7216. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7217. string cellStr = $" 5.其他费用(";
  7218. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7219. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7220. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7221. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7222. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7223. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7224. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7225. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7226. foreach (var otherInfo in dac5)
  7227. {
  7228. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7229. }
  7230. #endregion
  7231. if (cellStr.Length > 8)
  7232. {
  7233. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7234. }
  7235. cellStr += ")";
  7236. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7237. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7238. decimal pxFee = dac4.Sum(it => it.Cost);
  7239. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7240. string celllastStr1 = "";
  7241. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7242. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7243. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7244. celllastStr1 += $",国际旅费 元";
  7245. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7246. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7247. designer.SetDataSource("cell4Str", cell4Str);
  7248. designer.SetDataSource("cellStr", cellStr);
  7249. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7250. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7251. designer.SetDataSource("celllastStr", celllastStr);
  7252. Workbook wb = designer.Workbook;
  7253. var sheet = wb.Worksheets[0];
  7254. //绑定datatable数据集
  7255. designer.SetDataSource(dtdac1);
  7256. designer.SetDataSource(dtdac2);
  7257. designer.Process();
  7258. var rowStart = dtdac1.Rows.Count;
  7259. while (rowStart > 0)
  7260. {
  7261. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7262. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7263. startIndex++;
  7264. rowStart--;
  7265. }
  7266. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7267. startIndex += 1; //总计行
  7268. rowStart = dtdac2.Rows.Count;
  7269. while (rowStart > 0)
  7270. {
  7271. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7272. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7273. startIndex++;
  7274. rowStart--;
  7275. }
  7276. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7277. wb.CalculateFormula(true);
  7278. //模板文件名
  7279. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7280. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7281. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7282. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7283. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7284. }
  7285. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7286. {
  7287. //获取模板
  7288. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7289. //载入模板
  7290. var doc = new Document(tempPath);
  7291. var builder = new DocumentBuilder(doc);
  7292. var dic = new Dictionary<string, string>
  7293. {
  7294. { "GroupName", _DelegationInfo.TeamName },
  7295. { "ClientUnit", _DelegationInfo.ClientUnit }
  7296. };
  7297. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7298. string missionLeaderJob = "";//负责人job
  7299. //int groupNumber = 0; //团人数
  7300. if (DeleClientList.Count > 0)
  7301. {
  7302. missionLeader = DeleClientList[0]?.Name ?? "";
  7303. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7304. }
  7305. dic.Add("MissionLeader", missionLeader); //团负责人
  7306. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7307. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7308. #region MyRegion
  7309. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7310. //{
  7311. // List<string> list = new List<string>();
  7312. // try
  7313. // {
  7314. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7315. // foreach (var item in spilitArr)
  7316. // {
  7317. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7318. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7319. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7320. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7321. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7322. // list.Add(depName);
  7323. // list.Add(arrName);
  7324. // }
  7325. // list = list.Distinct().ToList();
  7326. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7327. // }
  7328. // catch (Exception)
  7329. // {
  7330. // dic.Add("ReturnCode", "行程录入不正确!");
  7331. // }
  7332. //}
  7333. //else
  7334. //{
  7335. // dic.Add("ReturnCode", "未录入行程!");
  7336. //}
  7337. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7338. dic.Add("ReturnCode", string.Join("、", countrys));
  7339. #endregion
  7340. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7341. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7342. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7343. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7344. //{
  7345. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7346. // dic.Add("Day", sp.Days.ToString());
  7347. //}
  7348. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7349. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7350. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7351. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7352. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7353. //培训人员名单
  7354. int cultivateRowIndex = 7;
  7355. foreach (var item in DeleClientList)
  7356. {
  7357. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7358. builder.Write(item.Name);
  7359. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7360. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7361. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7362. string birthDay = "";
  7363. if (item.Birthday != null)
  7364. {
  7365. DateTime dt = Convert.ToDateTime(item.Birthday);
  7366. birthDay = $"{dt.Year}.{dt.Month}";
  7367. }
  7368. builder.Write(birthDay);
  7369. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7370. builder.Write(item.Company);
  7371. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7372. builder.Write(item.Job);
  7373. cultivateRowIndex++;
  7374. }
  7375. //删除多余行
  7376. //cultivateRowIndex -= 2;
  7377. int delRows = 10 + 7 - cultivateRowIndex;
  7378. if (delRows > 0)
  7379. {
  7380. for (int i = 0; i < delRows; i++)
  7381. {
  7382. table1.Rows.RemoveAt(cultivateRowIndex);
  7383. //cultivateRowIndex++;
  7384. }
  7385. }
  7386. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7387. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7388. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7389. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7390. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7391. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7392. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7393. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7394. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7395. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7396. //其他费用
  7397. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7398. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7399. //其他费用合计
  7400. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7401. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7402. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7403. //公务舱合计
  7404. //国际旅费
  7405. //string outsideJJ = "";
  7406. //string allPriceJJ = "";
  7407. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7408. {
  7409. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7410. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7411. }
  7412. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7413. {
  7414. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7415. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7416. }
  7417. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7418. {
  7419. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7420. dic.Add("AirFeeTotal", airFeeTotalStr);
  7421. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7422. dic.Add("FeeTotal", feeTotalStr);
  7423. }
  7424. foreach (var key in dic.Keys)
  7425. {
  7426. builder.MoveToBookmark(key);
  7427. builder.Write(dic[key]);
  7428. }
  7429. //模板文件名
  7430. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7431. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7432. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7433. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7434. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7435. }
  7436. }
  7437. else if (dto.ExportType == 2) //表格
  7438. {
  7439. //利用键值对存放数据
  7440. Dictionary<string, string> dic = new Dictionary<string, string>();
  7441. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7442. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7443. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7444. dic.Add("Day", sp.Days.ToString());
  7445. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7446. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7447. {
  7448. //获取模板
  7449. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7450. //载入模板
  7451. var doc = new Document(tempPath);
  7452. var builder = new DocumentBuilder(doc);
  7453. dic.Add("TeamName", _DelegationInfo.TeamName);
  7454. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7455. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7456. string missionLeaderName = "",
  7457. missionLeaderJob = "";
  7458. if (DeleClientList.Count > 0)
  7459. {
  7460. missionLeaderName = DeleClientList[0].Name;
  7461. missionLeaderJob = DeleClientList[0].Job;
  7462. }
  7463. dic.Add("MissionLeaderName", missionLeaderName);
  7464. dic.Add("MissionLeaderJob", missionLeaderJob);
  7465. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7466. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7467. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7468. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7469. int rowCount = 10;//总人数行
  7470. int startRowIndex = 7; //起始行
  7471. for (int i = 0; i < DeleClientList.Count; i++)
  7472. {
  7473. builder.MoveToCell(0, startRowIndex, 0, 0);
  7474. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7475. builder.MoveToCell(0, startRowIndex, 1, 0);
  7476. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7477. builder.Write(sex);//性别
  7478. builder.MoveToCell(0, startRowIndex, 2, 0);
  7479. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7480. builder.MoveToCell(0, startRowIndex, 3, 0);
  7481. builder.Write(DeleClientList[i].Company);//工作单位
  7482. builder.MoveToCell(0, startRowIndex, 4, 0);
  7483. builder.Write(DeleClientList[i].Job);//职务及级别
  7484. builder.MoveToCell(0, startRowIndex, 5, 0);
  7485. builder.Write("");//人员属性
  7486. builder.MoveToCell(0, startRowIndex, 6, 0);
  7487. builder.Write("");//上次出国时间
  7488. startRowIndex++;
  7489. }
  7490. int nullRow = rowCount - DeleClientList.Count;//空行
  7491. for (int i = 0; i < nullRow; i++)
  7492. {
  7493. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7494. }
  7495. foreach (var key in dic.Keys)
  7496. {
  7497. builder.MoveToBookmark(key);
  7498. builder.Write(dic[key]);
  7499. }
  7500. //模板文件名
  7501. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7502. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7503. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7504. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7505. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7506. }
  7507. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7508. {
  7509. //获取模板
  7510. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7511. //载入模板
  7512. var doc = new Document(tempPath);
  7513. var builder = new DocumentBuilder(doc);
  7514. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7515. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7516. dic.Add("Names", Names);
  7517. int accommodationRows = 12;
  7518. //int foodandotherRows = 12;
  7519. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7520. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7521. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7522. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7523. int accommodationStartIndex = 6;
  7524. decimal dac1totalPrice = 0.00M;
  7525. foreach (var dac in dac1)
  7526. {
  7527. if (dac.SubTotal == 0)
  7528. {
  7529. continue;
  7530. }
  7531. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7532. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7533. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7534. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7535. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7536. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7537. builder.Write(currency);//币种
  7538. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7539. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7540. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7541. builder.Write("");//人数
  7542. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7543. builder.Write("");//天数
  7544. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7545. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7546. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7547. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7548. builder.Write(rate.ToString("#0.0000"));//汇率
  7549. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7550. decimal rbmPrice = rate * dac.SubTotal;
  7551. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7552. accommodationStartIndex++;
  7553. dac1totalPrice += rbmPrice;
  7554. }
  7555. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7556. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7557. builder.Write("小计");
  7558. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7559. builder.Write(dac1totalPrice.ToString("#0.00"));
  7560. accommodationStartIndex++;
  7561. int nullRow = accommodationRows - dac1.Count;
  7562. //删除空行
  7563. //if (nullRow > 0)
  7564. //{
  7565. // int rowIndex = accommodationStartIndex;
  7566. // for (int i = 0; i < nullRow; i++)
  7567. // {
  7568. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7569. // row.Remove();
  7570. // rowIndex++;
  7571. // }
  7572. //}
  7573. if (dac2.Count == dac3.Count)//国家 币种 金额
  7574. {
  7575. for (int i = 0; i < dac2.Count; i++)
  7576. {
  7577. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7578. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7579. }
  7580. }
  7581. int foodandotherStartIndex = 19;//
  7582. decimal dac2totalPrice = 0.00M;
  7583. foreach (var dac in dac2)
  7584. {
  7585. if (dac.SubTotal == 0)
  7586. {
  7587. continue;
  7588. }
  7589. //foodandotherStartIndex = 12;
  7590. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7591. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7592. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7593. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7594. builder.Write(currency);//币种
  7595. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7596. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7597. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7598. builder.Write("");//人数
  7599. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7600. builder.Write("");//天数
  7601. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7602. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7603. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7604. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7605. builder.Write(rate.ToString("#0.0000"));//汇率
  7606. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7607. decimal rbmPrice = rate * dac.SubTotal;
  7608. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7609. foodandotherStartIndex++;
  7610. dac2totalPrice += rbmPrice;
  7611. }
  7612. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7613. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7614. //删除空行
  7615. //if (dac2.Count < foodandotherRows)
  7616. //{
  7617. // while (table2.Rows.Count > dac2.Count)
  7618. // {
  7619. // table2.Rows.RemoveAt(dac2.Count);
  7620. // }
  7621. //}
  7622. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7623. string otherFeeStr = "";
  7624. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7625. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7626. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7627. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7628. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7629. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7630. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7631. foreach (var otherInfo in dac5)
  7632. {
  7633. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7634. }
  7635. #endregion
  7636. if (otherFeeStr.Length > 0)
  7637. {
  7638. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7639. otherFeeStr = $"({otherFeeStr})";
  7640. dic.Add("OtherFeeStr", otherFeeStr);
  7641. }
  7642. foreach (var key in dic.Keys)
  7643. {
  7644. builder.MoveToBookmark(key);
  7645. builder.Write(dic[key]);
  7646. }
  7647. //模板文件名
  7648. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7649. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7650. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7651. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7652. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7653. }
  7654. }
  7655. else if (dto.ExportType == 3)
  7656. {
  7657. if (dto.SubTypeId == 1) //团组成员名单
  7658. {
  7659. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7660. //获取模板
  7661. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7662. //载入模板
  7663. var doc = new Document(tempPath);
  7664. var builder = new DocumentBuilder(doc);
  7665. //获取word里所有表格
  7666. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7667. //获取所填表格的序数
  7668. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7669. var rowStart = tableOne.Rows[0]; //获取第1行
  7670. //循环赋值
  7671. for (int i = 0; i < DeleClientList.Count; i++)
  7672. {
  7673. builder.MoveToCell(0, i + 1, 0, 0);
  7674. builder.Write(DeleClientList[i].Name);
  7675. builder.MoveToCell(0, i + 1, 1, 0);
  7676. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7677. builder.Write(sex);
  7678. builder.MoveToCell(0, i + 1, 2, 0);
  7679. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7680. builder.MoveToCell(0, i + 1, 3, 0);
  7681. builder.Write(DeleClientList[i].Company);
  7682. builder.MoveToCell(0, i + 1, 4, 0);
  7683. builder.Write(DeleClientList[i].Job);
  7684. }
  7685. //删除多余行
  7686. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7687. {
  7688. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7689. }
  7690. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7691. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7692. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7693. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7694. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7695. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7696. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7697. }
  7698. }
  7699. return Ok(JsonView(400, "操作失败!", ""));
  7700. }
  7701. catch (Exception ex)
  7702. {
  7703. return Ok(JsonView(400, ex.Message, ""));
  7704. }
  7705. }
  7706. /// <summary>
  7707. /// 获取三公费用标准city
  7708. /// </summary>
  7709. /// <param name="placeData"></param>
  7710. /// <param name="nationalTravelFeeId"></param>
  7711. /// <returns></returns>
  7712. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7713. {
  7714. string _city = string.Empty;
  7715. if (placeData.Count < 1) return _city;
  7716. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7717. if (data == null) return _city;
  7718. string country = data.Country;
  7719. string city = data.City;
  7720. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7721. else _city = city;
  7722. return _city;
  7723. }
  7724. ///// <summary>
  7725. ///// 团组模块 - 出入境费用 - 明细表导出
  7726. ///// </summary>
  7727. ///// <returns></returns>
  7728. //[HttpPost]
  7729. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7730. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7731. //{
  7732. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7733. // if (data.Code != 0)
  7734. // {
  7735. // return Ok(JsonView(false, data.Msg));
  7736. // }
  7737. // return Ok(JsonView(true, data.Msg, data.Data));
  7738. //}
  7739. /// <summary>
  7740. /// 团组模块 - 出入境费用 - 一键清空
  7741. /// </summary>
  7742. /// <returns></returns>
  7743. [HttpPost]
  7744. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7746. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7747. {
  7748. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7749. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7750. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7751. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7752. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7753. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7754. .SetColumns(x => new Grp_DayOtherPrice
  7755. {
  7756. IsDel = 1,
  7757. DeleteUserId = dto.UserId,
  7758. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7759. })
  7760. .ExecuteCommandAsync();
  7761. if (_view.Code == 0)
  7762. {
  7763. return Ok(JsonView(true, "操作成功"));
  7764. }
  7765. return Ok(JsonView(false, "操作失败"));
  7766. }
  7767. /// <summary>
  7768. /// 团组模块 - 出入境费用 - 子项删除
  7769. /// </summary>
  7770. /// <returns></returns>
  7771. [HttpPost]
  7772. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7774. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7775. {
  7776. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7777. if (data.Code != 0)
  7778. {
  7779. return Ok(JsonView(false, data.Msg));
  7780. }
  7781. return Ok(JsonView(true, "操作成功!", data.Data));
  7782. }
  7783. /// <summary>
  7784. /// 删除三公其他费用
  7785. /// </summary>
  7786. /// <param name="dto"></param>
  7787. /// <returns></returns>
  7788. [HttpPost]
  7789. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7790. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7791. {
  7792. var jw = JsonView(false, "删除失败!");
  7793. var data = new Grp_DayOtherPrice()
  7794. {
  7795. Id = dto.Id,
  7796. IsDel = 1,
  7797. DeleteUserId = dto.DeleteUserId,
  7798. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7799. };
  7800. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7801. if (del > 0)
  7802. {
  7803. jw.Code = 200;
  7804. jw.Msg = "删除成功!";
  7805. }
  7806. return Ok(jw);
  7807. }
  7808. /// <summary>
  7809. /// 团组模块 - 出入境国家费用标准 List
  7810. /// </summary>
  7811. /// <returns></returns>
  7812. [HttpPost]
  7813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7814. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7815. {
  7816. int provinceId = dto.ProvinceId;
  7817. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7818. var nftData = await _sqlSugar
  7819. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7820. JoinType.Left, ntf.Currency == sd1.Id,
  7821. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7822. JoinType.Left, ntf.ProvinceId == c.Id
  7823. ))
  7824. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7825. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7826. {
  7827. Id = ntf.Id,
  7828. ProvinceId = ntf.ProvinceId,
  7829. ProvinceName = c.Name_CN,
  7830. Continent = ntf.Continent,
  7831. Country = ntf.Country,
  7832. City = ntf.City,
  7833. Currency = ntf.Currency,
  7834. CurrencyCode = sd1.Name,
  7835. CurrencyName = sd1.Remark,
  7836. RoomCost = ntf.RoomCost,
  7837. FoodCost = ntf.FoodCost,
  7838. PublicCost = ntf.PublicCost,
  7839. LastUpdateUserId = ntf.LastUpdateUserId,
  7840. LastUpdateUserName = u.CnName,
  7841. LastUpdateTime = ntf.LastUpdateTime
  7842. })
  7843. .ToListAsync();
  7844. return Ok(JsonView(true, "查询成功!", nftData));
  7845. }
  7846. /// <summary>
  7847. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7848. /// </summary>
  7849. /// <returns></returns>
  7850. [HttpPost]
  7851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7852. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7853. {
  7854. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7855. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7856. List<string> countryData = new List<string>();
  7857. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7858. countryData = countryData.Distinct().ToList();
  7859. List<dynamic> dataSource = new List<dynamic>();
  7860. foreach (var item in countryData)
  7861. {
  7862. var cityData1 = new List<string>();
  7863. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7864. var countryData2 = new
  7865. {
  7866. CountryName = item,
  7867. CityData = cityData1
  7868. };
  7869. if (!dataSource.Contains(countryData2))
  7870. {
  7871. dataSource.Add(countryData2);
  7872. }
  7873. }
  7874. return Ok(JsonView(true, "查询成功!", dataSource));
  7875. }
  7876. /// <summary>
  7877. /// 团组模块 - 出入境国家费用标准 Page List
  7878. /// </summary>
  7879. /// <returns></returns>
  7880. [HttpPost]
  7881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7882. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7883. {
  7884. int portId = dto.PortType,
  7885. pageIndex = dto.PageIndex,
  7886. pageSize = dto.PageSize;
  7887. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7888. if (pageIndex == 0) pageIndex = 1;
  7889. if (pageSize == 0) pageSize = 10;
  7890. RefAsync<int> total = 0;
  7891. var nationalTravelFeeData = await _sqlSugar
  7892. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7893. JoinType.Left, ntf.Currency == sd1.Id,
  7894. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7895. JoinType.Left, ntf.ProvinceId == sd2.Id
  7896. ))
  7897. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7898. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7899. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7900. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7901. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7902. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7903. {
  7904. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7905. Id = ntf.Id,
  7906. ProvinceId = ntf.ProvinceId,
  7907. ProvinceName = sd2.Name_CN,
  7908. Continent = ntf.Continent,
  7909. Country = ntf.Country,
  7910. City = ntf.City,
  7911. Currency = ntf.Currency,
  7912. CurrencyCode = sd1.Name,
  7913. CurrencyName = sd1.Remark,
  7914. RoomCost = ntf.RoomCost,
  7915. FoodCost = ntf.FoodCost,
  7916. PublicCost = ntf.PublicCost,
  7917. LastUpdateUserId = ntf.LastUpdateUserId,
  7918. LastUpdateUserName = u.CnName,
  7919. LastUpdateTime = ntf.LastUpdateTime,
  7920. Remark = ntf.Remark
  7921. })
  7922. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7923. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7924. }
  7925. /// <summary>
  7926. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7927. /// </summary>
  7928. /// <returns></returns>
  7929. [HttpPost]
  7930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7931. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7932. {
  7933. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7934. int portId = dto.PortType;
  7935. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7936. string whereSql = string.Empty;
  7937. if (!string.IsNullOrEmpty(dto.Country))
  7938. {
  7939. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7940. }
  7941. if (!string.IsNullOrEmpty(dto.City))
  7942. {
  7943. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7944. }
  7945. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7946. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7947. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7948. From Grp_NationalTravelFee gntf
  7949. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7950. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7951. Where gntf.Isdel = 0 {0} ", whereSql);
  7952. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7953. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7954. }
  7955. /// <summary>
  7956. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7957. /// </summary>
  7958. /// <returns></returns>
  7959. [HttpPost]
  7960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7961. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7962. {
  7963. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7964. }
  7965. /// <summary>
  7966. /// 团组模块 - 出入境国家费用标准 - Del
  7967. /// </summary>
  7968. /// <returns></returns>
  7969. [HttpPost]
  7970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7971. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7972. {
  7973. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7974. {
  7975. Id = dto.Id,
  7976. DeleteUserId = dto.DeleteUserId,
  7977. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7978. IsDel = 1
  7979. };
  7980. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7981. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7982. .WhereColumns(it => new { it.Id })
  7983. .ExecuteCommandAsync();
  7984. if (delStatus <= 0)
  7985. {
  7986. return Ok(JsonView(false, "删除失败!"));
  7987. }
  7988. return Ok(JsonView(true, "操作成功!"));
  7989. }
  7990. /// <summary>
  7991. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7992. /// 注:Get 请求Headers 加 Token
  7993. /// </summary>
  7994. /// <param name="groupId"></param>
  7995. /// <returns></returns>
  7996. [HttpGet("{groupId}")]
  7997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7998. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7999. {
  8000. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8001. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8002. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8003. data.ForEach(x =>
  8004. {
  8005. x.CreateUserId = _currUserInfo.UserId;
  8006. });
  8007. if (data.Any())
  8008. {
  8009. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8010. if (add > 0)
  8011. {
  8012. return Ok(JsonView(true, "操作成功!"));
  8013. }
  8014. }
  8015. return Ok(JsonView(false, "未操作!"));
  8016. }
  8017. #endregion
  8018. #region 团组经理模块 出入境费用-草稿
  8019. /// <summary>
  8020. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8021. /// </summary>
  8022. /// <returns></returns>
  8023. [HttpGet]
  8024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8025. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8026. {
  8027. var provData = await _groupRepository.ProvinceBasicSource();
  8028. return Ok(JsonView(true, "查询成功!", provData));
  8029. }
  8030. /// <summary>
  8031. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8032. /// </summary>
  8033. /// <returns></returns>
  8034. [HttpGet("{provinceId}")]
  8035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8036. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8037. {
  8038. //验证城市归属并给默认值
  8039. if (provinceId < 1) provinceId = 122;
  8040. /*
  8041. * 122 四川
  8042. * 108 贵州
  8043. * 103 重庆
  8044. * 132 云南
  8045. */
  8046. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8047. return Ok(JsonView(true, "查询成功!", new
  8048. {
  8049. WordTypeData = wordTypeData,
  8050. ExcelTypeData = excelTypeData,
  8051. }));
  8052. }
  8053. /// <summary>
  8054. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8055. /// </summary>
  8056. /// <returns></returns>
  8057. [HttpPost]
  8058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8059. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8060. {
  8061. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8062. .Where(x => x.IsDel == 0)
  8063. .OrderByDescending(x => x.CreateTime)
  8064. .Select(x => new { x.Id, x.DraftName })
  8065. .ToListAsync();
  8066. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8067. //SetDataInfoView
  8068. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8069. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8070. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8071. int provinceId = dto.ProvinceId;
  8072. if (provinceId < 1) provinceId = 122;
  8073. /*
  8074. * 122 四川
  8075. * 108 贵州
  8076. * 103 重庆
  8077. * 132 云南
  8078. */
  8079. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8080. //默认币种显示
  8081. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8082. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8083. return Ok(JsonView(true, "查询成功!", new
  8084. {
  8085. DraftNameDatas = draftNameDatas,
  8086. CurrencyData = _CurrencyData,
  8087. WordTypeData = wordTypeData,
  8088. ExcelTypeData = excelTypeData,
  8089. CurrencyInit = _currencyInfos,
  8090. ViewPermissionData = viewPermissionData
  8091. }));
  8092. }
  8093. /// <summary>
  8094. /// 团组模块 - 出入境费用-草稿
  8095. /// 实时汇率 tips
  8096. /// 机票费用 tips
  8097. /// </summary>
  8098. /// <returns></returns>
  8099. [HttpPost]
  8100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8101. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8102. {
  8103. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8104. return Ok(JsonView(true, "查询成功!", new
  8105. {
  8106. //GroupNameData = groupNameData.Data,
  8107. //visaData = visaData.Data,
  8108. //airData = airData.Data,
  8109. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8110. }));
  8111. }
  8112. /// <summary>
  8113. /// 团组模块 - 出入境费用-草稿
  8114. /// 签证费用 tips
  8115. /// </summary>
  8116. /// <returns></returns>
  8117. [HttpPost]
  8118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8119. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8120. {
  8121. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8122. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8123. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8124. .Select(x => x.NationalTravelFeeId)
  8125. .Distinct()
  8126. .ToListAsync();
  8127. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8128. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8129. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8130. .Select(x => x.Country)
  8131. .Distinct()
  8132. .ToArrayAsync();
  8133. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8134. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8135. return Ok(JsonView(true, "查询成功!", new
  8136. {
  8137. totalAmt = totalAmt,
  8138. remark = remark
  8139. }));
  8140. }
  8141. /// <summary>
  8142. /// 团组模块 - 出入境费用-草稿 - Info
  8143. /// </summary>
  8144. /// <returns></returns>
  8145. [HttpPost]
  8146. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8148. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8149. {
  8150. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8151. }
  8152. /// <summary>
  8153. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8154. /// </summary>
  8155. /// <returns></returns>
  8156. [HttpPost]
  8157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8158. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8159. {
  8160. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8161. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8162. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8163. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8164. foreach (var userId in dto.UserIds)
  8165. {
  8166. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8167. }
  8168. if (permissions.Any())
  8169. {
  8170. _sqlSugar.BeginTran();
  8171. try
  8172. {
  8173. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8174. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8175. if (result < 1)
  8176. {
  8177. _sqlSugar.RollbackTran();
  8178. return Ok(JsonView(false));
  8179. }
  8180. }
  8181. catch (Exception ex)
  8182. {
  8183. _sqlSugar.RollbackTran();
  8184. return Ok(JsonView(false, ex.Message));
  8185. }
  8186. _sqlSugar.CommitTran();
  8187. return Ok(JsonView(true));
  8188. }
  8189. return Ok(JsonView(false));
  8190. }
  8191. /// <summary>
  8192. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8193. /// </summary>
  8194. /// <returns></returns>
  8195. [HttpPost]
  8196. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8198. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8199. {
  8200. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8201. if (data.Code != 0)
  8202. {
  8203. return Ok(JsonView(false, data.Msg));
  8204. }
  8205. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8206. //汇率信息记录
  8207. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8208. return Ok(JsonView(true, data.Msg, data.Data));
  8209. }
  8210. /// <summary>
  8211. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8212. /// </summary>
  8213. /// <param name="dto"></param>
  8214. /// <returns></returns>
  8215. [HttpPost]
  8216. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8218. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8219. {
  8220. try
  8221. {
  8222. var id = dto.Id;
  8223. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8224. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8225. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8226. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8227. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8228. 3 团组成员名单 1 团组成员名单", ""));
  8229. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8230. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8231. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8232. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8233. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8234. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8235. //数据源
  8236. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8237. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8238. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8239. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8240. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8241. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8242. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8243. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8244. .Select((x, a, b) => new
  8245. {
  8246. x.Index,
  8247. itemName = a.Name,
  8248. CurrencyStr = b.Name,
  8249. x.Cost,
  8250. x.SubTotal,
  8251. x.Remark
  8252. })
  8253. .OrderBy((x) => x.Index)
  8254. .ToList(); //其他款项费用
  8255. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8256. var peiceItemCurrencys = new List<string>();
  8257. if (_DayAndCosts.Any())
  8258. {
  8259. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8260. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8261. }
  8262. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8263. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8264. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8265. {
  8266. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8267. }
  8268. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8269. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8270. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8271. if (dto.ExportType == 1) //明细表
  8272. {
  8273. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8274. {
  8275. //获取模板
  8276. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8277. //载入模板
  8278. Document doc = new Document(tempPath);
  8279. DocumentBuilder builder = new DocumentBuilder(doc);
  8280. //利用键值对存放数据
  8281. Dictionary<string, string> dic = new Dictionary<string, string>();
  8282. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8283. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8284. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8285. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8286. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8287. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8288. //境内费用(其他费用)
  8289. if (_EnterExitCosts.ChoiceOne == 1)
  8290. {
  8291. string row1_1 = "";
  8292. if (_EnterExitCosts.Visa > 0)
  8293. {
  8294. //insidePayTotal += _EnterExitCosts.Visa;
  8295. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8296. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8297. //{
  8298. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8299. //}
  8300. }
  8301. string row1_2 = "";
  8302. if (_EnterExitCosts.YiMiao > 0)
  8303. {
  8304. //insidePayTotal += _EnterExitCosts.YiMiao;
  8305. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8306. }
  8307. if (_EnterExitCosts.HeSuan > 0)
  8308. {
  8309. //insidePayTotal += _EnterExitCosts.HeSuan;
  8310. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8311. }
  8312. if (_EnterExitCosts.Service > 0)
  8313. {
  8314. //insidePayTotal += _EnterExitCosts.Service;
  8315. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8316. }
  8317. string row1_3 = "";
  8318. if (_EnterExitCosts.Safe > 0)
  8319. {
  8320. //insidePayTotal += _EnterExitCosts.Safe;
  8321. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8322. }
  8323. if (_EnterExitCosts.Ticket > 0)
  8324. {
  8325. //insidePayTotal += _EnterExitCosts.Ticket;
  8326. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8327. }
  8328. string row1 = "";
  8329. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8330. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8331. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8332. row1 += $"备注:{_EnterExitCosts.Remark}";
  8333. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8334. dic.Add("Row1Str", row1);
  8335. }
  8336. string airTotalStr = string.Empty,
  8337. airPriceStr = string.Empty;
  8338. //经济舱
  8339. if (_EnterExitCosts.SumJJC == 1)
  8340. {
  8341. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8342. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8343. }
  8344. //公务舱
  8345. if (_EnterExitCosts.SumGWC == 1)
  8346. {
  8347. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8348. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8349. }
  8350. //头等舱
  8351. if (_EnterExitCosts.SumTDC == 1)
  8352. {
  8353. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8354. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8355. }
  8356. //汇率描述
  8357. string rateStr = "";
  8358. if (peiceItemCurrencyInfos.Any())
  8359. {
  8360. rateStr = "\r\n汇率描述:";
  8361. foreach (var item in peiceItemCurrencyInfos)
  8362. {
  8363. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8364. }
  8365. }
  8366. string twoItemRemark = "备注:";
  8367. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8368. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8369. dic.Add("AirTotalStr", airTotalStr);
  8370. dic.Add("AirPriceStr", airPriceStr);
  8371. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8372. dic.Add("TwoItemRemark", twoItemRemark);
  8373. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8374. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8375. int table1Row = 0,
  8376. table2Row = 0,
  8377. table3Row = 0,
  8378. table4Row = 0,
  8379. table5Row = 0;
  8380. //住宿费
  8381. if (_EnterExitCosts.ChoiceThree == 1)
  8382. {
  8383. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8384. table1Row = dac1.Count;
  8385. #region 填充word表格内容
  8386. for (int i = 0; i < dac1.Count; i++)
  8387. {
  8388. var dac = dac1[i];
  8389. if (dac == null) continue;
  8390. builder.MoveToCell(0, i, 0, 0);
  8391. builder.Write("第" + dac.Days.ToString() + "晚:");
  8392. builder.MoveToCell(0, i, 1, 0);
  8393. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8394. //builder.Write(dac.Place == null ? "" : dac.Place);
  8395. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8396. builder.MoveToCell(0, i, 2, 0);
  8397. builder.Write("费用标准:");
  8398. string curr = "";
  8399. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8400. if (currData != null)
  8401. {
  8402. curr = currData.Name;
  8403. }
  8404. builder.MoveToCell(0, i, 3, 0);
  8405. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8406. builder.MoveToCell(0, i, 4, 0);
  8407. builder.Write("费用小计:");
  8408. builder.MoveToCell(0, i, 5, 0);
  8409. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8410. }
  8411. #endregion
  8412. }
  8413. else dic.Add("SubZS", "0.00");
  8414. //删除多余行
  8415. while (table1.Rows.Count > table1Row)
  8416. {
  8417. table1.Rows.RemoveAt(table1Row);
  8418. }
  8419. //伙食费
  8420. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8421. if (_EnterExitCosts.ChoiceFour == 1)
  8422. {
  8423. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8424. table2Row = dac2.Count;
  8425. #region 填充word表格内容
  8426. for (int i = 0; i < dac2.Count; i++)
  8427. {
  8428. var dac = dac2[i];
  8429. if (dac == null) continue;
  8430. builder.MoveToCell(1, i, 0, 0);
  8431. builder.Write("第" + dac.Days.ToString() + "天:");
  8432. builder.MoveToCell(1, i, 1, 0);
  8433. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8434. builder.MoveToCell(1, i, 2, 0);
  8435. builder.Write("费用标准:");
  8436. string curr = "";
  8437. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8438. if (currData != null)
  8439. {
  8440. curr = currData.Name;
  8441. }
  8442. builder.MoveToCell(1, i, 3, 0);
  8443. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8444. builder.MoveToCell(1, i, 4, 0);
  8445. builder.Write("费用小计:");
  8446. builder.MoveToCell(1, i, 5, 0);
  8447. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8448. }
  8449. #endregion
  8450. }
  8451. else dic.Add("SubHS", "0.00");
  8452. //删除多余行
  8453. while (table2.Rows.Count > table2Row)
  8454. {
  8455. table2.Rows.RemoveAt(table2Row);
  8456. }
  8457. //公杂费
  8458. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8459. if (_EnterExitCosts.ChoiceFive == 1)
  8460. {
  8461. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8462. table3Row = dac3.Count;
  8463. #region 填充word表格内容
  8464. for (int i = 0; i < dac3.Count; i++)
  8465. {
  8466. var dac = dac3[i];
  8467. if (dac == null) continue;
  8468. builder.MoveToCell(2, i, 0, 0);
  8469. builder.Write("第" + dac.Days.ToString() + "天:");
  8470. builder.MoveToCell(2, i, 1, 0);
  8471. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8472. builder.MoveToCell(2, i, 2, 0);
  8473. builder.Write("费用标准:");
  8474. string curr = "";
  8475. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8476. if (currData != null)
  8477. {
  8478. curr = currData.Name;
  8479. }
  8480. builder.MoveToCell(2, i, 3, 0);
  8481. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8482. builder.MoveToCell(2, i, 4, 0);
  8483. builder.Write("费用小计:");
  8484. builder.MoveToCell(2, i, 5, 0);
  8485. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8486. }
  8487. //删除多余行
  8488. while (table3.Rows.Count > table3Row)
  8489. {
  8490. table3.Rows.RemoveAt(table3Row);
  8491. }
  8492. #endregion
  8493. }
  8494. else dic.Add("SubGZF", "0.00");
  8495. //删除多余行
  8496. while (table3.Rows.Count > table3Row)
  8497. {
  8498. table3.Rows.RemoveAt(table3Row);
  8499. }
  8500. //培训费
  8501. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8502. if (_EnterExitCosts.ChoiceSix == 1)
  8503. {
  8504. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8505. dic.Add("SubPX", pxStr);
  8506. table4Row = dac4.Count;
  8507. #region 填充word表格内容
  8508. for (int i = 0; i < dac4.Count; i++)
  8509. {
  8510. var dac = dac4[i];
  8511. if (dac == null) continue;
  8512. builder.MoveToCell(3, i, 0, 0);
  8513. builder.Write("第" + dac.Days.ToString() + "天:");
  8514. builder.MoveToCell(3, i, 1, 0);
  8515. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8516. builder.MoveToCell(3, i, 2, 0);
  8517. builder.Write("费用标准:");
  8518. string curr = "";
  8519. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8520. if (currData != null)
  8521. {
  8522. curr = currData.Name;
  8523. }
  8524. builder.MoveToCell(3, i, 3, 0);
  8525. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8526. builder.MoveToCell(3, i, 4, 0);
  8527. builder.Write("费用小计:");
  8528. builder.MoveToCell(3, i, 5, 0);
  8529. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8530. }
  8531. #endregion
  8532. }
  8533. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8534. //删除多余行
  8535. while (table4.Rows.Count > table4Row)
  8536. {
  8537. table4.Rows.RemoveAt(table4Row);
  8538. }
  8539. //其他费用
  8540. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8541. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8542. {
  8543. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8544. dic.Add("titleQi", qtStr);
  8545. table5Row = dac5.Count;
  8546. #region 填充word表格内容
  8547. for (int i = 0; i < dac5.Count; i++)
  8548. {
  8549. var dac = dac5[i];
  8550. if (dac == null) continue;
  8551. builder.MoveToCell(4, i, 0, 0);
  8552. builder.Write("第" + dac.Index.ToString() + "项:");
  8553. builder.MoveToCell(4, i, 1, 0);
  8554. builder.Write(dac.itemName);
  8555. builder.MoveToCell(4, i, 2, 0);
  8556. builder.Write("费用标准:");
  8557. builder.MoveToCell(4, i, 3, 0);
  8558. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8559. builder.MoveToCell(4, i, 4, 0);
  8560. builder.Write("费用小计:");
  8561. builder.MoveToCell(4, i, 5, 0);
  8562. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8563. builder.MoveToCell(4, i, 6, 0);
  8564. builder.Write("备注:");
  8565. builder.MoveToCell(4, i, 7, 0);
  8566. builder.Write(dac.Remark);
  8567. }
  8568. #endregion
  8569. }
  8570. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8571. //删除多余行
  8572. while (table5.Rows.Count > table5Row)
  8573. {
  8574. table5.Rows.RemoveAt(table5Row);
  8575. }
  8576. //加上其他费用
  8577. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8578. decimal subJJC = 0.00M,
  8579. subGWC = 0.00M,
  8580. subTDC = 0.00M;
  8581. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8582. string totalLabel = string.Format("全部费用总计:");
  8583. //经济舱
  8584. if (_EnterExitCosts.SumJJC == 1)
  8585. {
  8586. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8587. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8588. }
  8589. //公务舱
  8590. if (_EnterExitCosts.SumGWC == 1)
  8591. {
  8592. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8593. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8594. }
  8595. //头等舱
  8596. if (_EnterExitCosts.SumTDC == 1)
  8597. {
  8598. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8599. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8600. }
  8601. //TotalLabel
  8602. dic.Add("TotalLabel", totalLabel);
  8603. #region 填充word模板书签内容
  8604. foreach (var key in dic.Keys)
  8605. {
  8606. Bookmark bookmark = doc.Range.Bookmarks[key];
  8607. if (bookmark != null)
  8608. {
  8609. builder.MoveToBookmark(key);
  8610. builder.Write(dic[key]);
  8611. }
  8612. }
  8613. #endregion
  8614. //文件名
  8615. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8616. strFileName = CommonFun.ValidFileName(strFileName);
  8617. AsposeHelper.removewatermark_v2180();
  8618. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8619. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8620. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8621. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8622. }
  8623. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8624. {
  8625. //获取模板
  8626. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8627. //载入模板
  8628. Document doc = new Document(tempPath);
  8629. DocumentBuilder builder = new DocumentBuilder(doc);
  8630. Dictionary<string, string> dic = new Dictionary<string, string>();
  8631. string returnCodeLabel = string.Empty;
  8632. if (nationalTravelFeeData.Any())
  8633. {
  8634. List<string> list = new List<string>();
  8635. foreach (var item in nationalTravelFeeData)
  8636. {
  8637. list.Add($"{item.Country}({item.City})");
  8638. }
  8639. list = list.Distinct().ToList();
  8640. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8641. }
  8642. var countryLabel = string.Empty;
  8643. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8644. if (countryData.Any())
  8645. {
  8646. countryLabel = string.Join("、", countryData);
  8647. }
  8648. dic.Add("ReturnCodeAir", returnCodeLabel);
  8649. dic.Add("VisitStartDate", "-");
  8650. dic.Add("VisitEndDate", "-");
  8651. dic.Add("Day", "-");
  8652. dic.Add("VisitCountry", countryLabel);
  8653. dic.Add("ClientUnit", "-");
  8654. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8655. //dic.Add("Names", Names);
  8656. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8657. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8658. decimal dac1totalPrice = 0.00M;
  8659. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8660. foreach (var dac in dac1)
  8661. {
  8662. if (dac.SubTotal == 0.00M)
  8663. {
  8664. continue;
  8665. }
  8666. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8667. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8668. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8669. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8670. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8671. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8672. builder.Write(currency);//币种
  8673. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8674. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8675. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8676. builder.Write("");//人数
  8677. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8678. builder.Write("");//天数
  8679. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8680. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8681. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8682. decimal rate = 0.00M;
  8683. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8684. builder.Write(rate.ToString("#0.0000"));//汇率
  8685. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8686. decimal rbmPrice = dac.SubTotal;
  8687. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8688. accommodationStartIndex++;
  8689. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8690. }
  8691. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8692. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8693. {
  8694. table1.Rows.RemoveAt(i - 1);
  8695. foodandotherStartIndex--;
  8696. }
  8697. if (dac2.Count == dac3.Count)//国家 币种 金额
  8698. {
  8699. for (int i = 0; i < dac2.Count; i++)
  8700. {
  8701. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8702. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8703. }
  8704. }
  8705. decimal dac2totalPrice = 0.00M;
  8706. foreach (var dac in dac2)
  8707. {
  8708. if (dac.SubTotal == 0)
  8709. {
  8710. continue;
  8711. }
  8712. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8713. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8714. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8715. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8716. builder.Write(currency);//币种
  8717. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8718. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8719. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8720. builder.Write("");//人数
  8721. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8722. builder.Write("");//天数
  8723. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8724. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8725. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8726. decimal rate = 0.00M;
  8727. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8728. builder.Write(rate.ToString("#0.0000"));//汇率
  8729. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8730. decimal rbmPrice = dac.SubTotal;
  8731. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8732. foodandotherStartIndex++;
  8733. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8734. }
  8735. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8736. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8737. {
  8738. table1.Rows.RemoveAt(i - 1);
  8739. }
  8740. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8741. string otherFeeStr = "";
  8742. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8743. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8744. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8745. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8746. foreach (var otherInfo in dac5)
  8747. {
  8748. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8749. }
  8750. #endregion
  8751. if (otherFeeStr.Length > 0)
  8752. {
  8753. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8754. otherFeeStr = $"({otherFeeStr})";
  8755. dic.Add("OtherFeeStr", otherFeeStr);
  8756. }
  8757. //总计
  8758. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8759. //国际旅费
  8760. string outsideAir = string.Empty;
  8761. string allPriceAir = string.Empty;
  8762. if (_EnterExitCosts.SumJJC == 1)
  8763. {
  8764. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8765. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8766. }
  8767. if (_EnterExitCosts.SumGWC == 1)
  8768. {
  8769. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8770. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8771. }
  8772. if (_EnterExitCosts.SumTDC == 1)
  8773. {
  8774. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8775. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8776. }
  8777. dic.Add("InTravelPrice", $"({outsideAir})");
  8778. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8779. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8780. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8781. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8782. foreach (var key in dic.Keys)
  8783. {
  8784. builder.MoveToBookmark(key);
  8785. builder.Write(dic[key]);
  8786. }
  8787. //模板文件名
  8788. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8789. strFileName = CommonFun.ValidFileName(strFileName);
  8790. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8791. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8792. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8793. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8794. }
  8795. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8796. {
  8797. //获取模板
  8798. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8799. //载入模板
  8800. WorkbookDesigner designer = new WorkbookDesigner();
  8801. designer.Workbook = new Workbook(tempPath);
  8802. Dictionary<string, string> dic = new Dictionary<string, string>();
  8803. string returnCodeLabel = string.Empty;
  8804. if (nationalTravelFeeData.Any())
  8805. {
  8806. List<string> list = new List<string>();
  8807. foreach (var item in nationalTravelFeeData)
  8808. {
  8809. list.Add($"{item.Country}({item.City})");
  8810. }
  8811. list = list.Distinct().ToList();
  8812. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8813. }
  8814. var countryLabel = string.Empty;
  8815. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8816. if (countryData.Any())
  8817. {
  8818. countryLabel = string.Join("、", countryData);
  8819. }
  8820. dic.Add("ReturnCodeAir", returnCodeLabel);
  8821. dic.Add("VisitStartDate", "-");
  8822. dic.Add("VisitEndDate", "-");
  8823. dic.Add("Day", "0");
  8824. dic.Add("VisitCountry", countryLabel);
  8825. dic.Add("ClientUnit", "-");
  8826. designer.SetDataSource("ClientUnit", "-");
  8827. designer.SetDataSource("VisitCountry", countryLabel);
  8828. designer.SetDataSource("Group", "-");
  8829. designer.SetDataSource("ClientUnitTitle", "-");
  8830. designer.SetDataSource("Name", "-");
  8831. designer.SetDataSource("VisitStartDate", "-");
  8832. designer.SetDataSource("Day", "0");
  8833. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8834. designer.SetDataSource("ReturnCodeAir", "-");
  8835. int startIndex = 10;
  8836. const int startIndexcopy = 10;
  8837. if (dac2.Count == dac3.Count)//国家 币种 金额
  8838. {
  8839. for (int i = 0; i < dac2.Count; i++)
  8840. {
  8841. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8842. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8843. }
  8844. }
  8845. DataTable dtdac1 = new DataTable();
  8846. List<string> place = new List<string>();
  8847. dtdac1.Columns.AddRange(new DataColumn[] {
  8848. new DataColumn(){ ColumnName = "city"},
  8849. new DataColumn(){ ColumnName = "curr"},
  8850. new DataColumn(){ ColumnName = "criterion"},
  8851. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8852. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8853. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8854. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8855. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8856. });
  8857. DataTable dtdac2 = new DataTable();
  8858. dtdac2.Columns.AddRange(new DataColumn[] {
  8859. new DataColumn(){ ColumnName = "city"},
  8860. new DataColumn(){ ColumnName = "curr"},
  8861. new DataColumn(){ ColumnName = "criterion"},
  8862. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8863. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8864. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8865. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8866. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8867. });
  8868. dtdac1.TableName = "tb1";
  8869. dtdac2.TableName = "tb2";
  8870. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8871. foreach (var item in dac1)
  8872. {
  8873. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8874. if (place.Contains(item.Place))
  8875. {
  8876. continue;
  8877. }
  8878. DataRow row = dtdac1.NewRow();
  8879. row["city"] = item.Place;
  8880. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8881. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8882. row["curr"] = currency;
  8883. row["rate"] = rate.ToString("#0.0000");
  8884. row["criterion"] = item.Cost.ToString("#0.00");
  8885. row["number"] = 1;
  8886. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8887. //row["costRMB"] = rbmPrice;
  8888. dtdac1.Rows.Add(row);
  8889. place.Add(item.Place);
  8890. }
  8891. place = new List<string>();
  8892. foreach (var item in dac2)
  8893. {
  8894. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8895. if (place.Contains(item.Place))
  8896. {
  8897. continue;
  8898. }
  8899. DataRow row = dtdac2.NewRow();
  8900. row["city"] = item.Place;
  8901. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8902. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8903. row["curr"] = currency;
  8904. row["rate"] = rate.ToString("#0.0000");
  8905. row["criterion"] = item.Cost.ToString("#0.00");
  8906. row["number"] = 1;
  8907. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8908. //row["cost"] = item.SubTotal;
  8909. //row["costRMB"] = rbmPrice;
  8910. dtdac2.Rows.Add(row);
  8911. place.Add(item.Place);
  8912. //dac2totalPrice += rbmPrice;
  8913. }
  8914. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8915. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8916. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8917. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8918. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8919. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8920. string cell4Str1 = string.Empty;
  8921. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8922. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8923. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8924. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8925. string cellStr = $" 5.其他费用(";
  8926. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8927. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8928. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8929. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8930. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8931. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8932. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8933. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8934. foreach (var otherInfo in dac5)
  8935. {
  8936. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8937. }
  8938. #endregion
  8939. if (cellStr.Length > 8)
  8940. {
  8941. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8942. }
  8943. cellStr += ")";
  8944. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8945. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8946. decimal pxFee = dac4.Sum(it => it.Cost);
  8947. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8948. string celllastStr1 = "";
  8949. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8950. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8951. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8952. celllastStr1 += $",国际旅费 元";
  8953. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8954. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8955. designer.SetDataSource("cell4Str", cell4Str);
  8956. designer.SetDataSource("cellStr", cellStr);
  8957. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8958. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8959. designer.SetDataSource("celllastStr", celllastStr);
  8960. Workbook wb = designer.Workbook;
  8961. var sheet = wb.Worksheets[0];
  8962. //绑定datatable数据集
  8963. designer.SetDataSource(dtdac1);
  8964. designer.SetDataSource(dtdac2);
  8965. designer.Process();
  8966. var rowStart = dtdac1.Rows.Count;
  8967. while (rowStart > 0)
  8968. {
  8969. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8970. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8971. startIndex++;
  8972. rowStart--;
  8973. }
  8974. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8975. startIndex += 1; //总计行
  8976. rowStart = dtdac2.Rows.Count;
  8977. while (rowStart > 0)
  8978. {
  8979. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8980. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8981. startIndex++;
  8982. rowStart--;
  8983. }
  8984. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8985. wb.CalculateFormula(true);
  8986. //模板文件名
  8987. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8988. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8989. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8990. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8991. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8992. }
  8993. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8994. {
  8995. //获取模板
  8996. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8997. //载入模板
  8998. Document doc = new Document(tempPath);
  8999. DocumentBuilder builder = new DocumentBuilder(doc);
  9000. Dictionary<string, string> dic = new Dictionary<string, string>();
  9001. dic.Add("GroupName", "-");
  9002. dic.Add("ClientUnit", "-");
  9003. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9004. //string missionLeaderJob = "";//负责人job
  9005. //int groupNumber = 0; //团人数
  9006. dic.Add("MissionLeader", "-"); //团负责人
  9007. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9008. dic.Add("GroupNumber", "0"); //团人数
  9009. dic.Add("Day", "0");
  9010. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9011. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9012. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9013. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9014. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9015. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9016. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9017. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9018. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9019. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9020. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9021. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9022. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9023. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9024. //其他费用
  9025. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9026. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9027. //其他费用合计
  9028. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9029. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9030. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9031. //公务舱合计
  9032. //国际旅费
  9033. //string outsideJJ = "";
  9034. //string allPriceJJ = "";
  9035. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9036. {
  9037. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9038. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9039. }
  9040. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9041. {
  9042. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9043. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9044. }
  9045. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9046. {
  9047. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9048. dic.Add("AirFeeTotal", airFeeTotalStr);
  9049. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9050. dic.Add("FeeTotal", feeTotalStr);
  9051. }
  9052. foreach (var key in dic.Keys)
  9053. {
  9054. builder.MoveToBookmark(key);
  9055. builder.Write(dic[key]);
  9056. }
  9057. //模板文件名
  9058. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9059. strFileName = CommonFun.ValidFileName(strFileName);
  9060. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9061. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9062. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9063. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9064. }
  9065. }
  9066. else if (dto.ExportType == 2) //表格
  9067. {
  9068. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9069. }
  9070. else if (dto.ExportType == 3)
  9071. {
  9072. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9073. }
  9074. return Ok(JsonView(400, "只可导出明细表!", ""));
  9075. }
  9076. catch (Exception ex)
  9077. {
  9078. return Ok(JsonView(400, ex.Message, ""));
  9079. }
  9080. }
  9081. /// <summary>
  9082. /// 获取三公费用标准city
  9083. /// </summary>
  9084. /// <param name="placeData"></param>
  9085. /// <param name="nationalTravelFeeId"></param>
  9086. /// <returns></returns>
  9087. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9088. {
  9089. string _city = string.Empty;
  9090. if (!placeData.Any()) return _city;
  9091. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9092. if (data == null) return _city;
  9093. string country = data.Country;
  9094. string city = data.City;
  9095. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9096. else _city = city;
  9097. return _city;
  9098. }
  9099. /// <summary>
  9100. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9101. /// </summary>
  9102. /// <returns></returns>
  9103. [HttpPost]
  9104. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9106. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9107. {
  9108. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9109. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9110. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9111. if (_view.Code == 0)
  9112. {
  9113. return Ok(JsonView(true, "操作成功"));
  9114. }
  9115. return Ok(JsonView(false, "操作失败"));
  9116. }
  9117. /// <summary>
  9118. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9119. /// </summary>
  9120. /// <returns></returns>
  9121. [HttpPost]
  9122. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9124. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9125. {
  9126. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9127. if (data.Code != 0)
  9128. {
  9129. return Ok(JsonView(false, data.Msg));
  9130. }
  9131. return Ok(JsonView(true, "操作成功!", data.Data));
  9132. }
  9133. /// <summary>
  9134. /// 三公其他费用草稿 删除
  9135. /// </summary>
  9136. /// <param name="dto"></param>
  9137. /// <returns></returns>
  9138. [HttpPost]
  9139. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9140. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9141. {
  9142. var jw = JsonView(false, "删除失败!");
  9143. var data = new Grp_DayOtherPriceDraft()
  9144. {
  9145. Id = dto.Id,
  9146. IsDel = 1,
  9147. DeleteUserId = dto.DeleteUserId,
  9148. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9149. };
  9150. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9151. if (del > 0)
  9152. {
  9153. jw.Code = 200;
  9154. jw.Msg = "删除成功!";
  9155. }
  9156. return Ok(jw);
  9157. }
  9158. /// <summary>
  9159. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9160. /// </summary>
  9161. /// <returns></returns>
  9162. [HttpPost]
  9163. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9164. {
  9165. var jw = JsonView(false);
  9166. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9167. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9168. jw.Code = StatusCodes.Status200OK;
  9169. jw.Msg = "操作成功!";
  9170. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9171. return Ok(jw);
  9172. }
  9173. /// <summary>
  9174. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9175. /// </summary>
  9176. /// <param name="dto"></param>
  9177. /// <returns></returns>
  9178. [HttpPost]
  9179. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9180. {
  9181. int userId = dto.UserId,
  9182. portId = dto.PortType,
  9183. groupId = dto.GroupId,
  9184. draftId = dto.DraftId;
  9185. _portTypeData.Add(1);
  9186. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9187. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9188. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9189. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9190. _sqlSugar.BeginTran();
  9191. try
  9192. {
  9193. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9194. if (draftDatas == null)
  9195. {
  9196. _sqlSugar.RollbackTran();
  9197. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9198. }
  9199. //验证可覆盖已有数据 两边创建人需为同一人;
  9200. int draftCreateUserId = draftDatas.CreateUserId,
  9201. formalCreateUserId = 0;
  9202. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9203. if (formalData != null)
  9204. {
  9205. formalCreateUserId = formalData.CreateUserId;
  9206. if (draftCreateUserId != formalCreateUserId)
  9207. {
  9208. _sqlSugar.RollbackTran();
  9209. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9210. }
  9211. }
  9212. //默认添加查看、编辑权限(创建人、自己)
  9213. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9214. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9215. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9216. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9217. newExterData.DiId = groupId;
  9218. newExterData.CreateUserId = userId;
  9219. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9220. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9221. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9222. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9223. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9224. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9225. //数据如果存在执行删除
  9226. if (enterExitCostInfo != null)
  9227. {
  9228. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9229. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9230. .Where(x => x.Id == enterExitCostInfo.Id)
  9231. .ExecuteCommand();
  9232. _sqlSugar.Updateable<Grp_DayAndCost>()
  9233. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9234. .Where(x => x.DiId == groupId)
  9235. .ExecuteCommand();
  9236. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9237. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9238. .Where(x => x.Diid == groupId)
  9239. .ExecuteCommand();
  9240. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9241. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9242. .Where(x => x.GroupId == groupId)
  9243. .ExecuteCommand();
  9244. }
  9245. //执行insert
  9246. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9247. if (insertId < 1)
  9248. {
  9249. _sqlSugar.RollbackTran();
  9250. return Ok(JsonView(false, "草稿数据导入失败!"));
  9251. }
  9252. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9253. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9254. #region 默认添加权限
  9255. #endregion
  9256. _sqlSugar.CommitTran();
  9257. //执行操作之后
  9258. //生成默认文件pdf并且通知人员
  9259. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9260. {
  9261. DiId = groupId,
  9262. ExportType = 1,
  9263. SubTypeId = 1005
  9264. }, "pdf");
  9265. //发送通知
  9266. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9267. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9268. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9269. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9270. //汇率信息记录
  9271. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9272. return Ok(JsonView(true));
  9273. }
  9274. catch (Exception ex)
  9275. {
  9276. _sqlSugar.RollbackTran();
  9277. return Ok(JsonView(false, ex.Message));
  9278. }
  9279. }
  9280. #endregion
  9281. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9282. /// <summary>
  9283. /// 获取币种基础数据(含逻辑处理)
  9284. /// </summary>
  9285. /// <returns></returns>
  9286. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9287. {
  9288. return await GeneralMethod.EnterExitCostInitRate();
  9289. }
  9290. /// <summary>
  9291. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9292. /// </summary>
  9293. /// <returns></returns>
  9294. [HttpPost]
  9295. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9296. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9297. {
  9298. //验证城市归属并给默认值
  9299. int provinceId = dto.ProvinceId;
  9300. if (provinceId < 1) provinceId = 122;
  9301. var dataSource = await _sqlSugar
  9302. .Queryable<Sys_SetData>()
  9303. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9304. .ToListAsync();
  9305. var fileTypes = new List<EecSetDataInfoView>();
  9306. //三公费用-Word明细类型
  9307. var wordTypeData = dataSource
  9308. .Where(it => it.STid == 72)
  9309. .Select(x => new EecSetDataInfoView
  9310. {
  9311. ParentId = 1,
  9312. Id = x.Id,
  9313. Name = x.Name
  9314. })
  9315. .ToArray();
  9316. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9317. var excelTypeData = dataSource
  9318. .Where(it => it.STid == 73)
  9319. .Select(x => new EecSetDataInfoView
  9320. {
  9321. ParentId = 2,
  9322. Id = x.Id,
  9323. Name = x.Name
  9324. })
  9325. .ToArray();
  9326. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9327. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9328. fileTypes.Add(groupNameList);
  9329. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9330. //默认币种显示
  9331. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9332. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9333. return Ok(JsonView(true, "查询成功!", new
  9334. {
  9335. FileTypeData = fileTypes,
  9336. CurrencyInit = _currencyInfos,
  9337. viewPermissionData = viewPermissionData
  9338. }));
  9339. }
  9340. /// <summary>
  9341. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9342. /// </summary>
  9343. /// <returns></returns>
  9344. [HttpPost]
  9345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9346. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9347. {
  9348. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9349. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9350. RefAsync<int> total = 0;
  9351. int diId = 0;
  9352. var status = int.TryParse(dto.GroupName, out diId);
  9353. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9354. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9355. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9356. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9357. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9358. .OrderByDescending(x => x.VisitStartDate)
  9359. .Select(x => new EnterExitCostMobileGroupView()
  9360. {
  9361. Id = x.Id,
  9362. GroupName = x.TeamName,
  9363. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9364. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9365. ProvinceId = x.CityId
  9366. })
  9367. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9368. //处理省份Id
  9369. if (data.Any())
  9370. {
  9371. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9372. if (provCityDatas.Any())
  9373. {
  9374. foreach (var item in data)
  9375. {
  9376. var provinceId = item.ProvinceId;
  9377. var isDefualtVal = true;
  9378. if (provinceId > 0)
  9379. {
  9380. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9381. if (parentId != null)
  9382. {
  9383. isDefualtVal = false;
  9384. item.ProvinceId = (int)parentId;
  9385. }
  9386. }
  9387. if (isDefualtVal)
  9388. {
  9389. item.ProvinceId = 122; //默认四川
  9390. }
  9391. }
  9392. }
  9393. }
  9394. //处理是否显示
  9395. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9396. {
  9397. foreach (var item in data)
  9398. {
  9399. item.IsView = true;
  9400. }
  9401. }
  9402. return Ok(JsonView(true, "查询成功!", data, total));
  9403. }
  9404. /// <summary>
  9405. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9406. /// </summary>
  9407. /// <returns></returns>
  9408. [HttpPost]
  9409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9410. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9411. {
  9412. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9413. RefAsync<int> total = 0;
  9414. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9415. .Where(x => x.IsDel == 0 && x.STid == 66)
  9416. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9417. .Select(x => new
  9418. {
  9419. id = x.Id,
  9420. name = x.Name,
  9421. remark = x.Remark,
  9422. })
  9423. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9424. return Ok(JsonView(true, "查询成功!", data, total));
  9425. }
  9426. /// <summary>
  9427. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9428. /// </summary>
  9429. /// <returns></returns>
  9430. [HttpPost]
  9431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9432. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9433. {
  9434. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9435. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9436. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9437. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9438. var groupOtherRateData = groupRateData.TeamRates;
  9439. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9440. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9441. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9442. groupOtherRateData = groupOtherRateData
  9443. .Select(x => new TeamRateDescAddCurrencyIdView
  9444. {
  9445. CurrencyId = x.CurrencyId,
  9446. CurrencyName = x.CurrencyName,
  9447. CurrencyCode = x.CurrencyCode,
  9448. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9449. }).ToList();
  9450. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9451. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9452. }
  9453. /// <summary>
  9454. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9455. /// </summary>
  9456. /// <returns></returns>
  9457. [HttpPost]
  9458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9459. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9460. {
  9461. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9462. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9463. var tipsData = new List<int>() { 1, 2, 3 };
  9464. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9465. if (dto.TipsType == 1)
  9466. {
  9467. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9468. }
  9469. else if (dto.TipsType == 2)
  9470. {
  9471. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9472. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9473. }
  9474. else if (dto.TipsType == 3)
  9475. {
  9476. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9477. return Ok(JsonView(true, "查询成功!", airData));
  9478. }
  9479. return Ok(JsonView(false));
  9480. }
  9481. /// <summary>
  9482. /// 团组模块 - 出入境国家费用标准-移动端 List
  9483. /// </summary>
  9484. /// <returns></returns>
  9485. [HttpPost]
  9486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9487. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9488. {
  9489. Stopwatch sw = new Stopwatch();
  9490. sw.Start();
  9491. int provinceId = dto.ProvinceId;
  9492. if (provinceId < 1) provinceId = 122; // 默认四川
  9493. RefAsync<int> total = 0;
  9494. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9495. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9496. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9497. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9498. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9499. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9500. .Select((ntf, sd, u, sd1) => new
  9501. {
  9502. Id = ntf.Id,
  9503. Area = $"{ntf.Country}-{ntf.City}",
  9504. Currency = ntf.Currency,
  9505. CurrencyCode = sd.Name,
  9506. CurrencyName = sd.Remark,
  9507. RoomCost = ntf.RoomCost,
  9508. FoodCost = ntf.FoodCost,
  9509. PublicCost = ntf.PublicCost,
  9510. TrainCost = ntf.TrainCost,
  9511. LastUpdateUserId = ntf.LastUpdateUserId,
  9512. LastUpdateUserName = u.CnName,
  9513. LastUpdateTime = ntf.LastUpdateTime
  9514. })
  9515. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9516. sw.Stop();
  9517. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9518. }
  9519. /// <summary>
  9520. /// 团组模块 - 出入境费用-移动端 - Info
  9521. /// </summary>
  9522. /// <returns></returns>
  9523. [HttpPost]
  9524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9525. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9526. {
  9527. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9528. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9529. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9530. return Ok(data);
  9531. }
  9532. /// <summary>
  9533. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9534. /// </summary>
  9535. /// <returns></returns>
  9536. [HttpPost]
  9537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9538. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9539. {
  9540. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9541. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9542. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9543. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9544. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9545. mobileInfo.DiId = dto.DiId;
  9546. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9547. if (eecInfo == null) return Ok(mobileInfo);
  9548. //验证查看权限
  9549. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9550. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9551. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9552. mobileInfo.IsAssignPerm = isSet;
  9553. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9554. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9555. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9556. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9557. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9558. {
  9559. SubId = dac.Id,
  9560. DiId = dac.DiId,
  9561. Type = dac.Type,
  9562. Days = dac.Days,
  9563. NationalTravelFeeId = dac.NationalTravelFeeId,
  9564. Arae = $"{ntf.Country}-{ntf.City}",
  9565. Cost = dac.Cost,
  9566. Currency = dac.Currency,
  9567. CurrencyName = sd.Name,
  9568. SubTotal = dac.SubTotal,
  9569. })
  9570. .ToList();
  9571. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9572. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9573. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9574. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9575. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9576. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9577. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9578. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9579. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9580. //其他款项
  9581. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9582. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9583. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9584. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9585. .OrderBy((dop, sd1, sd2) => dop.Index)
  9586. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9587. {
  9588. SubId = dop.Id,
  9589. DiId = dop.Diid,
  9590. Index = dop.Index,
  9591. SetDataId = dop.SetDataId,
  9592. SetDataName = sd1.Name,
  9593. Cost = dop.Cost,
  9594. Currency = dop.Currency,
  9595. CurrencyName = sd2.Remark,
  9596. SubTotal = dop.SubTotal,
  9597. Remark = dop.Remark,
  9598. })
  9599. .ToArray();
  9600. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9601. return Ok(mobileInfo);
  9602. }
  9603. /// <summary>
  9604. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9605. /// </summary>
  9606. /// <returns></returns>
  9607. [HttpPost]
  9608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9609. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9610. {
  9611. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9612. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9613. //验证查看权限
  9614. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9615. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9616. var userIds = await _sqlSugar
  9617. .Queryable<Grp_EnterExitCostPermission>()
  9618. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9619. .Select(x => x.UserId)
  9620. .ToArrayAsync();
  9621. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9622. var perUsersView = new List<dynamic>();
  9623. foreach (var item in perUsers)
  9624. {
  9625. bool isView1 = false;
  9626. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9627. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9628. }
  9629. return Ok(JsonView(perUsersView));
  9630. }
  9631. /// <summary>
  9632. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9633. /// </summary>
  9634. /// <returns></returns>
  9635. [HttpPost]
  9636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9637. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9638. {
  9639. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9640. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9641. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9642. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9643. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9644. //验证查看权限
  9645. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9646. //if (!isView) return Ok(JsonView(false, msg));
  9647. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9648. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9649. var subType = dto.SubType;
  9650. if (subType == 1) //1:境内费用
  9651. {
  9652. var oneData = new ChoiceOneMobileSubInfoView()
  9653. {
  9654. Id = eecInfo.Id,
  9655. ChoiceOne = eecInfo.ChoiceOne,
  9656. ChoiceOneTotalCost = eecInfo.InsidePay,
  9657. Visa = eecInfo.Visa,
  9658. VisaRemark = eecInfo.VisaRemark,
  9659. YiMiao = eecInfo.YiMiao,
  9660. HeSuan = eecInfo.HeSuan,
  9661. Service = eecInfo.Service,
  9662. Ticket = eecInfo.Ticket,
  9663. Safe = eecInfo.Safe,
  9664. FirstItemRemark = eecInfo.FirstItemRemark
  9665. };
  9666. return Ok(JsonView(oneData));
  9667. }
  9668. else if (subType == 2) //2:国际旅费
  9669. {
  9670. var twoData = new ChoiceTwoMobileSubInfoView()
  9671. {
  9672. Id = eecInfo.Id,
  9673. ChoiceTwoJJ = eecInfo.SumJJC,
  9674. OutsideJJPay = eecInfo.OutsideJJPay,
  9675. ChoiceTwoGW = eecInfo.SumGWC,
  9676. OutsideGWPay = eecInfo.OutsideGWPay,
  9677. ChoiceTwoTD = eecInfo.SumTDC,
  9678. OutsideTDPay = eecInfo.OutsideTDPay,
  9679. AirJJ = eecInfo.AirJJ,
  9680. AirGW = eecInfo.AirGW,
  9681. AirTD = eecInfo.AirTD,
  9682. CityTranffic = eecInfo.CityTranffic,
  9683. TwoItemRemark = eecInfo.TwoItemRemark
  9684. };
  9685. return Ok(JsonView(twoData));
  9686. }
  9687. else if (subType == 3) //3:住宿费
  9688. {
  9689. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9690. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9691. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9692. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9693. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9694. {
  9695. SubId = dac.Id,
  9696. DiId = dac.DiId,
  9697. Type = dac.Type,
  9698. Days = dac.Days,
  9699. NationalTravelFeeId = dac.NationalTravelFeeId,
  9700. Arae = $"{ntf.Country}-{ntf.City}",
  9701. Cost = dac.Cost,
  9702. Currency = dac.Currency,
  9703. CurrencyName = sd.Name,
  9704. SubTotal = dac.SubTotal,
  9705. })
  9706. .ToArray();
  9707. var data = new ChoiceMobileSubInfo3To6View()
  9708. {
  9709. ParentId = eecInfo.Id,
  9710. Choice = eecInfo.ChoiceThree,
  9711. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9712. Details = dayAndCostDatas
  9713. };
  9714. return Ok(JsonView(data));
  9715. }
  9716. else if (subType == 4) //4:伙食费
  9717. {
  9718. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9719. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9720. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9721. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9722. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9723. {
  9724. SubId = dac.Id,
  9725. DiId = dac.DiId,
  9726. Type = dac.Type,
  9727. Days = dac.Days,
  9728. NationalTravelFeeId = dac.NationalTravelFeeId,
  9729. Arae = $"{ntf.Country}-{ntf.City}",
  9730. Cost = dac.Cost,
  9731. Currency = dac.Currency,
  9732. CurrencyName = sd.Name,
  9733. SubTotal = dac.SubTotal,
  9734. })
  9735. .ToArray();
  9736. var data = new ChoiceMobileSubInfo3To6View()
  9737. {
  9738. ParentId = eecInfo.Id,
  9739. Choice = eecInfo.ChoiceFour,
  9740. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9741. Details = dayAndCostDatas
  9742. };
  9743. return Ok(JsonView(data));
  9744. }
  9745. else if (subType == 5) //5:公杂费
  9746. {
  9747. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9748. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9749. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9750. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9751. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9752. {
  9753. SubId = dac.Id,
  9754. DiId = dac.DiId,
  9755. Type = dac.Type,
  9756. Days = dac.Days,
  9757. NationalTravelFeeId = dac.NationalTravelFeeId,
  9758. Arae = $"{ntf.Country}-{ntf.City}",
  9759. Cost = dac.Cost,
  9760. Currency = dac.Currency,
  9761. CurrencyName = sd.Name,
  9762. SubTotal = dac.SubTotal,
  9763. })
  9764. .ToArray();
  9765. var data = new ChoiceMobileSubInfo3To6View()
  9766. {
  9767. ParentId = eecInfo.Id,
  9768. Choice = eecInfo.ChoiceFive,
  9769. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9770. Details = dayAndCostDatas
  9771. };
  9772. return Ok(JsonView(data));
  9773. }
  9774. else if (subType == 6) //6:培训费
  9775. {
  9776. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9777. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9778. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9779. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9780. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9781. {
  9782. SubId = dac.Id,
  9783. DiId = dac.DiId,
  9784. Type = dac.Type,
  9785. Days = dac.Days,
  9786. NationalTravelFeeId = dac.NationalTravelFeeId,
  9787. Arae = $"{ntf.Country}-{ntf.City}",
  9788. Cost = dac.Cost,
  9789. Currency = dac.Currency,
  9790. CurrencyName = sd.Name,
  9791. SubTotal = dac.SubTotal,
  9792. })
  9793. .ToArray();
  9794. var data = new ChoiceMobileSubInfo3To6View()
  9795. {
  9796. ParentId = eecInfo.Id,
  9797. Choice = eecInfo.ChoiceSix,
  9798. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9799. Details = dayAndCostDatas
  9800. };
  9801. return Ok(JsonView(data));
  9802. }
  9803. else if (subType == 7) //7:其他
  9804. {
  9805. //其他款项
  9806. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9807. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9808. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9809. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9810. .OrderBy((dop, sd1, sd2) => dop.Index)
  9811. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9812. {
  9813. SubId = dop.Id,
  9814. DiId = dop.Diid,
  9815. Index = dop.Index,
  9816. SetDataId = dop.SetDataId,
  9817. SetDataName = sd1.Name,
  9818. Cost = dop.Cost,
  9819. Currency = dop.Currency,
  9820. CurrencyName = sd2.Name,
  9821. SubTotal = dop.SubTotal,
  9822. Remark = dop.Remark,
  9823. })
  9824. .ToArray();
  9825. var data = new ChoiceSevenMobileSubInfoView()
  9826. {
  9827. ParentId = eecInfo.Id,
  9828. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9829. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9830. Details = otherData
  9831. };
  9832. return Ok(JsonView(data));
  9833. }
  9834. return Ok(JsonView(false));
  9835. }
  9836. #region op
  9837. ///// <summary>
  9838. ///// 移动端更新费用消息通知
  9839. ///// </summary>
  9840. ///// <param name="diid"></param>
  9841. ///// <param name="id"></param>
  9842. ///// <param name="currUserId"></param>
  9843. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9844. //{
  9845. // try
  9846. // {
  9847. // ////生成默认文件pdf并且通知人员
  9848. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9849. // //{
  9850. // // DiId = diid,
  9851. // // ExportType = 1,
  9852. // // SubTypeId = 1005
  9853. // //}, "pdf");
  9854. // ////发送通知
  9855. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9856. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9857. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9858. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9859. // ////汇率信息记录
  9860. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9861. // }
  9862. // catch (Exception ex)
  9863. // {
  9864. // //记录日志
  9865. // throw;
  9866. // }
  9867. //}
  9868. /// <summary>
  9869. /// 验证出入境费用数据是否存在
  9870. /// 不存在添加
  9871. /// </summary>
  9872. /// <param name="diId"></param>
  9873. /// <param name="currUserId"></param>
  9874. /// <returns></returns>
  9875. /// <exception cref="CustomException"></exception>
  9876. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9877. {
  9878. var parentId = 0;
  9879. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9880. if (info != null)
  9881. {
  9882. parentId = info.Id;
  9883. }
  9884. else
  9885. {
  9886. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9887. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9888. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9889. parentId = addId;
  9890. }
  9891. return parentId;
  9892. }
  9893. /// <summary>
  9894. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9895. /// </summary>
  9896. /// <returns></returns>
  9897. [HttpPost]
  9898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9899. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9900. {
  9901. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9902. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9903. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9904. //验证编辑权限
  9905. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9906. //if (!isEdit) return Ok(JsonView(false, msg));
  9907. var permissions = new List<Grp_EnterExitCostPermission>();
  9908. foreach (var userId in dto.UserIds)
  9909. {
  9910. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9911. }
  9912. if (permissions.Any())
  9913. {
  9914. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9915. {
  9916. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9917. }
  9918. _sqlSugar.BeginTran();
  9919. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9920. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9921. if (result < 1)
  9922. {
  9923. _sqlSugar.RollbackTran();
  9924. return Ok(JsonView(false));
  9925. }
  9926. _sqlSugar.CommitTran();
  9927. return Ok(JsonView(true));
  9928. }
  9929. return Ok(JsonView(false));
  9930. }
  9931. /// <summary>
  9932. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9933. /// </summary>
  9934. /// <returns></returns>
  9935. [HttpPost]
  9936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9937. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9938. {
  9939. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9940. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9941. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9942. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9943. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9944. int id = dto.Id;
  9945. if (id <= 0) //add
  9946. {
  9947. //int provinceId = dto.ProvinceId;
  9948. int groupId = dto.DiId;
  9949. //if (provinceId < 1) provinceId = 122;
  9950. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9951. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9952. if (add < 1) return Ok(JsonView(false));
  9953. id = add;
  9954. }
  9955. else //update
  9956. {
  9957. ////验证编辑权限
  9958. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9959. //if (!isEdit) return Ok(JsonView(false, msg));
  9960. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9961. if (upd < 1) return Ok(JsonView(false));
  9962. }
  9963. #region 汇率变更时更改币种相关费用
  9964. var opDayCosts = new List<Grp_DayAndCost>();
  9965. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9966. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9967. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9968. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9969. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9970. .Select((dac, sd) => new
  9971. {
  9972. dac.Id,
  9973. dac.DiId,
  9974. CurrencyCode = sd.Name,
  9975. dac.Cost
  9976. })
  9977. .ToList();
  9978. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9979. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9980. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9981. .Select((dop, sd) => new
  9982. {
  9983. dop.Id,
  9984. dop.Diid,
  9985. CurrencyCode = sd.Name,
  9986. dop.Cost
  9987. })
  9988. .ToList();
  9989. if (dayCosts.Count > 0)
  9990. {
  9991. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9992. foreach (var dc in new_dayCosts)
  9993. {
  9994. var thisCurrency = dc.Key.ToUpper();
  9995. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9996. if (thisRate == 0.00M) continue;
  9997. foreach (var dcSub in dc)
  9998. {
  9999. opDayCosts.Add(new Grp_DayAndCost()
  10000. {
  10001. Id = dcSub.Id,
  10002. DiId = dcSub.DiId,
  10003. Cost = dcSub.Cost,
  10004. SubTotal = dcSub.Cost * thisRate,
  10005. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10006. });
  10007. }
  10008. }
  10009. if (opDayCosts.Count > 0)
  10010. {
  10011. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10012. }
  10013. }
  10014. if (dayOtherCosts.Count > 0)
  10015. {
  10016. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10017. foreach (var dc in new_dayOtherCosts)
  10018. {
  10019. var thisCurrency = dc.Key.ToUpper();
  10020. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10021. if (thisRate == 0.00M) continue;
  10022. foreach (var dcSub in dc)
  10023. {
  10024. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10025. {
  10026. Id = dcSub.Id,
  10027. Diid = dcSub.Diid,
  10028. Cost = dcSub.Cost,
  10029. SubTotal = dcSub.Cost * thisRate,
  10030. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10031. });
  10032. }
  10033. }
  10034. if (opDayOtherCosts.Count > 0)
  10035. {
  10036. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10037. }
  10038. }
  10039. #endregion
  10040. //消息通知
  10041. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10042. //汇率信息记录
  10043. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10044. return Ok(JsonView(new { parentId = id }));
  10045. }
  10046. /// <summary>
  10047. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10048. /// </summary>
  10049. /// <returns></returns>
  10050. [HttpPost]
  10051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10052. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10053. {
  10054. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10055. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10056. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10057. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10058. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10059. int id = dto.Id;
  10060. if (id <= 0) //add
  10061. {
  10062. checkboxInfo.CreateUserId = dto.CurrUserId;
  10063. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10064. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10065. if (add < 1) return Ok(JsonView(false));
  10066. }
  10067. else //update
  10068. {
  10069. ////验证编辑权限
  10070. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10071. //if (!isEdit) return Ok(JsonView(false, msg));
  10072. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10073. .UpdateColumns(x => new
  10074. {
  10075. x.ChoiceOne,
  10076. x.ChoiceTwo,
  10077. x.SumJJC,
  10078. x.SumGWC,
  10079. x.SumTDC,
  10080. x.ChoiceThree,
  10081. x.ChoiceFour,
  10082. x.ChoiceFive,
  10083. x.ChoiceSix,
  10084. x.OtherExpenses_Checked
  10085. })
  10086. .Where(x => x.Id == id)
  10087. .ExecuteCommandAsync();
  10088. if (upd < 1) return Ok(JsonView(false));
  10089. }
  10090. return Ok(JsonView(new { parentId = id }));
  10091. }
  10092. /// <summary>
  10093. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10094. /// </summary>
  10095. /// <returns></returns>
  10096. [HttpPost]
  10097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10098. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10099. {
  10100. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10101. // if (provinceId < 1) provinceId = 122;
  10102. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10103. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10104. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10105. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10106. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10107. var checkboxInfo = new Grp_EnterExitCost()
  10108. {
  10109. Id = id,
  10110. //ProvinceId = provinceId,
  10111. DiId = diId,
  10112. CreateUserId = currUserId
  10113. };
  10114. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10115. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10116. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10117. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10118. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10119. if (id <= 0) //add
  10120. {
  10121. checkboxInfo.CreateUserId = dto.CurrUserId;
  10122. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10123. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10124. if (add < 1) return Ok(JsonView(false));
  10125. }
  10126. else //update
  10127. {
  10128. ////验证编辑权限
  10129. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10130. //if (!isEdit) return Ok(JsonView(false, msg));
  10131. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10132. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10133. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10134. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10135. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10136. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10137. .Where(x => x.Id == id)
  10138. .ExecuteCommandAsync();
  10139. if (upd < 1) return Ok(JsonView(false));
  10140. }
  10141. return Ok(JsonView(new { parentId = id }));
  10142. }
  10143. /// <summary>
  10144. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10145. /// </summary>
  10146. /// <returns></returns>
  10147. [HttpPost]
  10148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10149. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10150. {
  10151. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10152. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10153. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10154. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10155. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10156. info.FirstItemRemark = dto.FirstItemRemark;
  10157. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10158. int id = dto.Id;
  10159. if (id <= 0) //add
  10160. {
  10161. info.CreateUserId = dto.CurrUserId;
  10162. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10163. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10164. if (add < 1) return Ok(JsonView(false));
  10165. id = add;
  10166. }
  10167. else //update
  10168. {
  10169. ////验证编辑权限
  10170. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10171. //if (!isEdit) return Ok(JsonView(false, msg));
  10172. var upd = await _sqlSugar.Updateable(info)
  10173. .UpdateColumns(x => new
  10174. {
  10175. x.ChoiceOne,
  10176. x.InsidePay,
  10177. x.VisaRemark,
  10178. x.Visa,
  10179. x.Service,
  10180. x.Safe,
  10181. x.Ticket,
  10182. x.HeSuan,
  10183. x.YiMiao,
  10184. x.FirstItemRemark
  10185. })
  10186. .Where(x => x.Id == id)
  10187. .ExecuteCommandAsync();
  10188. if (upd < 1) return Ok(JsonView(false));
  10189. }
  10190. //消息通知
  10191. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10192. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10193. }
  10194. /// <summary>
  10195. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10196. /// </summary>
  10197. /// <returns></returns>
  10198. [HttpPost]
  10199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10200. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10201. {
  10202. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10203. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10204. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10205. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10206. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10207. info.DiId = dto.DiId;
  10208. //info.ProvinceId = dto.ProvinceId;
  10209. info.OutsideJJPay = dto.OutsideJJPay;
  10210. info.OutsideGWPay = dto.OutsideGWPay;
  10211. info.OutsideTDPay = dto.OutsideTDPay;
  10212. info.AirJJ = dto.AirJJ;
  10213. info.AirGW = dto.AirGW;
  10214. info.AirTD = dto.AirTD;
  10215. info.CityTranffic = dto.CityTranffic;
  10216. info.TwoItemRemark = dto.TwoItemRemark;
  10217. info.SumJJC = dto.ChoiceTwoJJ;
  10218. info.SumGWC = dto.ChoiceTwoGW;
  10219. info.SumTDC = dto.ChoiceTwoTD;
  10220. int id = dto.Id;
  10221. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10222. if (id <= 0) //add
  10223. {
  10224. info.CreateUserId = dto.CurrUserId;
  10225. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10226. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10227. if (addId <= 0) return Ok(JsonView(false));
  10228. id = addId;
  10229. }
  10230. else //update
  10231. {
  10232. ////验证编辑权限
  10233. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10234. //if (!isEdit) return Ok(JsonView(false, msg));
  10235. var upd = await _sqlSugar.Updateable(info)
  10236. .UpdateColumns(x => new
  10237. {
  10238. x.SumJJC,
  10239. x.OutsideJJPay,
  10240. x.SumGWC,
  10241. x.OutsideGWPay,
  10242. x.SumTDC,
  10243. x.OutsideTDPay,
  10244. x.AirJJ,
  10245. x.AirGW,
  10246. x.AirTD,
  10247. x.CityTranffic,
  10248. x.TwoItemRemark
  10249. })
  10250. .Where(x => x.Id == id)
  10251. .ExecuteCommandAsync();
  10252. if (upd < 1) return Ok(JsonView(false));
  10253. }
  10254. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10255. gwcItemTotal = info.AirGW + info.CityTranffic;
  10256. tdcItemTotal = info.AirTD + info.CityTranffic;
  10257. //消息通知
  10258. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10259. return Ok(JsonView(new
  10260. {
  10261. parentId = id,
  10262. choiceTwoJJ = dto.ChoiceTwoJJ,
  10263. jjcItemTotal = jjcItemTotal,
  10264. choiceTwoGW = dto.ChoiceTwoGW,
  10265. gwcItemTotal = gwcItemTotal,
  10266. choiceTwoTD = dto.ChoiceTwoTD,
  10267. tdcItemTotal = tdcItemTotal
  10268. }));
  10269. }
  10270. /// <summary>
  10271. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10272. /// </summary>
  10273. /// <returns></returns>
  10274. [HttpPost]
  10275. [ApiExplorerSettings(IgnoreApi = true)]
  10276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10277. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10278. {
  10279. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10280. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10281. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10282. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10283. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10284. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10285. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10286. var infos = infos1.Select(x => new Grp_DayAndCost
  10287. {
  10288. Id = x.Id,
  10289. DiId = dto.DiId,
  10290. Type = dto.FeeType,
  10291. Days = x.Days,
  10292. NationalTravelFeeId = x.NationalTravelFeeId,
  10293. Cost = x.Cost,
  10294. Currency = x.Currency,
  10295. SubTotal = x.SubTotal,
  10296. CreateUserId = dto.CurrUserId
  10297. })
  10298. .ToList();
  10299. var adds = infos.Where(x => x.Id <= 0).ToList();
  10300. var upds = infos.Where(x => x.Id > 0).ToList();
  10301. if (adds.Count > 0)
  10302. {
  10303. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10304. if (add < 1) return Ok(JsonView(false));
  10305. }
  10306. if (upds.Count > 0)
  10307. {
  10308. var upd = await _sqlSugar.Updateable(adds)
  10309. .UpdateColumns(x => new
  10310. {
  10311. x.Days,
  10312. x.NationalTravelFeeId,
  10313. x.Cost,
  10314. x.Currency,
  10315. x.SubTotal
  10316. })
  10317. .WhereColumns(x => new { x.Id })
  10318. .ExecuteCommandAsync();
  10319. if (upd < 1) return Ok(JsonView(false));
  10320. }
  10321. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10322. //消息通知
  10323. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10324. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10325. return Ok(JsonView(new { itemTotal = itemTotal }));
  10326. }
  10327. /// <summary>
  10328. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10329. /// </summary>
  10330. /// <returns></returns>
  10331. [HttpPost]
  10332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10333. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10334. {
  10335. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10336. int subId = dto.SubId, feeType = dto.FeeType;
  10337. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10338. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10339. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10340. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10341. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10342. subInfo.Id = subId;
  10343. subInfo.DiId = dto.DiId;
  10344. if (feeType == 3) subInfo.Type = 1;
  10345. else if (feeType == 4) subInfo.Type = 2;
  10346. else if (feeType == 5) subInfo.Type = 3;
  10347. else if (feeType == 6) subInfo.Type = 4;
  10348. subInfo.CreateUserId = dto.CurrUserId;
  10349. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10350. if (parentId < 1) return Ok(JsonView(false));
  10351. //子表op
  10352. if (subId < 1)
  10353. {
  10354. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10355. if (subAdd < 1) return Ok(JsonView(false));
  10356. }
  10357. else
  10358. {
  10359. ////验证编辑权限
  10360. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10361. //if (!isEdit) return Ok(JsonView(false, msg));
  10362. var subUpd = await _sqlSugar.Updateable(subInfo)
  10363. .UpdateColumns(x => new
  10364. {
  10365. x.Days,
  10366. x.NationalTravelFeeId,
  10367. x.Cost,
  10368. x.Currency,
  10369. x.SubTotal
  10370. })
  10371. .WhereColumns(x => new { x.Id })
  10372. .ExecuteCommandAsync();
  10373. if (subUpd < 1) return Ok(JsonView(false));
  10374. }
  10375. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10376. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10377. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10378. }
  10379. /// <summary>
  10380. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10381. /// </summary>
  10382. /// <returns></returns>
  10383. [HttpPost]
  10384. [ApiExplorerSettings(IgnoreApi = true)]
  10385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10386. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10387. {
  10388. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10389. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10390. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10391. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10392. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10393. {
  10394. Id = x.Id,
  10395. Diid = dto.DiId,
  10396. SetDataId = x.SetDataId,
  10397. Index = x.Index,
  10398. Cost = x.Cost,
  10399. Currency = x.Currency,
  10400. SubTotal = x.SubTotal,
  10401. CreateUserId = dto.CurrUserId,
  10402. Remark = x.Remark
  10403. }).ToList();
  10404. var adds = infos.Where(x => x.Id <= 0).ToList();
  10405. var upds = infos.Where(x => x.Id > 0).ToList();
  10406. if (adds.Count > 0)
  10407. {
  10408. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10409. if (add < 1) return Ok(JsonView(false));
  10410. }
  10411. if (upds.Count > 0)
  10412. {
  10413. var upd = await _sqlSugar.Updateable(adds)
  10414. .UpdateColumns(x => new
  10415. {
  10416. x.Index,
  10417. x.SetDataId,
  10418. x.Cost,
  10419. x.Currency,
  10420. x.SubTotal,
  10421. x.Remark
  10422. })
  10423. .WhereColumns(x => new { x.Id })
  10424. .ExecuteCommandAsync();
  10425. if (upd < 1) return Ok(JsonView(false));
  10426. }
  10427. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10428. //消息通知
  10429. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10430. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10431. return Ok(JsonView(new { itemTotal = itemTotal }));
  10432. }
  10433. /// <summary>
  10434. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10435. /// </summary>
  10436. /// <returns></returns>
  10437. [HttpPost]
  10438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10439. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10440. {
  10441. int subId = dto.SubId;
  10442. int diId = dto.Diid;
  10443. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10444. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10445. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10446. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10447. subInfo.Id = subId;
  10448. subInfo.Diid = dto.Diid;
  10449. subInfo.CreateUserId = dto.CurrUserId;
  10450. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10451. if (parentId < 1) return Ok(JsonView(false));
  10452. #region 子表op
  10453. if (subId < 1)//add
  10454. {
  10455. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10456. if (subAdd < 1) return Ok(JsonView(false));
  10457. }
  10458. else //upd
  10459. {
  10460. ////验证编辑权限
  10461. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10462. //if (!isEdit) return Ok(JsonView(false, msg));
  10463. var subUpd = await _sqlSugar.Updateable(subInfo)
  10464. .UpdateColumns(x => new
  10465. {
  10466. x.Index,
  10467. x.SetDataId,
  10468. x.Cost,
  10469. x.Currency,
  10470. x.SubTotal,
  10471. x.Remark
  10472. })
  10473. .WhereColumns(x => new { x.Id })
  10474. .ExecuteCommandAsync();
  10475. if (subUpd < 1) return Ok(JsonView(false));
  10476. }
  10477. #endregion
  10478. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10479. //消息通知
  10480. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10481. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10482. }
  10483. /// <summary>
  10484. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10485. /// </summary>
  10486. /// <returns></returns>
  10487. [HttpPost]
  10488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10489. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10490. {
  10491. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10492. if (data.Code != 0)
  10493. {
  10494. return Ok(JsonView(false, data.Msg));
  10495. }
  10496. return Ok(JsonView(true, "操作成功!", data.Data));
  10497. }
  10498. /// <summary>
  10499. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10500. /// </summary>
  10501. /// <param name="dto"></param>
  10502. /// <returns></returns>
  10503. [HttpPost]
  10504. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10505. {
  10506. var data = new Grp_DayOtherPrice()
  10507. {
  10508. Id = dto.Id,
  10509. IsDel = 1,
  10510. DeleteUserId = dto.DeleteUserId,
  10511. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10512. };
  10513. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10514. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10515. return Ok(JsonView(false, "删除失败!"));
  10516. }
  10517. #endregion
  10518. #endregion
  10519. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10520. /// <summary>
  10521. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10522. /// </summary>
  10523. /// <returns></returns>
  10524. [HttpGet]
  10525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10526. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10527. {
  10528. var provData = await _groupRepository.ProvinceBasicSource();
  10529. return Ok(JsonView(true, "查询成功!", provData));
  10530. }
  10531. /// <summary>
  10532. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10533. /// </summary>
  10534. /// <returns></returns>
  10535. [HttpPost]
  10536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10537. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10538. {
  10539. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10540. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10541. RefAsync<int> total = 0;
  10542. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10543. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10544. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10545. .Select(x => new
  10546. {
  10547. Id = x.Id,
  10548. DraftName = x.DraftName,
  10549. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10550. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10551. .Any()
  10552. })
  10553. .OrderByDescending(x => x.Id)
  10554. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10555. return Ok(JsonView(true, "查询成功!", data, total));
  10556. }
  10557. /// <summary>
  10558. /// 出入境费用-草稿 移动端
  10559. /// 获取币种基础数据(含逻辑处理)
  10560. /// </summary>
  10561. /// <returns></returns>
  10562. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10563. {
  10564. return await GeneralMethod.EnterExitCostInitRate();
  10565. }
  10566. /// <summary>
  10567. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10568. /// </summary>
  10569. /// <returns></returns>
  10570. [HttpPost]
  10571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10572. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10573. {
  10574. //验证城市归属并给默认值
  10575. int provinceId = dto.ProvinceId;
  10576. if (provinceId < 1) provinceId = 122;
  10577. var dataSource = await _sqlSugar
  10578. .Queryable<Sys_SetData>()
  10579. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10580. .ToListAsync();
  10581. //三公费用-Word明细类型
  10582. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10583. .Select(x => new SetDataInfoView
  10584. {
  10585. Id = x.Id,
  10586. Name = x.Name,
  10587. Remark = x.Remark
  10588. })
  10589. .ToList();
  10590. //三公费用-Excel明细类型
  10591. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10592. .Select(x => new SetDataInfoView
  10593. {
  10594. Id = x.Id,
  10595. Name = x.Name,
  10596. Remark = x.Remark
  10597. })
  10598. .ToList();
  10599. //默认币种显示
  10600. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10601. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10602. return Ok(JsonView(true, "查询成功!", new
  10603. {
  10604. WordTypeData = wordTypeData,
  10605. ExcelTypeData = excelTypeData,
  10606. CurrencyInit = _currencyInfos,
  10607. viewPermissionData = viewPermissionData
  10608. }));
  10609. }
  10610. /// <summary>
  10611. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10612. /// </summary>
  10613. /// <returns></returns>
  10614. [HttpPost]
  10615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10616. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10617. {
  10618. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10619. RefAsync<int> total = 0;
  10620. int diId = 0;
  10621. var status = int.TryParse(dto.GroupName, out diId);
  10622. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10623. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10624. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10625. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10626. .OrderByDescending(x => x.VisitStartDate)
  10627. .Select(x => new
  10628. {
  10629. Id = x.Id,
  10630. GroupName = x.TeamName
  10631. })
  10632. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10633. return Ok(JsonView(true, "查询成功!", data, total));
  10634. }
  10635. /// <summary>
  10636. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10637. /// </summary>
  10638. /// <returns></returns>
  10639. [HttpPost]
  10640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10641. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10642. {
  10643. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10644. RefAsync<int> total = 0;
  10645. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10646. .Where(x => x.IsDel == 0 && x.STid == 66)
  10647. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10648. .Select(x => new
  10649. {
  10650. id = x.Id,
  10651. name = x.Name,
  10652. remark = x.Remark,
  10653. })
  10654. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10655. return Ok(JsonView(true, "查询成功!", data, total));
  10656. }
  10657. /// <summary>
  10658. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10659. /// </summary>
  10660. /// <returns></returns>
  10661. [HttpPost]
  10662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10663. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10664. {
  10665. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10666. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10667. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10668. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10669. var groupOtherRateData = groupRateData.TeamRates;
  10670. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10671. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10672. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10673. groupOtherRateData = groupOtherRateData
  10674. .Select(x => new TeamRateDescAddCurrencyIdView
  10675. {
  10676. CurrencyId = x.CurrencyId,
  10677. CurrencyName = x.CurrencyName,
  10678. CurrencyCode = x.CurrencyCode,
  10679. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10680. }).ToList();
  10681. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10682. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10683. }
  10684. /// <summary>
  10685. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10686. /// </summary>
  10687. /// <returns></returns>
  10688. [HttpPost]
  10689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10690. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10691. {
  10692. int portType = dto.PortType;
  10693. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10694. var tipsData = new List<int>() { 1, 2, 3 };
  10695. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10696. if (dto.TipsType == 1)
  10697. {
  10698. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10699. }
  10700. else if (dto.TipsType == 2)
  10701. {
  10702. if (portType == 2)
  10703. {
  10704. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10705. }
  10706. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10707. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10708. .Select(x => x.NationalTravelFeeId)
  10709. .Distinct()
  10710. .ToListAsync();
  10711. if (portType == 2)
  10712. {
  10713. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10714. }
  10715. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10716. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10717. .Select(x => x.Country)
  10718. .Distinct()
  10719. .ToArrayAsync();
  10720. if (portType == 2)
  10721. {
  10722. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10723. }
  10724. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10725. return Ok(JsonView(true, "查询成功!", new
  10726. {
  10727. totalAmt = totalAmt,
  10728. remark = remark
  10729. }));
  10730. }
  10731. else if (dto.TipsType == 3)
  10732. {
  10733. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10734. }
  10735. return Ok(JsonView(false));
  10736. }
  10737. /// <summary>
  10738. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10739. /// </summary>
  10740. /// <returns></returns>
  10741. [HttpPost]
  10742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10743. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10744. {
  10745. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10746. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10747. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10748. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10749. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10750. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10751. var info = new Grp_EnterExitCostDraft()
  10752. {
  10753. ProvinceId = dto.ProvinceId,
  10754. DraftName = dto.DraftName,
  10755. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10756. CreateUserId = dto.CurrUserId
  10757. };
  10758. _sqlSugar.BeginTran();
  10759. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10760. if (draftId < 1)
  10761. {
  10762. _sqlSugar.RollbackTran();
  10763. return Ok(JsonView(false, "草稿创建失败!"));
  10764. }
  10765. //添加默认权限
  10766. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10767. _sqlSugar.CommitTran();
  10768. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10769. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10770. mobileInfo.Id = draftId;
  10771. mobileInfo.DraftName = dto.DraftName;
  10772. mobileInfo.Currencys = rateInfos;
  10773. mobileInfo.IsAssignPerm = assignPerm;
  10774. return Ok(JsonView(mobileInfo));
  10775. }
  10776. /// <summary>
  10777. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10778. /// </summary>
  10779. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10780. /// <summary>
  10781. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10782. /// </summary>
  10783. /// <returns></returns>
  10784. [HttpPost]
  10785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10786. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10787. {
  10788. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10789. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10790. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10791. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10792. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10793. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10794. //验证查看编辑权限
  10795. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10796. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10797. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10798. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10799. mobileInfo.IsAssignPerm = assignPerm;
  10800. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10801. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10802. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10803. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10804. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10805. {
  10806. ParentId = dac.ParentId,
  10807. SubId = dac.Id,
  10808. Type = dac.Type,
  10809. Days = dac.Days,
  10810. NationalTravelFeeId = dac.NationalTravelFeeId,
  10811. Arae = $"{ntf.Country}-{ntf.City}",
  10812. Cost = dac.Cost,
  10813. Currency = dac.Currency,
  10814. CurrencyName = sd.Name,
  10815. SubTotal = dac.SubTotal,
  10816. })
  10817. .ToList();
  10818. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10819. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10820. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10821. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10822. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10823. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10824. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10825. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10826. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10827. //其他款项
  10828. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10829. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10830. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10831. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10832. .OrderBy((dop, sd1, sd2) => dop.Index)
  10833. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10834. {
  10835. ParentId = dop.ParentId,
  10836. SubId = dop.Id,
  10837. Index = dop.Index,
  10838. SetDataId = dop.SetDataId,
  10839. SetDataName = sd1.Name,
  10840. Cost = dop.Cost,
  10841. Currency = dop.Currency,
  10842. CurrencyName = sd2.Remark,
  10843. SubTotal = dop.SubTotal,
  10844. Remark = dop.Remark,
  10845. })
  10846. .ToArray();
  10847. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10848. return Ok(mobileInfo);
  10849. }
  10850. /// <summary>
  10851. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10852. /// </summary>
  10853. /// <returns></returns>
  10854. [HttpPost]
  10855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10856. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10857. {
  10858. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10859. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10860. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10861. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10862. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10863. //验证查看编辑权限
  10864. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10865. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10866. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10867. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10868. var subType = dto.SubType;
  10869. if (subType == 1) //1:境内费用
  10870. {
  10871. var oneData = new ChoiceOneMobileSubInfoView()
  10872. {
  10873. Id = eecInfo.Id,
  10874. ChoiceOne = eecInfo.ChoiceOne,
  10875. ChoiceOneTotalCost = eecInfo.InsidePay,
  10876. Visa = eecInfo.Visa,
  10877. VisaRemark = eecInfo.VisaRemark,
  10878. YiMiao = eecInfo.YiMiao,
  10879. HeSuan = eecInfo.HeSuan,
  10880. Service = eecInfo.Service,
  10881. Ticket = eecInfo.Ticket,
  10882. Safe = eecInfo.Safe,
  10883. FirstItemRemark = eecInfo.FirstItemRemark
  10884. };
  10885. return Ok(JsonView(oneData));
  10886. }
  10887. else if (subType == 2) //2:国际旅费
  10888. {
  10889. var twoData = new ChoiceTwoMobileSubInfoView()
  10890. {
  10891. Id = eecInfo.Id,
  10892. ChoiceTwoJJ = eecInfo.SumJJC,
  10893. OutsideJJPay = eecInfo.OutsideJJPay,
  10894. ChoiceTwoGW = eecInfo.SumGWC,
  10895. OutsideGWPay = eecInfo.OutsideGWPay,
  10896. ChoiceTwoTD = eecInfo.SumTDC,
  10897. OutsideTDPay = eecInfo.OutsideTDPay,
  10898. AirJJ = eecInfo.AirJJ,
  10899. AirGW = eecInfo.AirGW,
  10900. AirTD = eecInfo.AirTD,
  10901. CityTranffic = eecInfo.CityTranffic,
  10902. TwoItemRemark = eecInfo.TwoItemRemark
  10903. };
  10904. return Ok(JsonView(twoData));
  10905. }
  10906. else if (subType == 3) //3:住宿费
  10907. {
  10908. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10909. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10910. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10911. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10912. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10913. {
  10914. ParentId = dac.ParentId,
  10915. SubId = dac.Id,
  10916. Type = dac.Type,
  10917. Days = dac.Days,
  10918. NationalTravelFeeId = dac.NationalTravelFeeId,
  10919. Arae = $"{ntf.Country}-{ntf.City}",
  10920. Cost = dac.Cost,
  10921. Currency = dac.Currency,
  10922. CurrencyName = sd.Name,
  10923. SubTotal = dac.SubTotal,
  10924. })
  10925. .ToArray();
  10926. var data = new ChoiceDraftMobileSubInfo3To6View()
  10927. {
  10928. ParentId = eecInfo.Id,
  10929. Choice = eecInfo.ChoiceThree,
  10930. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10931. Details = dayAndCostDatas
  10932. };
  10933. return Ok(JsonView(data));
  10934. }
  10935. else if (subType == 4) //4:伙食费
  10936. {
  10937. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10938. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10939. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10940. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10941. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10942. {
  10943. ParentId = dac.ParentId,
  10944. SubId = dac.Id,
  10945. Type = dac.Type,
  10946. Days = dac.Days,
  10947. NationalTravelFeeId = dac.NationalTravelFeeId,
  10948. Arae = $"{ntf.Country}-{ntf.City}",
  10949. Cost = dac.Cost,
  10950. Currency = dac.Currency,
  10951. CurrencyName = sd.Name,
  10952. SubTotal = dac.SubTotal,
  10953. })
  10954. .ToArray();
  10955. var data = new ChoiceDraftMobileSubInfo3To6View()
  10956. {
  10957. ParentId = eecInfo.Id,
  10958. Choice = eecInfo.ChoiceFour,
  10959. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10960. Details = dayAndCostDatas
  10961. };
  10962. return Ok(JsonView(data));
  10963. }
  10964. else if (subType == 5) //5:公杂费
  10965. {
  10966. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10967. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10968. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10969. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10970. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10971. {
  10972. ParentId = dac.ParentId,
  10973. SubId = dac.Id,
  10974. Type = dac.Type,
  10975. Days = dac.Days,
  10976. NationalTravelFeeId = dac.NationalTravelFeeId,
  10977. Arae = $"{ntf.Country}-{ntf.City}",
  10978. Cost = dac.Cost,
  10979. Currency = dac.Currency,
  10980. CurrencyName = sd.Name,
  10981. SubTotal = dac.SubTotal,
  10982. })
  10983. .ToArray();
  10984. var data = new ChoiceDraftMobileSubInfo3To6View()
  10985. {
  10986. ParentId = eecInfo.Id,
  10987. Choice = eecInfo.ChoiceFive,
  10988. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10989. Details = dayAndCostDatas
  10990. };
  10991. return Ok(JsonView(data));
  10992. }
  10993. else if (subType == 6) //6:培训费
  10994. {
  10995. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10996. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10997. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10998. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10999. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11000. {
  11001. ParentId = dac.ParentId,
  11002. SubId = dac.Id,
  11003. Type = dac.Type,
  11004. Days = dac.Days,
  11005. NationalTravelFeeId = dac.NationalTravelFeeId,
  11006. Arae = $"{ntf.Country}-{ntf.City}",
  11007. Cost = dac.Cost,
  11008. Currency = dac.Currency,
  11009. CurrencyName = sd.Name,
  11010. SubTotal = dac.SubTotal,
  11011. })
  11012. .ToArray();
  11013. var data = new ChoiceDraftMobileSubInfo3To6View()
  11014. {
  11015. ParentId = eecInfo.Id,
  11016. Choice = eecInfo.ChoiceSix,
  11017. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11018. Details = dayAndCostDatas
  11019. };
  11020. return Ok(JsonView(data));
  11021. }
  11022. else if (subType == 7) //7:其他
  11023. {
  11024. //其他款项
  11025. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11026. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11027. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11028. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11029. .OrderBy((dop, sd1, sd2) => dop.Index)
  11030. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11031. {
  11032. ParentId = dop.ParentId,
  11033. SubId = dop.Id,
  11034. Index = dop.Index,
  11035. SetDataId = dop.SetDataId,
  11036. SetDataName = sd1.Name,
  11037. Cost = dop.Cost,
  11038. Currency = dop.Currency,
  11039. CurrencyName = sd2.Name,
  11040. SubTotal = dop.SubTotal,
  11041. Remark = dop.Remark,
  11042. })
  11043. .ToArray();
  11044. var data = new ChoiceSevenDraftMobileSubInfoView()
  11045. {
  11046. ParentId = eecInfo.Id,
  11047. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11048. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11049. Details = otherData
  11050. };
  11051. return Ok(JsonView(data));
  11052. }
  11053. return Ok(JsonView(false));
  11054. }
  11055. #region op
  11056. ///// <summary>
  11057. ///// 移动端更新费用消息通知
  11058. ///// </summary>
  11059. ///// <param name="draftId"></param>
  11060. ///// <param name="id"></param>
  11061. ///// <param name="currUserId"></param>
  11062. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11063. //{
  11064. // try
  11065. // {
  11066. // ////生成默认文件pdf并且通知人员
  11067. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11068. // //{
  11069. // // DiId = draftId,
  11070. // // ExportType = 1,
  11071. // // SubTypeId = 1005
  11072. // //}, "pdf");
  11073. // ////发送通知
  11074. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11075. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11076. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11077. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11078. // ////汇率信息记录
  11079. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11080. // }
  11081. // catch (Exception ex)
  11082. // {
  11083. // //记录日志
  11084. // throw;
  11085. // }
  11086. //}
  11087. /// <summary>
  11088. /// 验证出入境费用数据是否存在
  11089. /// 不存在添加
  11090. /// </summary>
  11091. /// <param name="draftId"></param>
  11092. /// <param name="currUserId"></param>
  11093. /// <returns></returns>
  11094. /// <exception cref="CustomException"></exception>
  11095. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11096. {
  11097. var parentId = 0;
  11098. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11099. if (info != null) parentId = info.Id;
  11100. else
  11101. {
  11102. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11103. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11104. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11105. parentId = addId;
  11106. }
  11107. return parentId;
  11108. }
  11109. /// <summary>
  11110. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11111. /// </summary>
  11112. /// <returns></returns>
  11113. [HttpPost]
  11114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11115. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11116. {
  11117. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11118. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11119. //验证查看权限
  11120. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11121. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11122. var userIds = await _sqlSugar
  11123. .Queryable<Grp_EnterExitCostDraftPermission>()
  11124. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11125. .Select(x => x.UserId)
  11126. .ToArrayAsync();
  11127. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11128. var perUsersView = new List<dynamic>();
  11129. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11130. var viewPermissionData = new List<PermissionViewUserview>();
  11131. if (feeBasePerm.Any())
  11132. {
  11133. foreach (var item in feeBasePerm)
  11134. {
  11135. if (item.Users.Any())
  11136. {
  11137. viewPermissionData.AddRange(item.Users);
  11138. }
  11139. }
  11140. }
  11141. foreach (var item in perUsers)
  11142. {
  11143. bool isView1 = false;
  11144. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11145. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11146. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11147. }
  11148. return Ok(JsonView(perUsersView));
  11149. }
  11150. /// <summary>
  11151. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11152. /// </summary>
  11153. /// <returns></returns>
  11154. [HttpPost]
  11155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11156. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11157. {
  11158. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11159. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11160. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11161. //验证查看编辑权限
  11162. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11163. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11164. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11165. foreach (var userId in dto.UserIds)
  11166. {
  11167. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11168. }
  11169. if (permissions.Any())
  11170. {
  11171. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11172. {
  11173. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11174. }
  11175. _sqlSugar.BeginTran();
  11176. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11177. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11178. if (result < 1)
  11179. {
  11180. _sqlSugar.RollbackTran();
  11181. return Ok(JsonView(false));
  11182. }
  11183. _sqlSugar.CommitTran();
  11184. return Ok(JsonView(true));
  11185. }
  11186. return Ok(JsonView(false));
  11187. }
  11188. /// <summary>
  11189. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11190. /// </summary>
  11191. /// <returns></returns>
  11192. [HttpPost]
  11193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11194. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11195. {
  11196. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11197. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11198. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11199. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11200. int id = dto.DraftId;
  11201. if (id <= 0) //add
  11202. {
  11203. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11204. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11205. if (add < 1) return Ok(JsonView(false));
  11206. id = add;
  11207. }
  11208. else //update
  11209. {
  11210. //验证查看编辑权限
  11211. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11212. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11213. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11214. if (upd < 1) return Ok(JsonView(false));
  11215. }
  11216. return Ok(JsonView(new { parentId = id }));
  11217. }
  11218. /// <summary>
  11219. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11220. /// </summary>
  11221. /// <returns></returns>
  11222. [HttpPost]
  11223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11224. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11225. {
  11226. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11227. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11228. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11229. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11230. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11231. int id = dto.DraftId;
  11232. if (id <= 0) //add
  11233. {
  11234. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11235. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11236. if (add < 1) return Ok(JsonView(false));
  11237. id = add;
  11238. }
  11239. else //update
  11240. {
  11241. //验证查看编辑权限
  11242. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11243. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11244. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11245. if (upd < 1) return Ok(JsonView(false));
  11246. }
  11247. #region 汇率变更时更改币种相关费用
  11248. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11249. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11250. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11251. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11252. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11253. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11254. .Select((dac, sd) => new
  11255. {
  11256. dac.Id,
  11257. dac.ParentId,
  11258. CurrencyCode = sd.Name,
  11259. dac.Cost
  11260. })
  11261. .ToList();
  11262. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11263. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11264. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11265. .Select((dop, sd) => new
  11266. {
  11267. dop.Id,
  11268. dop.ParentId,
  11269. CurrencyCode = sd.Name,
  11270. dop.Cost
  11271. })
  11272. .ToList();
  11273. if (dayCosts.Count > 0)
  11274. {
  11275. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11276. foreach (var dc in new_dayCosts)
  11277. {
  11278. var thisCurrency = dc.Key.ToUpper();
  11279. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11280. if (thisRate == 0.00M) continue;
  11281. foreach (var dcSub in dc)
  11282. {
  11283. opDayCosts.Add(new Grp_DayAndCostDraft()
  11284. {
  11285. Id = dcSub.Id,
  11286. ParentId = dcSub.ParentId,
  11287. Cost = dcSub.Cost,
  11288. SubTotal = dcSub.Cost * thisRate,
  11289. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11290. });
  11291. }
  11292. }
  11293. if (opDayCosts.Count > 0)
  11294. {
  11295. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11296. }
  11297. }
  11298. if (dayOtherCosts.Count > 0)
  11299. {
  11300. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11301. foreach (var dc in new_dayOtherCosts)
  11302. {
  11303. var thisCurrency = dc.Key.ToUpper();
  11304. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11305. if (thisRate == 0.00M) continue;
  11306. foreach (var dcSub in dc)
  11307. {
  11308. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11309. {
  11310. Id = dcSub.Id,
  11311. ParentId = dcSub.ParentId,
  11312. Cost = dcSub.Cost,
  11313. SubTotal = dcSub.Cost * thisRate,
  11314. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11315. });
  11316. }
  11317. }
  11318. if (opDayOtherCosts.Count > 0)
  11319. {
  11320. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11321. }
  11322. }
  11323. #endregion
  11324. ////消息通知
  11325. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11326. ////汇率信息记录
  11327. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11328. return Ok(JsonView(new { parentId = id }));
  11329. }
  11330. /// <summary>
  11331. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11332. /// </summary>
  11333. /// <returns></returns>
  11334. [HttpPost]
  11335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11336. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11337. {
  11338. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11339. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11340. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11341. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11342. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11343. int id = dto.DraftId;
  11344. if (id <= 0) //add
  11345. {
  11346. checkboxInfo.ProvinceId = dto.ProvinceId;
  11347. checkboxInfo.CreateUserId = dto.CurrUserId;
  11348. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11349. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11350. if (add < 1) return Ok(JsonView(false));
  11351. }
  11352. else //update
  11353. {
  11354. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11355. .UpdateColumns(x => new
  11356. {
  11357. x.ChoiceOne,
  11358. x.ChoiceTwo,
  11359. x.SumJJC,
  11360. x.SumGWC,
  11361. x.SumTDC,
  11362. x.ChoiceThree,
  11363. x.ChoiceFour,
  11364. x.ChoiceFive,
  11365. x.ChoiceSix,
  11366. x.OtherExpenses_Checked
  11367. })
  11368. .Where(x => x.Id == id)
  11369. .ExecuteCommandAsync();
  11370. if (upd < 1) return Ok(JsonView(false));
  11371. }
  11372. return Ok(JsonView(new { parentId = id }));
  11373. }
  11374. /// <summary>
  11375. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11376. /// </summary>
  11377. /// <returns></returns>
  11378. [HttpPost]
  11379. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11380. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11381. {
  11382. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11383. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11384. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11385. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11386. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11387. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11388. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11389. var checkboxInfo = new Grp_EnterExitCostDraft()
  11390. {
  11391. Id = draftId,
  11392. ProvinceId = dto.ProvinceId,
  11393. CreateUserId = currUserId
  11394. };
  11395. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11396. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11397. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11398. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11399. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11400. if (draftId <= 0) //add
  11401. {
  11402. checkboxInfo.CreateUserId = dto.CurrUserId;
  11403. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11404. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11405. if (add < 1) return Ok(JsonView(false));
  11406. }
  11407. else //update
  11408. {
  11409. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11410. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11411. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11412. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11413. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11414. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11415. .Where(x => x.Id == draftId)
  11416. .ExecuteCommandAsync();
  11417. if (upd < 1) return Ok(JsonView(false));
  11418. }
  11419. return Ok(JsonView(new { parentId = draftId }));
  11420. }
  11421. /// <summary>
  11422. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11423. /// </summary>
  11424. /// <returns></returns>
  11425. [HttpPost]
  11426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11427. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11428. {
  11429. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11430. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11431. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11432. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11433. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11434. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11435. info.ProvinceId = dto.ProvinceId;
  11436. info.FirstItemRemark = dto.FirstItemRemark;
  11437. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11438. if (id <= 0) //add
  11439. {
  11440. info.CreateUserId = dto.CurrUserId;
  11441. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11442. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11443. if (add < 1) return Ok(JsonView(false));
  11444. id = add;
  11445. }
  11446. else //update
  11447. {
  11448. var upd = await _sqlSugar.Updateable(info)
  11449. .UpdateColumns(x => new
  11450. {
  11451. x.ChoiceOne,
  11452. x.InsidePay,
  11453. x.VisaRemark,
  11454. x.Visa,
  11455. x.Service,
  11456. x.Safe,
  11457. x.Ticket,
  11458. x.HeSuan,
  11459. x.YiMiao,
  11460. x.FirstItemRemark
  11461. })
  11462. .Where(x => x.Id == id)
  11463. .ExecuteCommandAsync();
  11464. if (upd < 1) return Ok(JsonView(false));
  11465. }
  11466. ////消息通知
  11467. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11468. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11469. }
  11470. /// <summary>
  11471. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11472. /// </summary>
  11473. /// <returns></returns>
  11474. [HttpPost]
  11475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11476. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11477. {
  11478. int id = dto.DraftId;
  11479. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11480. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11481. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11482. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11483. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11484. info.ProvinceId = dto.ProvinceId;
  11485. info.OutsideJJPay = dto.OutsideJJPay;
  11486. info.OutsideGWPay = dto.OutsideGWPay;
  11487. info.OutsideTDPay = dto.OutsideTDPay;
  11488. info.AirJJ = dto.AirJJ;
  11489. info.AirGW = dto.AirGW;
  11490. info.AirTD = dto.AirTD;
  11491. info.CityTranffic = dto.CityTranffic;
  11492. info.TwoItemRemark = dto.TwoItemRemark;
  11493. info.SumJJC = dto.ChoiceTwoJJ;
  11494. info.SumGWC = dto.ChoiceTwoGW;
  11495. info.SumTDC = dto.ChoiceTwoTD;
  11496. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11497. if (id <= 0) //add
  11498. {
  11499. info.CreateUserId = dto.CurrUserId;
  11500. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11501. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11502. if (addId <= 0) return Ok(JsonView(false));
  11503. id = addId;
  11504. }
  11505. else //update
  11506. {
  11507. var upd = await _sqlSugar.Updateable(info)
  11508. .UpdateColumns(x => new
  11509. {
  11510. x.SumJJC,
  11511. x.OutsideJJPay,
  11512. x.SumGWC,
  11513. x.OutsideGWPay,
  11514. x.SumTDC,
  11515. x.OutsideTDPay,
  11516. x.AirJJ,
  11517. x.AirGW,
  11518. x.AirTD,
  11519. x.CityTranffic,
  11520. x.TwoItemRemark
  11521. })
  11522. .Where(x => x.Id == id)
  11523. .ExecuteCommandAsync();
  11524. if (upd < 1) return Ok(JsonView(false));
  11525. }
  11526. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11527. gwcItemTotal = info.AirGW + info.CityTranffic;
  11528. tdcItemTotal = info.AirTD + info.CityTranffic;
  11529. ////消息通知
  11530. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11531. return Ok(JsonView(new
  11532. {
  11533. parentId = id,
  11534. choiceTwoJJ = dto.ChoiceTwoJJ,
  11535. jjcItemTotal = jjcItemTotal,
  11536. choiceTwoGW = dto.ChoiceTwoGW,
  11537. gwcItemTotal = gwcItemTotal,
  11538. choiceTwoTD = dto.ChoiceTwoTD,
  11539. tdcItemTotal = tdcItemTotal
  11540. }));
  11541. }
  11542. /// <summary>
  11543. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11544. /// </summary>
  11545. /// <returns></returns>
  11546. [HttpPost]
  11547. [ApiExplorerSettings(IgnoreApi = true)]
  11548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11549. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11550. {
  11551. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11552. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11553. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11554. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11555. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11556. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11557. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11558. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11559. {
  11560. Id = x.Id,
  11561. ParentId = dto.DraftId,
  11562. Type = dto.FeeType,
  11563. Days = x.Days,
  11564. NationalTravelFeeId = x.NationalTravelFeeId,
  11565. Cost = x.Cost,
  11566. Currency = x.Currency,
  11567. SubTotal = x.SubTotal,
  11568. CreateUserId = dto.CurrUserId
  11569. })
  11570. .ToList();
  11571. var adds = infos.Where(x => x.Id <= 0).ToList();
  11572. var upds = infos.Where(x => x.Id > 0).ToList();
  11573. if (adds.Count > 0)
  11574. {
  11575. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11576. if (add < 1) return Ok(JsonView(false));
  11577. }
  11578. if (upds.Count > 0)
  11579. {
  11580. var upd = await _sqlSugar.Updateable(adds)
  11581. .UpdateColumns(x => new
  11582. {
  11583. x.Days,
  11584. x.NationalTravelFeeId,
  11585. x.Cost,
  11586. x.Currency,
  11587. x.SubTotal
  11588. })
  11589. .WhereColumns(x => new { x.Id })
  11590. .ExecuteCommandAsync();
  11591. if (upd < 1) return Ok(JsonView(false));
  11592. }
  11593. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11594. ////消息通知
  11595. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11596. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11597. return Ok(JsonView(new { itemTotal = itemTotal }));
  11598. }
  11599. /// <summary>
  11600. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11601. /// </summary>
  11602. /// <returns></returns>
  11603. [HttpPost]
  11604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11605. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11606. {
  11607. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11608. int subId = dto.SubId, feeType = dto.FeeType;
  11609. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11610. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11611. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11612. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11613. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11614. subInfo.Id = subId;
  11615. subInfo.ParentId = dto.DraftId;
  11616. if (feeType == 3) subInfo.Type = 1;
  11617. else if (feeType == 4) subInfo.Type = 2;
  11618. else if (feeType == 5) subInfo.Type = 3;
  11619. else if (feeType == 6) subInfo.Type = 4;
  11620. subInfo.CreateUserId = dto.CurrUserId;
  11621. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11622. if (parentId < 1) return Ok(JsonView(false));
  11623. //子表op
  11624. if (subId < 1)
  11625. {
  11626. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11627. if (subAdd < 1) return Ok(JsonView(false));
  11628. }
  11629. else
  11630. {
  11631. var subUpd = await _sqlSugar.Updateable(subInfo)
  11632. .UpdateColumns(x => new
  11633. {
  11634. x.Days,
  11635. x.NationalTravelFeeId,
  11636. x.Cost,
  11637. x.Currency,
  11638. x.SubTotal
  11639. })
  11640. .WhereColumns(x => new { x.Id })
  11641. .ExecuteCommandAsync();
  11642. if (subUpd < 1) return Ok(JsonView(false));
  11643. }
  11644. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11645. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11646. }
  11647. /// <summary>
  11648. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11649. /// </summary>
  11650. /// <returns></returns>
  11651. [HttpPost]
  11652. [ApiExplorerSettings(IgnoreApi = true)]
  11653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11654. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11655. {
  11656. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11657. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11658. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11659. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11660. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11661. {
  11662. Id = x.Id,
  11663. ParentId = dto.DraftId,
  11664. SetDataId = x.SetDataId,
  11665. Index = x.Index,
  11666. Cost = x.Cost,
  11667. Currency = x.Currency,
  11668. SubTotal = x.SubTotal,
  11669. CreateUserId = dto.CurrUserId,
  11670. Remark = x.Remark
  11671. }).ToList();
  11672. var adds = infos.Where(x => x.Id <= 0).ToList();
  11673. var upds = infos.Where(x => x.Id > 0).ToList();
  11674. if (adds.Count > 0)
  11675. {
  11676. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11677. if (add < 1) return Ok(JsonView(false));
  11678. }
  11679. if (upds.Count > 0)
  11680. {
  11681. var upd = await _sqlSugar.Updateable(adds)
  11682. .UpdateColumns(x => new
  11683. {
  11684. x.Index,
  11685. x.SetDataId,
  11686. x.Cost,
  11687. x.Currency,
  11688. x.SubTotal,
  11689. x.Remark
  11690. })
  11691. .WhereColumns(x => new { x.Id })
  11692. .ExecuteCommandAsync();
  11693. if (upd < 1) return Ok(JsonView(false));
  11694. }
  11695. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11696. //消息通知
  11697. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11698. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11699. return Ok(JsonView(new { itemTotal = itemTotal }));
  11700. }
  11701. /// <summary>
  11702. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11703. /// </summary>
  11704. /// <returns></returns>
  11705. [HttpPost]
  11706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11707. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11708. {
  11709. int subId = dto.SubId, id = dto.DraftId;
  11710. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11711. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11712. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11713. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11714. subInfo.Id = subId;
  11715. subInfo.ParentId = id;
  11716. subInfo.CreateUserId = dto.CurrUserId;
  11717. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11718. if (parentId < 1) return Ok(JsonView(false));
  11719. #region 子表op
  11720. if (subId < 1)//add
  11721. {
  11722. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11723. if (subAdd < 1) return Ok(JsonView(false));
  11724. }
  11725. else //upd
  11726. {
  11727. var subUpd = await _sqlSugar.Updateable(subInfo)
  11728. .UpdateColumns(x => new
  11729. {
  11730. x.Index,
  11731. x.SetDataId,
  11732. x.Cost,
  11733. x.Currency,
  11734. x.SubTotal,
  11735. x.Remark
  11736. })
  11737. .WhereColumns(x => new { x.Id })
  11738. .ExecuteCommandAsync();
  11739. if (subUpd < 1) return Ok(JsonView(false));
  11740. }
  11741. #endregion
  11742. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11743. ////消息通知
  11744. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11745. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11746. }
  11747. /// <summary>
  11748. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11749. /// </summary>
  11750. /// <returns></returns>
  11751. [HttpPost]
  11752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11753. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11754. {
  11755. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11756. if (data.Code != 0)
  11757. {
  11758. return Ok(JsonView(false, data.Msg));
  11759. }
  11760. return Ok(JsonView(true, "操作成功!", data.Data));
  11761. }
  11762. /// <summary>
  11763. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11764. /// </summary>
  11765. /// <param name="dto"></param>
  11766. /// <returns></returns>
  11767. [HttpPost]
  11768. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11769. {
  11770. var data = new Grp_DayOtherPriceDraft()
  11771. {
  11772. Id = dto.Id,
  11773. IsDel = 1,
  11774. DeleteUserId = dto.DeleteUserId,
  11775. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11776. };
  11777. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11778. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11779. return Ok(JsonView(false, "删除失败!"));
  11780. }
  11781. #endregion
  11782. #endregion
  11783. #region 团组经理模块 出入境费用报价表
  11784. /// <summary>
  11785. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11786. /// </summary>
  11787. /// <returns></returns>
  11788. [HttpPost]
  11789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11790. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11791. {
  11792. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11793. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11794. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11795. initRates.Insert(0, cnyInfo);
  11796. liveRates.Insert(0, cnyInfo);
  11797. return Ok(JsonView(true, "查询成功!", new
  11798. {
  11799. InitRates = initRates,
  11800. LiveRates = liveRates
  11801. }));
  11802. }
  11803. /// <summary>
  11804. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11805. /// </summary>
  11806. /// <returns></returns>
  11807. [HttpPost]
  11808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11809. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11810. {
  11811. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11812. }
  11813. /// <summary>
  11814. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11815. /// </summary>
  11816. /// <returns></returns>
  11817. [HttpPost]
  11818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11819. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11820. {
  11821. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11822. }
  11823. /// <summary>
  11824. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11825. /// </summary>
  11826. /// <returns></returns>
  11827. [HttpPost]
  11828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11829. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11830. {
  11831. int groupId = dto.DiId,
  11832. currUserId = dto.CurrUserId;
  11833. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11834. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11835. //验证报价数据是否存在
  11836. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11837. if (isNull != null)
  11838. {
  11839. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11840. if (!info1.Rates.Any())
  11841. {
  11842. var rates = await GeneralMethod.EnterExitCostInitRate();
  11843. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11844. info1.Rates = rates.ToArray();
  11845. }
  11846. return Ok(JsonView(info1));
  11847. }
  11848. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11849. result.GroupId = groupId;
  11850. //处理报价名称
  11851. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11852. if (groupInfo != null)
  11853. {
  11854. var visitCountry = groupInfo.VisitCountry;
  11855. if (!string.IsNullOrEmpty(visitCountry))
  11856. {
  11857. string quoteName = string.Empty;
  11858. if (visitCountry.Contains("|"))
  11859. {
  11860. var countrys = visitCountry.Split("|");
  11861. quoteName = string.Join("、", countrys);
  11862. }
  11863. else quoteName = visitCountry;
  11864. quoteName += $"团组报价表";
  11865. result.Name = quoteName;
  11866. }
  11867. }
  11868. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11869. if (info.Code != StatusCodes.Status200OK)
  11870. {
  11871. if (!result.Rates.Any())
  11872. {
  11873. var rates = await GeneralMethod.EnterExitCostInitRate();
  11874. result.Rates = rates.ToArray();
  11875. }
  11876. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11877. }
  11878. var infoView = info.Data as EnterExitCostInfoView;
  11879. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11880. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11881. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11882. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11883. var eecRates = infoView.Currencys;
  11884. //默认添加人名币
  11885. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  11886. {
  11887. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11888. }
  11889. //处理团组人数
  11890. int pplNum = 1;
  11891. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11892. var views = new List<QuoteSubItemInfo>();
  11893. #region 数据填充
  11894. var intTravelCosts = new List<QuoteSubItemInfo>();
  11895. #region 机票费用 1354
  11896. int intTravelIndex = 1;
  11897. if (infoView.SumJJC == 1)
  11898. {
  11899. intTravelCosts.Add(new QuoteSubItemInfo
  11900. {
  11901. ItemId = 1354,
  11902. Index = intTravelIndex,
  11903. FeeName = "经济舱",
  11904. UnitPrice = infoView.AirJJ,
  11905. Currency = "CNY",
  11906. Quantity = 1,
  11907. PplNum = 1,
  11908. TotalAmt = infoView.AirJJ,
  11909. Remark = "",
  11910. });
  11911. intTravelIndex++;
  11912. }
  11913. if (infoView.SumGWC == 1)
  11914. {
  11915. intTravelCosts.Add(new QuoteSubItemInfo
  11916. {
  11917. ItemId = 1354,
  11918. Index = intTravelIndex,
  11919. FeeName = "公务舱",
  11920. UnitPrice = infoView.AirGW,
  11921. Currency = "CNY",
  11922. Quantity = 1,
  11923. PplNum = 1,
  11924. TotalAmt = infoView.AirGW,
  11925. Remark = "",
  11926. });
  11927. intTravelIndex++;
  11928. }
  11929. if (infoView.SumTDC == 1)
  11930. {
  11931. intTravelCosts.Add(new QuoteSubItemInfo
  11932. {
  11933. ItemId = 1354,
  11934. Index = intTravelIndex,
  11935. FeeName = "头等舱",
  11936. UnitPrice = infoView.AirTD,
  11937. Currency = "CNY",
  11938. Quantity = 1,
  11939. PplNum = 1,
  11940. TotalAmt = infoView.AirTD,
  11941. Remark = "",
  11942. });
  11943. intTravelIndex++;
  11944. }
  11945. intTravelCosts.Add(new QuoteSubItemInfo
  11946. {
  11947. ItemId = 1354,
  11948. Index = intTravelIndex,
  11949. FeeName = "城市间交通费用",
  11950. UnitPrice = infoView.CityTranffic,
  11951. Currency = "CNY",
  11952. Quantity = 1,
  11953. PplNum = pplNum,
  11954. TotalAmt = infoView.CityTranffic * pplNum,
  11955. Remark = "",
  11956. });
  11957. views.AddRange(intTravelCosts);
  11958. #endregion
  11959. var accomCosts = new List<QuoteSubItemInfo>();
  11960. #region 住宿费 1355
  11961. if (infoView.QuarterageData.Any())
  11962. {
  11963. int accomIndex = 1;
  11964. int accomItemTypeId = 1355;
  11965. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11966. foreach (var item in groupData)
  11967. {
  11968. string feeName = string.Empty;
  11969. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11970. if (countryInfo != null)
  11971. {
  11972. feeName = countryInfo.Country;
  11973. var city = countryInfo.City;
  11974. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11975. {
  11976. feeName += $"-{city}";
  11977. }
  11978. }
  11979. var hotelInfo = item.FirstOrDefault();
  11980. if (hotelInfo == null) continue;
  11981. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11982. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11983. int quantity = item.ToList().Count;
  11984. accomCosts.Add(new QuoteSubItemInfo
  11985. {
  11986. ItemId = accomItemTypeId,
  11987. Index = accomIndex,
  11988. FeeName = feeName,
  11989. UnitPrice = hotelInfo.Cost,
  11990. Currency = thisCurrency,
  11991. Quantity = quantity,
  11992. PplNum = pplNum,
  11993. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11994. Remark = "",
  11995. });
  11996. accomIndex++;
  11997. }
  11998. views.AddRange(accomCosts);
  11999. }
  12000. #endregion
  12001. var mealCosts = new List<QuoteSubItemInfo>();
  12002. #region 餐饮费 1356
  12003. if (infoView.BoardWagesData.Any())
  12004. {
  12005. var mealIndex = 1;
  12006. int mealItemTypeId = 1356;
  12007. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12008. foreach (var item in groupData)
  12009. {
  12010. string feeName = string.Empty;
  12011. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12012. if (countryInfo != null)
  12013. {
  12014. feeName = countryInfo.Country;
  12015. var city = countryInfo.City;
  12016. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12017. {
  12018. feeName += $"-{city}";
  12019. }
  12020. }
  12021. var mealInfo = item.FirstOrDefault();
  12022. if (mealInfo == null) continue;
  12023. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12024. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12025. int quantity = item.ToList().Count;
  12026. mealCosts.Add(new QuoteSubItemInfo
  12027. {
  12028. ItemId = mealItemTypeId,
  12029. Index = mealIndex,
  12030. FeeName = feeName,
  12031. UnitPrice = mealInfo.Cost,
  12032. Currency = thisCurrency,
  12033. Quantity = quantity,
  12034. PplNum = pplNum,
  12035. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12036. Remark = "",
  12037. });
  12038. mealIndex++;
  12039. }
  12040. views.AddRange(mealCosts);
  12041. }
  12042. #endregion
  12043. var miscCosts = new List<QuoteSubItemInfo>();
  12044. #region 公杂费 1364
  12045. if (infoView.MiscellaneousFeeData.Any())
  12046. {
  12047. var miscIndex = 1;
  12048. int miscItemTypeId = 1364;
  12049. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12050. foreach (var item in groupData)
  12051. {
  12052. string feeName = string.Empty;
  12053. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12054. if (countryInfo != null)
  12055. {
  12056. feeName = countryInfo.Country;
  12057. var city = countryInfo.City;
  12058. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12059. {
  12060. feeName += $"-{city}";
  12061. }
  12062. }
  12063. var miscInfo = item.FirstOrDefault();
  12064. if (miscInfo == null) continue;
  12065. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12066. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12067. int quantity = item.ToList().Count;
  12068. miscCosts.Add(new QuoteSubItemInfo
  12069. {
  12070. ItemId = miscItemTypeId,
  12071. Index = miscIndex,
  12072. FeeName = feeName,
  12073. UnitPrice = miscInfo.Cost,
  12074. Currency = thisCurrency,
  12075. Quantity = quantity,
  12076. PplNum = pplNum,
  12077. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12078. Remark = "",
  12079. });
  12080. miscIndex++;
  12081. }
  12082. views.AddRange(miscCosts);
  12083. }
  12084. #endregion
  12085. #region 签证+保险 1362
  12086. int visaInsIndex = 1;
  12087. int visaInsItemTypeId = 1362;
  12088. if (infoView.Visa > 0)
  12089. {
  12090. views.Add(new QuoteSubItemInfo()
  12091. {
  12092. ItemId = visaInsItemTypeId,
  12093. Index = visaInsIndex,
  12094. FeeName = $"签证",
  12095. UnitPrice = infoView.Visa,
  12096. Currency = $"CNY",
  12097. Quantity = 1,
  12098. PplNum = pplNum,
  12099. TotalAmt = infoView.Visa * pplNum,
  12100. Remark = "",
  12101. });
  12102. visaInsIndex++;
  12103. }
  12104. if (infoView.Safe > 0)
  12105. {
  12106. views.Add(new QuoteSubItemInfo()
  12107. {
  12108. ItemId = visaInsItemTypeId,
  12109. Index = visaInsIndex,
  12110. FeeName = $"保险",
  12111. UnitPrice = infoView.Safe,
  12112. Currency = $"CNY",
  12113. Quantity = 1,
  12114. PplNum = pplNum,
  12115. TotalAmt = infoView.Safe * pplNum,
  12116. Remark = "",
  12117. });
  12118. }
  12119. #endregion
  12120. #region 服务费 1363
  12121. int serviceFeeIndex = 1;
  12122. int serviceFeeItemTypeId = 1363;
  12123. if (infoView.Service > 0)
  12124. {
  12125. views.Add(new QuoteSubItemInfo()
  12126. {
  12127. ItemId = serviceFeeItemTypeId,
  12128. Index = serviceFeeIndex,
  12129. FeeName = $"服务费",
  12130. UnitPrice = infoView.Service,
  12131. Currency = $"CNY",
  12132. Quantity = 1,
  12133. PplNum = pplNum,
  12134. TotalAmt = infoView.Service * pplNum,
  12135. Remark = "",
  12136. });
  12137. }
  12138. #endregion
  12139. #endregion
  12140. if (result.FeeItems.Any())
  12141. {
  12142. result.FeeItems.Select(x =>
  12143. {
  12144. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12145. if (feeInfos.Any()) x.Infos = feeInfos;
  12146. return x;
  12147. }
  12148. ).OrderBy(x => x.Index)
  12149. .ToList();
  12150. if (!result.Rates.Any())
  12151. {
  12152. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12153. else
  12154. {
  12155. var rates = await GeneralMethod.EnterExitCostInitRate();
  12156. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12157. result.Rates = rates.ToArray();
  12158. }
  12159. }
  12160. }
  12161. return Ok(JsonView(result));
  12162. }
  12163. /// <summary>
  12164. /// 团组模块 - 出入境费用报价表 - Info
  12165. /// </summary>
  12166. /// <returns></returns>
  12167. [HttpPost]
  12168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12169. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12170. {
  12171. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12172. if (!info.Rates.Any())
  12173. {
  12174. var rates = await GeneralMethod.EnterExitCostInitRate();
  12175. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12176. info.Rates = rates.ToArray();
  12177. }
  12178. return Ok(JsonView(info));
  12179. }
  12180. /// <summary>
  12181. /// 团组模块 - 出入境费用报价表 - OP
  12182. /// </summary>
  12183. /// <returns></returns>
  12184. [HttpPost]
  12185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12186. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12187. {
  12188. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12189. }
  12190. /// <summary>
  12191. /// 团组模块 - 出入境费用报价表 - 删除 项
  12192. /// </summary>
  12193. /// <returns></returns>
  12194. [HttpPost]
  12195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12196. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12197. {
  12198. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12199. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12200. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12201. }
  12202. /// <summary>
  12203. /// 团组模块 - 出入境费用报价表 - 导出
  12204. /// </summary>
  12205. /// <returns></returns>
  12206. [HttpPost]
  12207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12208. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12209. {
  12210. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12211. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12212. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12213. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12214. var rates = info.Rates;
  12215. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12216. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12217. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12218. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12219. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12220. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12221. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12222. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12223. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12224. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12225. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12226. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12227. //获取模板
  12228. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12229. var designer = new WorkbookDesigner();
  12230. designer.Workbook = new Workbook(tempPath);
  12231. designer.SetDataSource("QuoteName", info.Name);
  12232. designer.SetDataSource("CompanyTitle", "公司名称");
  12233. designer.SetDataSource("CompanyLabel", "");
  12234. #region 国际旅费
  12235. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12236. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12237. {
  12238. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12239. var label = new StringBuilder();
  12240. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12241. if (infos.Any())
  12242. {
  12243. label.Append(infos.Sum(x => x.PplNum));
  12244. label.Append("人全程机票:");
  12245. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12246. label.AppendLine("元");
  12247. }
  12248. foreach (var item in intTravelCosts.Infos)
  12249. {
  12250. label.Append(item.FeeName);
  12251. label.Append(":");
  12252. label.Append(item.UnitPrice.TruncDecimals(2));
  12253. label.Append("元/人*");
  12254. label.Append(item.PplNum);
  12255. label.AppendLine("人");
  12256. }
  12257. if (label.HasValue())
  12258. {
  12259. label.Append("\r\n以上小计:");
  12260. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12261. label.Append("元");
  12262. }
  12263. designer.SetDataSource("IntTravelLabel", label.ToString());
  12264. }
  12265. #endregion
  12266. #region 住宿费
  12267. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12268. if (accomCosts != null && accomCosts.Infos.Any())
  12269. {
  12270. string currencyName = string.Empty,
  12271. countryName = string.Empty;
  12272. decimal rate = 1.0000M;
  12273. var label = new StringBuilder();
  12274. label.AppendLine("全程五星酒店,每人1间房");
  12275. foreach (var item in accomCosts.Infos)
  12276. {
  12277. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12278. string name = string.Empty, thisCountryName = string.Empty;
  12279. if (item.FeeName.Contains('-'))
  12280. {
  12281. var feeName = item.FeeName.Split('-');
  12282. thisCountryName = feeName[0];
  12283. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12284. name = feeName[1];
  12285. }
  12286. else name = item.FeeName;
  12287. string thisFeeName = string.Empty;
  12288. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12289. else thisFeeName = $"\r\n{name}:";
  12290. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12291. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12292. rate = rateInfo?.Rate ?? 1.0000M;
  12293. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12294. label.AppendLine(subLabel);
  12295. }
  12296. if (label.HasValue())
  12297. {
  12298. //以上小计:52440元(美金汇率:7.5 )
  12299. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12300. label.AppendLine(subLabel);
  12301. }
  12302. designer.SetDataSource("AccomLabel", label.ToString());
  12303. }
  12304. #endregion
  12305. #region 餐饮费
  12306. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12307. if (mealCosts != null && mealCosts.Infos.Any())
  12308. {
  12309. string currencyName = string.Empty;
  12310. decimal rate = 1.0000M;
  12311. var label = new StringBuilder();
  12312. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12313. foreach (var item in mealCosts.Infos)
  12314. {
  12315. string name = string.Empty;
  12316. if (item.FeeName.Contains('-'))
  12317. {
  12318. var feeName = item.FeeName.Split('-');
  12319. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12320. }
  12321. else name = $"\r\n{item.FeeName}:";
  12322. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12323. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12324. rate = rateInfo?.Rate ?? 1.0000M;
  12325. label.Append(name);
  12326. label.Append(item.UnitPrice.TruncDecimals(2));
  12327. label.Append(currencyName);
  12328. label.Append("/天*");
  12329. label.Append(item.Quantity.ToString("#0"));
  12330. label.Append('*');
  12331. label.Append(item.PplNum);
  12332. label.Append("人\r\n");
  12333. }
  12334. if (label.HasValue())
  12335. {
  12336. label.Append("\r\n以上小计:");
  12337. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12338. label.Append("元\r\n(");
  12339. label.Append("汇率:");
  12340. label.Append(rate.TruncDecimals(4));
  12341. label.Append(')');
  12342. }
  12343. designer.SetDataSource("MealLabel", label.ToString());
  12344. }
  12345. #endregion
  12346. #region 车辆安排
  12347. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12348. if (vehArranges != null && vehArranges.Infos.Any())
  12349. {
  12350. string currencyName = string.Empty;
  12351. //decimal rate = 1.0000M;
  12352. var label = new StringBuilder();
  12353. foreach (var item in vehArranges.Infos)
  12354. {
  12355. label.AppendLine();
  12356. label.AppendLine();
  12357. label.Append(item.FeeName);
  12358. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12359. }
  12360. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12361. }
  12362. #endregion
  12363. #region 邀请函发放对象
  12364. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12365. designer.SetDataSource("InviteToContent", "");
  12366. #endregion
  12367. #region 邀请函费
  12368. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12369. var is_label = new StringBuilder();
  12370. if (inviteCosts != null && inviteCosts.Infos.Any())
  12371. {
  12372. string currencyName = string.Empty;
  12373. decimal rate = 1.0000M;
  12374. foreach (var item in inviteCosts.Infos)
  12375. {
  12376. //乌兹别克斯坦:2000美金
  12377. currencyName = item.Currency;
  12378. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12379. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12380. is_label.AppendLine(label);
  12381. }
  12382. if (is_label.HasValue())
  12383. {
  12384. //以上小计:28500元(美金汇率:7.5)
  12385. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12386. is_label.AppendLine(label);
  12387. }
  12388. }
  12389. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12390. #endregion
  12391. #region 邀请函发放时间
  12392. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12393. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12394. #endregion
  12395. #region 公务活动(含翻译)
  12396. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12397. var oa_label = new StringBuilder();
  12398. if (officialActs != null && officialActs.Infos.Any())
  12399. {
  12400. string currencyName = string.Empty;
  12401. decimal rate = 1.0000M;
  12402. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12403. foreach (var item in officialActs.Infos)
  12404. {
  12405. //乌兹别克斯坦:1000美金/场
  12406. currencyName = item.Currency;
  12407. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12408. string label_remark = string.Empty;
  12409. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12410. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12411. }
  12412. label_content += "*总费用中未含超出公务活动价格";
  12413. //8场公务活动(以上小计:60000元)
  12414. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12415. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12416. oa_label.AppendLine(label_title);
  12417. oa_label.AppendLine(label_content);
  12418. }
  12419. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12420. #endregion
  12421. #region 签证+保险
  12422. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12423. var vi_label = new StringBuilder();
  12424. if (visaIns != null && visaIns.Infos.Any())
  12425. {
  12426. foreach (var item in visaIns.Infos)
  12427. {
  12428. //签证:500元/人
  12429. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12430. vi_label.AppendLine(label);
  12431. }
  12432. if (vi_label.HasValue())
  12433. {
  12434. //以上小计:6000元
  12435. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12436. vi_label.AppendLine(label);
  12437. }
  12438. }
  12439. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12440. #endregion
  12441. #region 服务费
  12442. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12443. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12444. #endregion
  12445. #region 公杂费
  12446. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12447. var pm_label = new StringBuilder();
  12448. if (pubMiscs != null && pubMiscs.Infos.Any())
  12449. {
  12450. string currencyName = string.Empty,
  12451. countryName = string.Empty;
  12452. decimal rate = 1.0000M;
  12453. foreach (var item in pubMiscs.Infos)
  12454. {
  12455. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12456. string name = string.Empty, thisCountryName = string.Empty;
  12457. if (item.FeeName.Contains('-'))
  12458. {
  12459. var feeName = item.FeeName.Split('-');
  12460. thisCountryName = feeName[0];
  12461. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12462. name = feeName[1];
  12463. }
  12464. else name = item.FeeName;
  12465. string thisFeeName = string.Empty;
  12466. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12467. else thisFeeName = $"\r\n{name}:";
  12468. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12469. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12470. rate = rateInfo?.Rate ?? 1.0000M;
  12471. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12472. pm_label.AppendLine(label);
  12473. }
  12474. if (pm_label.HasValue())
  12475. {
  12476. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12477. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12478. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12479. pm_label.AppendLine(string.Format("部分发放成员"));
  12480. }
  12481. }
  12482. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12483. #endregion
  12484. #region 税费
  12485. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12486. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12487. #endregion
  12488. #region 合计(单位:元)
  12489. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12490. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12491. #endregion
  12492. #region 汇率 Remark
  12493. var rate_label = new StringBuilder();
  12494. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12495. foreach (var item in rateGroups)
  12496. {
  12497. //美元汇率按\r\n1:7.5
  12498. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12499. rate_label.AppendLine(label);
  12500. }
  12501. designer.SetDataSource("RateLabel", rate_label.ToString());
  12502. #endregion
  12503. designer.Process();
  12504. //文件名
  12505. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12506. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12507. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12508. return Ok(JsonView(true, "成功", url));
  12509. }
  12510. #endregion
  12511. #region 签证费用录入
  12512. /// <summary>
  12513. /// 根据diid查询签证费用列表
  12514. /// </summary>
  12515. /// <param name="dto"></param>
  12516. /// <returns></returns>
  12517. [HttpPost]
  12518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12519. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12520. {
  12521. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12522. if (groupData.Code != 0)
  12523. {
  12524. return Ok(JsonView(false, groupData.Msg));
  12525. }
  12526. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12527. }
  12528. /// <summary>
  12529. /// 根据签证费用Id查询单条数据及c表数据
  12530. /// </summary>
  12531. /// <param name="dto"></param>
  12532. /// <returns></returns>
  12533. [HttpPost]
  12534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12535. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12536. {
  12537. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12538. if (groupData.Code != 0)
  12539. {
  12540. return Ok(JsonView(false, groupData.Msg));
  12541. }
  12542. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12543. }
  12544. /// <summary>
  12545. /// 签证费用删除
  12546. /// </summary>
  12547. /// <param name="dto"></param>
  12548. /// <returns></returns>
  12549. [HttpPost]
  12550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12551. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12552. {
  12553. _sqlSugar.BeginTran();
  12554. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12555. if (!res)
  12556. {
  12557. _sqlSugar.RollbackTran();
  12558. return Ok(JsonView(false, "删除失败"));
  12559. }
  12560. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12561. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12562. .SetColumns(a => new Grp_CreditCardPayment()
  12563. {
  12564. IsDel = 1,
  12565. DeleteUserId = dto.DeleteUserId,
  12566. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12567. })
  12568. .ExecuteCommand();
  12569. if (resSub < 1)
  12570. {
  12571. _sqlSugar.RollbackTran();
  12572. return Ok(JsonView(false, "删除失败"));
  12573. }
  12574. _sqlSugar.CommitTran();
  12575. return Ok(JsonView(true, "删除成功!"));
  12576. }
  12577. /// <summary>
  12578. /// 签证费用录入下拉框初始化
  12579. /// </summary>
  12580. /// <returns></returns>
  12581. [HttpPost]
  12582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12583. public async Task<IActionResult> VisaPriceAddSelect()
  12584. {
  12585. //支付方式
  12586. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12587. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12588. //币种
  12589. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12590. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12591. //乘客类型
  12592. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12593. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12594. //卡类型
  12595. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12596. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12597. //代办费类型
  12598. var agencyFeeTypeData = new List<dynamic>() {
  12599. new { id = 0 , Text = "未选择" },
  12600. new { id = 1 , Text = "小公务" },
  12601. new { id = 2 , Text = "大公务" },
  12602. };
  12603. //签证费用标准国家Data
  12604. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12605. var data = new
  12606. {
  12607. Payment = _Payment,
  12608. CurrencyList = _CurrencyList,
  12609. PassengerType = _PassengerType,
  12610. BankCard = _BankCard,
  12611. AgencyFeeType = agencyFeeTypeData,
  12612. CountryFeeData = visaCountryFeeData
  12613. };
  12614. return Ok(JsonView(true, "查询成功!", data));
  12615. }
  12616. /// <summary>
  12617. /// 签证费用录入操作(Status:1.新增,2.修改)
  12618. /// </summary>
  12619. /// <param name="dto"></param>
  12620. /// <returns></returns>
  12621. [HttpPost]
  12622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12623. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12624. {
  12625. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12626. if (groupData.Code != 0)
  12627. {
  12628. return Ok(JsonView(false, groupData.Msg));
  12629. }
  12630. #region 应用推送
  12631. try
  12632. {
  12633. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12634. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12635. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12636. //2024-10-21 新增LZ UID
  12637. var userIds = new List<int>() { 21 };
  12638. string title = $"系统通知";
  12639. string content = "";
  12640. var diId = dto.DiId;
  12641. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12642. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12643. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12644. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12645. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12646. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12647. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12648. }
  12649. catch (Exception ex)
  12650. {
  12651. }
  12652. #endregion
  12653. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12654. }
  12655. #endregion
  12656. #region 签证提成录入
  12657. /// <summary>
  12658. /// 签证提成录入
  12659. /// 基础数据
  12660. /// </summary>
  12661. /// <returns></returns>
  12662. [HttpGet]
  12663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12664. public async Task<IActionResult> VisaCommissionInit()
  12665. {
  12666. return Ok(await _visaCommissionRep.Init());
  12667. }
  12668. /// <summary>
  12669. /// 签证提成录入
  12670. /// Item
  12671. /// </summary>
  12672. /// <param name="_dto"></param>
  12673. /// <returns></returns>
  12674. [HttpPost]
  12675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12676. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12677. {
  12678. var validator = new VisaCommissionItemDtoValidator();
  12679. var validatorRes = await validator.ValidateAsync(_dto);
  12680. if (!validatorRes.IsValid)
  12681. {
  12682. var sb = new StringBuilder();
  12683. foreach (var item in validatorRes.Errors)
  12684. {
  12685. sb.AppendLine(item.ErrorMessage);
  12686. }
  12687. return Ok(JsonView(false, sb.ToString()));
  12688. }
  12689. return Ok(await _visaCommissionRep.Item(_dto));
  12690. }
  12691. /// <summary>
  12692. /// 签证提成录入
  12693. /// Save
  12694. /// </summary>
  12695. /// <param name="_dto"></param>
  12696. /// <returns></returns>
  12697. [HttpPost]
  12698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12699. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12700. {
  12701. //参数验证
  12702. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12703. foreach (var item in _dto.Items)
  12704. {
  12705. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12706. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12707. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12708. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12709. }
  12710. return Ok(await _visaCommissionRep.Save(_dto));
  12711. }
  12712. /// <summary>
  12713. /// 签证提成录入
  12714. /// Create
  12715. /// </summary>
  12716. /// <param name="_dto"></param>
  12717. /// <returns></returns>
  12718. [HttpPost]
  12719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12720. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12721. {
  12722. var validator = new VisaCommissionCreateDtoValidator();
  12723. var validatorRes = await validator.ValidateAsync(_dto);
  12724. if (!validatorRes.IsValid)
  12725. {
  12726. var sb = new StringBuilder();
  12727. foreach (var item in validatorRes.Errors)
  12728. {
  12729. sb.AppendLine(item.ErrorMessage);
  12730. }
  12731. return Ok(JsonView(false, sb.ToString()));
  12732. }
  12733. return Ok(await _visaCommissionRep.Create(_dto));
  12734. }
  12735. /// <summary>
  12736. /// 签证提成录入
  12737. /// Put(编辑)
  12738. /// </summary>
  12739. /// <param name="id"></param>
  12740. /// <param name="_dto"></param>
  12741. /// <returns></returns>
  12742. [HttpPut]
  12743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12744. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12745. {
  12746. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12747. var validator = new VisaCommissionCreateDtoValidator();
  12748. var validatorRes = await validator.ValidateAsync(_dto);
  12749. if (!validatorRes.IsValid)
  12750. {
  12751. var sb = new StringBuilder();
  12752. foreach (var item in validatorRes.Errors)
  12753. {
  12754. sb.AppendLine(item.ErrorMessage);
  12755. }
  12756. return Ok(JsonView(false, sb.ToString()));
  12757. }
  12758. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12759. }
  12760. /// <summary>
  12761. /// 签证提成录入
  12762. /// Del
  12763. /// </summary>
  12764. /// <param name="id"></param>
  12765. /// <param name="currUserId"></param>
  12766. /// <returns></returns>
  12767. [HttpPost]
  12768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12769. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12770. {
  12771. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12772. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12773. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12774. }
  12775. #endregion
  12776. #region op费用录入
  12777. /// <summary>
  12778. /// 根据diid查询op费用列表
  12779. /// </summary>
  12780. /// <param name="dto"></param>
  12781. /// <returns></returns>
  12782. [HttpPost]
  12783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12784. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12785. {
  12786. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12787. if (groupData.Code != 0)
  12788. {
  12789. return Ok(JsonView(false, groupData.Msg));
  12790. }
  12791. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12792. }
  12793. /// <summary>
  12794. /// 根据op费用Id查询单条数据及c表数据
  12795. /// </summary>
  12796. /// <param name="dto"></param>
  12797. /// <returns></returns>
  12798. [HttpPost]
  12799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12800. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12801. {
  12802. try
  12803. {
  12804. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12805. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12806. var data = new
  12807. {
  12808. CarTouristGuideGround = _groupData,
  12809. CreditCardPayment = _creditCardPayment
  12810. };
  12811. return Ok(JsonView(true, "查询成功!", data));
  12812. }
  12813. catch (Exception ex)
  12814. {
  12815. return Ok(JsonView(false, "程序错误!"));
  12816. }
  12817. }
  12818. /// <summary>
  12819. /// op费用删除
  12820. /// </summary>
  12821. /// <param name="dto"></param>
  12822. /// <returns></returns>
  12823. [HttpPost]
  12824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12825. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12826. {
  12827. try
  12828. {
  12829. _sqlSugar.BeginTran();
  12830. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12831. if (!res)
  12832. {
  12833. return Ok(JsonView(false, "删除失败"));
  12834. }
  12835. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12836. {
  12837. IsDel = 1,
  12838. DeleteUserId = dto.DeleteUserId,
  12839. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12840. }).ExecuteCommandAsync();
  12841. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12842. {
  12843. IsDel = 1,
  12844. DeleteUserId = dto.DeleteUserId,
  12845. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12846. }).ExecuteCommandAsync();
  12847. #region 删除超支相关数据
  12848. //删除导入的超支数据
  12849. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12850. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12851. {
  12852. IsDel = 1,
  12853. DeleteUserId = dto.DeleteUserId,
  12854. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12855. }).ExecuteCommand();
  12856. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12857. {
  12858. IsDel = 1,
  12859. DeleteUserId = dto.DeleteUserId,
  12860. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12861. }).ExecuteCommand();
  12862. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12863. {
  12864. IsDel = 1,
  12865. DeleteUserId = dto.DeleteUserId,
  12866. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12867. }).ExecuteCommand();
  12868. #endregion
  12869. _sqlSugar.CommitTran();
  12870. return Ok(JsonView(true, "删除成功!"));
  12871. }
  12872. catch (Exception ex)
  12873. {
  12874. _sqlSugar.RollbackTran();
  12875. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12876. }
  12877. }
  12878. /// <summary>
  12879. /// op费用录入操作(Status:1.新增,2.修改)
  12880. /// </summary>
  12881. /// <param name="dto"></param>
  12882. /// <returns></returns>
  12883. [HttpPost]
  12884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12885. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12886. {
  12887. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12888. if (groupData.Code != 0)
  12889. {
  12890. return Ok(JsonView(false, groupData.Msg));
  12891. }
  12892. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12893. }
  12894. /// <summary>
  12895. /// 填写费用详细页面初始化绑定
  12896. /// </summary>
  12897. /// <param name="dto"></param>
  12898. /// <returns></returns>
  12899. [HttpPost]
  12900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12901. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12902. {
  12903. try
  12904. {
  12905. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12906. if (groupData.Code != 0)
  12907. {
  12908. return Ok(JsonView(false, groupData.Msg));
  12909. }
  12910. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12911. }
  12912. catch (Exception ex)
  12913. {
  12914. return Ok(JsonView(false, ex.Message));
  12915. }
  12916. }
  12917. /// <summary>
  12918. /// 根据op费用Id查询详细数据
  12919. /// </summary>
  12920. /// <param name="dto"></param>
  12921. /// <returns></returns>
  12922. [HttpPost]
  12923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12924. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12925. {
  12926. try
  12927. {
  12928. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12929. if (groupData.Code != 0)
  12930. {
  12931. return Ok(JsonView(false, groupData.Msg));
  12932. }
  12933. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12934. }
  12935. catch (Exception ex)
  12936. {
  12937. return Ok(JsonView(false, ex.Message));
  12938. }
  12939. }
  12940. /// <summary>
  12941. /// OP费用录入填写详情
  12942. /// </summary>
  12943. /// <param name="dto"></param>
  12944. /// <returns></returns>
  12945. [HttpPost]
  12946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12947. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12948. {
  12949. try
  12950. {
  12951. #region 参数校验
  12952. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12953. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12954. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12955. #endregion
  12956. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12957. if (groupData.Code != 0)
  12958. {
  12959. return Ok(JsonView(false, groupData.Msg));
  12960. }
  12961. //自动审核
  12962. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12963. #region 应用推送
  12964. try
  12965. {
  12966. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12967. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12968. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12969. //2024-10-21 新增LZ UID
  12970. var userIds = new List<int>() { 21 };
  12971. string title = $"系统通知";
  12972. var diId = dto.DiId;
  12973. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12974. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12975. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12976. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12977. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  12978. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12979. }
  12980. catch (Exception ex)
  12981. {
  12982. }
  12983. #endregion
  12984. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12985. }
  12986. catch (Exception ex)
  12987. {
  12988. return Ok(JsonView(false, ex.Message));
  12989. }
  12990. }
  12991. /// <summary>
  12992. /// 获取三公详细所有城市
  12993. /// </summary>
  12994. /// <returns></returns>
  12995. [HttpGet]
  12996. public IActionResult OpCarCityResult()
  12997. {
  12998. var jw = JsonView(false);
  12999. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13000. {
  13001. x.Id,
  13002. x.Country,
  13003. x.City,
  13004. }).ToList();
  13005. if (data.Count > 0)
  13006. {
  13007. jw = JsonView(true, "获取成功!", data);
  13008. }
  13009. else
  13010. {
  13011. jw.Msg = "城市数据为空!";
  13012. jw.Data = Array.Empty<string>();
  13013. }
  13014. return Ok(jw);
  13015. }
  13016. /// <summary>
  13017. /// 导出地接费用明细
  13018. /// </summary>
  13019. /// <param name="dto"></param>
  13020. /// <returns></returns>
  13021. [HttpPost]
  13022. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13023. {
  13024. var jw = JsonView(false);
  13025. if (dto.Diid < 1)
  13026. {
  13027. jw.Msg = "请输入正确的diid!";
  13028. return Ok(jw);
  13029. }
  13030. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13031. if (group == null)
  13032. {
  13033. jw.Msg = "未找到团组信息!";
  13034. return Ok(jw);
  13035. }
  13036. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13037. if (localGuideArr.Count == 0)
  13038. {
  13039. jw.Msg = "该团组暂无地接信息!";
  13040. return Ok(jw);
  13041. }
  13042. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13043. var overspendSoure = new Dictionary<int, int>
  13044. {
  13045. { 91, 982 }, //车
  13046. { 92 , 1059} ,//导游
  13047. { 994 , 1073}, //翻译
  13048. { 988 , 1074 }, //早餐
  13049. { 93 , 1075 }, //午餐
  13050. { 989 , 1076 }, //晚餐
  13051. };
  13052. var Zips = new Dictionary<string, Stream>();
  13053. foreach (var groupArr in localGroup)
  13054. {
  13055. var keyValue = groupArr.Key;
  13056. if (int.TryParse(keyValue, out int cityid))
  13057. {
  13058. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13059. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13060. }
  13061. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13062. foreach (var item in groupArr)
  13063. {
  13064. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13065. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13066. new Grp_CarTouristGuideGroundReservationsContentExtend
  13067. {
  13068. Count = a.Count,
  13069. CreateTime = a.CreateTime,
  13070. CreateUserId = a.CreateUserId,
  13071. CTGGRId = a.CTGGRId,
  13072. Currency = a.Currency,
  13073. DatePrice = a.DatePrice,
  13074. DeleteTime = a.DeleteTime,
  13075. DeleteUserId = a.DeleteUserId,
  13076. DiId = a.DiId,
  13077. Id = a.Id,
  13078. IsDel = a.IsDel,
  13079. Price = a.Price,
  13080. PriceContent = a.PriceContent,
  13081. Remark = a.Remark,
  13082. SId = a.SId,
  13083. SidName = b.Name,
  13084. Units = a.Units,
  13085. }
  13086. ).ToList();
  13087. if (content.Count > 0)
  13088. {
  13089. contentArr.Add(content);
  13090. }
  13091. }
  13092. //open excel
  13093. //set excel
  13094. //save excel
  13095. try
  13096. {
  13097. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13098. IWorkbook workbook;
  13099. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13100. {
  13101. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13102. }
  13103. else
  13104. {
  13105. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13106. }
  13107. ISheet sheet = workbook.GetSheetAt(0);
  13108. var rowStartIndex = 2;
  13109. var clounmCount = 10;
  13110. var initStyleRow = sheet.GetRow(2);
  13111. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13112. //var overspendArrDetail =
  13113. var existsId = new List<CarCompare>();
  13114. var lastElem = arr.Last();
  13115. var thisSid = -1;
  13116. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13117. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13118. {
  13119. Name = "未知币种!",
  13120. Remark = "未知币种!",
  13121. };
  13122. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13123. Action cloneRowFn = () =>
  13124. {
  13125. rowStartIndex++;
  13126. var cloneRow = sheet.CreateRow(rowStartIndex);
  13127. // 复制样式
  13128. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13129. {
  13130. ICell sourceCell = initStyleRow.GetCell(i);
  13131. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13132. // 确保单元格存在样式
  13133. if (sourceCell.CellStyle != null)
  13134. {
  13135. targetCell.CellStyle = sourceCell.CellStyle;
  13136. }
  13137. }
  13138. };
  13139. var mergeRow = () =>
  13140. {
  13141. for (int i = 2; i < sheet.LastRowNum; i++)
  13142. {
  13143. var row = sheet.GetRow(i);
  13144. var cellFirst = row.GetCell(0);
  13145. var thisIndex = i + 1;
  13146. while (thisIndex < sheet.LastRowNum)
  13147. {
  13148. var nextRow = sheet.GetRow(thisIndex);
  13149. var nextCellFirst = nextRow.GetCell(0);
  13150. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13151. {
  13152. thisIndex++;
  13153. }
  13154. else
  13155. {
  13156. break;
  13157. }
  13158. }
  13159. thisIndex--;
  13160. if (thisIndex != i)
  13161. {
  13162. //合并row
  13163. var cellRangeAddress = new CellRangeAddress(
  13164. i, // 起始行索引(0-based)
  13165. thisIndex, // 结束行索引(0-based)
  13166. 0, // 起始列索引(0-based)
  13167. 0 // 结束列索引(0-based)
  13168. );
  13169. sheet.AddMergedRegion(cellRangeAddress);
  13170. i = thisIndex;
  13171. }
  13172. }
  13173. };
  13174. var chaoshiNumber = 0;
  13175. var totalNumber = 0.00M;
  13176. string lastStr = "";
  13177. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13178. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13179. {
  13180. b.IsAuditGM,
  13181. x.Id,
  13182. x.Area,
  13183. b.PayPercentage,
  13184. b.PayMoney,
  13185. }).ToList();
  13186. string yesPayment = "", noPayment = "";
  13187. foreach (var item in queryCarArrByCityAndDiid)
  13188. {
  13189. if (item.IsAuditGM == 1)
  13190. {
  13191. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13192. }
  13193. else
  13194. {
  13195. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13196. }
  13197. }
  13198. lastStr = yesPayment + noPayment;
  13199. foreach (var item in arr)
  13200. {
  13201. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13202. {
  13203. if (thisSid != item.SId)
  13204. {
  13205. if (thisSid == -1)
  13206. {
  13207. thisSid = item.SId;
  13208. }
  13209. else
  13210. {
  13211. //合并小计行
  13212. //创建合并区域的实例
  13213. var cellRangeAddress = new CellRangeAddress(
  13214. rowStartIndex, // 起始行索引(0-based)
  13215. rowStartIndex, // 结束行索引(0-based)
  13216. 0, // 起始列索引(0-based)
  13217. 3 // 结束列索引(0-based)
  13218. );
  13219. sheet.AddMergedRegion(cellRangeAddress);
  13220. var CellStyle = workbook.CreateCellStyle();
  13221. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13222. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13223. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13224. for (int i = 0; i <= clounmCount; i++)
  13225. {
  13226. if (i > 6)
  13227. {
  13228. var CellStyle1 = workbook.CreateCellStyle();
  13229. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13230. IFont Font = workbook.CreateFont(); // 创建字体
  13231. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13232. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13233. CellStyle1.SetFont(Font);
  13234. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13235. }
  13236. else
  13237. {
  13238. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13239. }
  13240. }
  13241. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13242. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13243. //超时合计
  13244. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13245. //超时数
  13246. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13247. //超时合计费用
  13248. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13249. thisSid = item.SId;
  13250. cloneRowFn();
  13251. chaoshiNumber = 0;
  13252. totalNumber = 0;
  13253. }
  13254. }
  13255. IRow row = sheet.GetRow(rowStartIndex);
  13256. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13257. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13258. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13259. if (isOpenOverspendSoure)
  13260. {
  13261. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13262. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13263. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13264. }
  13265. for (int i = 0; i <= clounmCount; i++)
  13266. {
  13267. var cell = row.GetCell(i);
  13268. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13269. if (cell == null)
  13270. {
  13271. cell = row.CreateCell(i);
  13272. }
  13273. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13274. fontRed.CloneStyleFrom(cell.CellStyle);
  13275. IFont Font = workbook.CreateFont(); // 创建字体
  13276. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13277. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13278. fontRed.SetFont(Font);
  13279. byte[] rgb = new byte[3] { 255, 242, 204 };
  13280. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13281. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13282. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13283. if (workbook is XSSFWorkbook)
  13284. {
  13285. BackgroundColor255_242_204.FillForegroundColor = 0;
  13286. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13287. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13288. }
  13289. else
  13290. {
  13291. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13292. }
  13293. if (i == 1 || i > 6)
  13294. {
  13295. if (i > 6)
  13296. {
  13297. fontRed.FillForegroundColor = 0;
  13298. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13299. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13300. }
  13301. cell.CellStyle = fontRed;
  13302. }
  13303. if (i > 2 && i < 7)
  13304. {
  13305. cell.CellStyle = BackgroundColor255_242_204;
  13306. }
  13307. cell.SetCellValue(setCellValue); //写入单元格
  13308. }
  13309. if (overspendSoure.ContainsKey(thisSid))
  13310. {
  13311. var overspendId = overspendSoure[thisSid];
  13312. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13313. }
  13314. cloneRowFn();
  13315. existsId.Add(new CarCompare
  13316. {
  13317. DataPrice = item.DatePrice.ObjToDate(),
  13318. Sid = item.SId
  13319. });
  13320. }
  13321. if (item.Equals(lastElem))
  13322. {
  13323. //合并小计行
  13324. //创建合并区域的实例
  13325. var cellRangeAddress = new CellRangeAddress(
  13326. rowStartIndex, // 起始行索引(0-based)
  13327. rowStartIndex, // 结束行索引(0-based)
  13328. 0, // 起始列索引(0-based)
  13329. 3 // 结束列索引(0-based)
  13330. );
  13331. sheet.AddMergedRegion(cellRangeAddress);
  13332. var CellStyle = workbook.CreateCellStyle();
  13333. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13334. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13335. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13336. for (int i = 0; i <= clounmCount; i++)
  13337. {
  13338. if (i > 6)
  13339. {
  13340. var CellStyle1 = workbook.CreateCellStyle();
  13341. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13342. IFont Font = workbook.CreateFont(); // 创建字体
  13343. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13344. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13345. CellStyle1.SetFont(Font);
  13346. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13347. }
  13348. else
  13349. {
  13350. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13351. }
  13352. }
  13353. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13354. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13355. //超时合计
  13356. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13357. //超时数
  13358. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13359. //超时合计费用
  13360. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13361. cloneRowFn();
  13362. // 创建合并区域的实例
  13363. cellRangeAddress = new CellRangeAddress(
  13364. rowStartIndex, // 起始行索引(0-based)
  13365. rowStartIndex, // 结束行索引(0-based)
  13366. 0, // 起始列索引(0-based)
  13367. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13368. );
  13369. // 添加合并区域
  13370. sheet.AddMergedRegion(cellRangeAddress);
  13371. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13372. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13373. }
  13374. }
  13375. mergeRow();
  13376. // 保存修改后的Excel文件到新文件
  13377. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13378. // new FileStream(newFilePath, FileMode.CreateNew)
  13379. using (var stream = new MemoryStream())
  13380. {
  13381. workbook.Write(stream, true);
  13382. stream.Flush();
  13383. stream.Seek(0, SeekOrigin.Begin);
  13384. var memoryStream = new MemoryStream();
  13385. stream.CopyTo(memoryStream);
  13386. memoryStream.Seek(0, SeekOrigin.Begin);
  13387. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13388. }
  13389. workbook.Close();
  13390. workbook.Dispose();
  13391. }
  13392. catch (Exception ex)
  13393. {
  13394. jw.Msg = "出现异常!" + ex.Message;
  13395. return Ok(jw);
  13396. }
  13397. }
  13398. if (Zips.Count > 0)
  13399. {
  13400. var io = new IOOperatorHelper();
  13401. var byts = io.ConvertZipStream(Zips);
  13402. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13403. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13404. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13405. }
  13406. else
  13407. {
  13408. jw.Msg = "暂无生成文件!";
  13409. }
  13410. return Ok(jw);
  13411. }
  13412. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13413. {
  13414. string outStr = string.Empty;
  13415. switch (i)
  13416. {
  13417. case 0:
  13418. outStr = arr[0].SidName;
  13419. break;
  13420. case 1:
  13421. outStr = arr[0].DataPriceStr;
  13422. break;
  13423. case 2:
  13424. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13425. break;
  13426. case 4:
  13427. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13428. break;
  13429. case 7:
  13430. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13431. {
  13432. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13433. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13434. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13435. }
  13436. break;
  13437. case 8:
  13438. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13439. {
  13440. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13441. }
  13442. break;
  13443. case 9:
  13444. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13445. {
  13446. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13447. }
  13448. break;
  13449. case 10:
  13450. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13451. {
  13452. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13453. }
  13454. break;
  13455. }
  13456. return outStr;
  13457. }
  13458. #region OP行程单
  13459. /// <summary>
  13460. /// OP行程单初始化
  13461. /// </summary>
  13462. /// <param name="dto"></param>
  13463. /// <returns></returns>
  13464. [HttpPost]
  13465. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13466. {
  13467. var jw = JsonView(false);
  13468. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13469. var group = groupList.First();
  13470. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13471. if (group == null)
  13472. {
  13473. jw.Msg = "暂无团组!";
  13474. return Ok(jw);
  13475. }
  13476. group = groupList.Find(x => x.Id == diid);
  13477. if (group == null)
  13478. {
  13479. jw.Msg = "请输入正确的团组ID!";
  13480. return Ok(jw);
  13481. }
  13482. string city = string.Empty;
  13483. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13484. if (blackCode.Count > 0)
  13485. {
  13486. var black = blackCode.First();
  13487. black.BlackCode = black.BlackCode ?? "";
  13488. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13489. if (blackSp.Length > 0)
  13490. {
  13491. try
  13492. {
  13493. var cityArrCode = new List<string>(20);
  13494. foreach (var item in blackSp)
  13495. {
  13496. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13497. var IndexSelect = itemSp[2];
  13498. var cityArrCodeLength = cityArrCode.Count - 1;
  13499. var startCity = IndexSelect.Substring(0, 3);
  13500. if (cityArrCodeLength > 0)
  13501. {
  13502. var arrEndCity = cityArrCode[cityArrCodeLength];
  13503. if (arrEndCity != startCity)
  13504. {
  13505. cityArrCode.Add(startCity.ToUpper());
  13506. }
  13507. }
  13508. else
  13509. {
  13510. cityArrCode.Add(startCity.ToUpper());
  13511. }
  13512. var endCity = IndexSelect.Substring(3, 3);
  13513. cityArrCode.Add(endCity.ToUpper());
  13514. }
  13515. var cityThree = string.Empty;
  13516. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13517. cityThree = cityThree.TrimEnd(',');
  13518. if (string.IsNullOrWhiteSpace(cityThree))
  13519. {
  13520. throw new
  13521. Exception("error");
  13522. }
  13523. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13524. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13525. foreach (var item in cityArrCode)
  13526. {
  13527. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13528. if (find != null)
  13529. {
  13530. city += find.City + "/";
  13531. }
  13532. else
  13533. {
  13534. city += item + "三字码未收入/";
  13535. }
  13536. }
  13537. city = city.TrimEnd('/');
  13538. }
  13539. catch (Exception e)
  13540. {
  13541. city = "黑屏代码格式不正确!";
  13542. }
  13543. }
  13544. }
  13545. else
  13546. {
  13547. city = "未录入黑屏代码";
  13548. }
  13549. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13550. {
  13551. Date = x.Date,
  13552. Days = x.Days,
  13553. Diffgroup = x.Diffgroup,
  13554. Diid = x.Diid,
  13555. Traffic_First = x.Traffic_First,
  13556. Traffic_Second = x.Traffic_Second,
  13557. Trip = x.Trip,
  13558. WeekDay = x.WeekDay,
  13559. Id = x.Id
  13560. }).ToList();
  13561. jw.Data = new
  13562. {
  13563. groupList = groupList.Select(x => new
  13564. {
  13565. x.Id,
  13566. x.TeamName,
  13567. x.TourCode
  13568. }).ToList(),
  13569. groupInfo = new
  13570. {
  13571. group.VisitDays,
  13572. group.TourCode,
  13573. group.VisitPNumber,
  13574. group.TeamName,
  13575. city
  13576. },
  13577. OpTravelList
  13578. };
  13579. jw.Code = 200;
  13580. jw.Msg = "操作成功!";
  13581. return Ok(jw);
  13582. }
  13583. /// <summary>
  13584. /// 删除团组行程单
  13585. /// </summary>
  13586. /// <returns></returns>
  13587. [HttpPost]
  13588. public IActionResult DelTravel(DelOpTravelDto dto)
  13589. {
  13590. var jw = JsonView(false);
  13591. if (dto.UserId <= 0 || dto.Diid <= 0)
  13592. {
  13593. jw.Msg = "请输入正确的参数!";
  13594. return Ok(jw);
  13595. }
  13596. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13597. .SetColumns(x => new Grp_TravelList
  13598. {
  13599. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13600. DeleteUserId = dto.UserId,
  13601. IsDel = 1,
  13602. }).ExecuteCommand();
  13603. jw = JsonView(true);
  13604. return Ok(jw);
  13605. }
  13606. /// <summary>
  13607. /// 行程单保存
  13608. /// </summary>
  13609. /// <returns></returns>
  13610. [HttpPost]
  13611. public IActionResult TravelSave(TravelSaveDto dto)
  13612. {
  13613. var jw = JsonView(false);
  13614. if (dto.Arr.Count > 0)
  13615. {
  13616. try
  13617. {
  13618. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13619. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13620. .ToList();
  13621. _sqlSugar.BeginTran();
  13622. foreach (var item in dto.Arr)
  13623. {
  13624. if (item.Id == 0)
  13625. {
  13626. throw new Exception("请传入正确的Id");
  13627. }
  13628. //比较上一次的差异
  13629. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13630. if (findTravel != null)
  13631. {
  13632. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13633. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13634. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13635. }
  13636. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13637. .SetColumns(x => new Grp_TravelList
  13638. {
  13639. Trip = item.Trip
  13640. }).ExecuteCommand();
  13641. }
  13642. _sqlSugar.CommitTran();
  13643. jw = JsonView(true);
  13644. }
  13645. catch (Exception ex)
  13646. {
  13647. _sqlSugar.RollbackTran();
  13648. jw.Msg = "程序异常!" + ex.Message;
  13649. }
  13650. }
  13651. else
  13652. {
  13653. jw.Msg = "请传入正确的参数!";
  13654. }
  13655. return Ok(jw);
  13656. }
  13657. private static string CheckStr(string original, string changed)
  13658. {
  13659. // 创建diff_match_patch对象
  13660. var dmp = new diff_match_patch();
  13661. // 计算差异
  13662. List<Diff> diffs = dmp.diff_main(original, changed);
  13663. // 清理和合并差异
  13664. dmp.diff_cleanupSemantic(diffs);
  13665. // 使用StringBuilder构建最终的字符串
  13666. var finalString = new StringBuilder();
  13667. // 输出差异结果,并构建变动后的字符串
  13668. foreach (Diff diff in diffs)
  13669. {
  13670. switch (diff.operation)
  13671. {
  13672. case Operation.EQUAL:
  13673. // 相等的部分,直接添加到最终字符串
  13674. finalString.Append(diff.text);
  13675. break;
  13676. case Operation.INSERT:
  13677. // 插入的部分,添加标记并添加到最终字符串
  13678. finalString.Append("[++]" + diff.text + "[++]");
  13679. break;
  13680. case Operation.DELETE:
  13681. // 删除的部分,不添加到最终字符串
  13682. //finalString.Append("[++]" + diff.text + "[++]");
  13683. break;
  13684. }
  13685. }
  13686. // 输出变动后的字符串
  13687. return finalString.ToString();
  13688. }
  13689. private class tagContent
  13690. {
  13691. public DateTime Date { get; set; }
  13692. public string StartTag { get; set; }
  13693. public string EndTag { get; set; }
  13694. public string Content { get; set; }
  13695. public static int tagLength { get { return 3; } }
  13696. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13697. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13698. public bool IsFinally { get; set; }
  13699. }
  13700. private static List<string> ExtractContentBetweenTags(string input, string tag)
  13701. {
  13702. var results = new List<string>();
  13703. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13704. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13705. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13706. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13707. string[] strValueArr = new string[1];
  13708. foreach (System.Text.RegularExpressions.Match match in matches)
  13709. {
  13710. var strValue = match.Groups[1].Value;
  13711. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13712. }
  13713. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13714. return results;
  13715. }
  13716. /// <summary>
  13717. /// 导出行程单
  13718. /// </summary>
  13719. /// <param name="dto"></param>
  13720. /// <returns></returns>
  13721. [HttpPost]
  13722. public IActionResult ExportTravel(ExportTravelDto dto)
  13723. {
  13724. var jw = JsonView(false);
  13725. jw.Data = "";
  13726. int diid = 0;
  13727. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13728. if (Find == null)
  13729. {
  13730. jw.Msg = "请选择正确的团组!";
  13731. return Ok(jw);
  13732. }
  13733. else
  13734. {
  13735. diid = Find.Id;
  13736. }
  13737. //数据源
  13738. var _travelList = new List<Grp_TravelList>();
  13739. DataTable dtBlack = null;
  13740. try
  13741. {
  13742. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13743. }
  13744. catch (Exception)
  13745. {
  13746. jw.Msg = "机票黑屏代码有误!";
  13747. return Ok(jw);
  13748. }
  13749. string CityStr = string.Empty;
  13750. if (dtBlack.Rows.Count == 0)
  13751. {
  13752. jw.Msg = "机票黑屏代码有误!";
  13753. return Ok(jw);
  13754. }
  13755. else
  13756. {
  13757. foreach (DataRow row in dtBlack.Rows)
  13758. {
  13759. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13760. {
  13761. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13762. return Ok(jw);
  13763. }
  13764. }
  13765. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13766. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13767. }
  13768. // 指定的文字
  13769. var targetTextDic = new Dictionary<string, List<string>>();
  13770. //创建数据源Table
  13771. var dtSource = new DataTable();
  13772. dtSource.Columns.Add("Days", typeof(string));
  13773. dtSource.Columns.Add("Date", typeof(string));
  13774. dtSource.Columns.Add("Week", typeof(string));
  13775. dtSource.Columns.Add("Traffic", typeof(string));
  13776. dtSource.Columns.Add("Trip", typeof(string));
  13777. //获取数据,放到datatable
  13778. foreach (var item in _travelList)
  13779. {
  13780. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13781. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13782. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13783. .Replace("[++]", string.Empty);
  13784. DataRow dr = dtSource.NewRow();
  13785. dr["Days"] = item.Days;
  13786. dr["Date"] = item.Date;
  13787. dr["Week"] = item.WeekDay;
  13788. dr["Traffic"] = item.Traffic_First
  13789. + "\r\n"
  13790. + item.Traffic_Second;
  13791. dr["Trip"] = item.Trip;
  13792. dtSource.Rows.Add(dr);
  13793. }
  13794. var dic = new Dictionary<string, string>
  13795. {
  13796. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  13797. { "City", CityStr },
  13798. { "Days", Find.VisitDays.ToString() },
  13799. { "DeleCode", Find.TourCode },
  13800. { "Pnum", Find.VisitPNumber.ToString() }
  13801. };
  13802. //模板路径
  13803. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13804. //载入模板
  13805. Document doc = null;
  13806. DocumentBuilder builder = null;
  13807. try
  13808. {
  13809. //载入模板
  13810. doc = new Document(tempPath);
  13811. builder = new DocumentBuilder(doc);
  13812. }
  13813. catch (Exception)
  13814. {
  13815. jw.Msg = "模板位置不存在!";
  13816. return Ok(jw);
  13817. }
  13818. foreach (var key in dic.Keys)
  13819. {
  13820. Bookmark bookmark = doc.Range.Bookmarks[key];
  13821. if (bookmark != null)
  13822. {
  13823. builder.MoveToBookmark(key);
  13824. builder.Write(dic[key]);
  13825. }
  13826. }
  13827. //获取word里所有表格
  13828. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13829. //获取所填表格的序数
  13830. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13831. try
  13832. {
  13833. //循环赋值
  13834. for (int i = 0; i < dtSource.Rows.Count; i++)
  13835. {
  13836. builder.MoveToCell(0, i + 1, 0, 0);
  13837. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13838. builder.MoveToCell(0, i + 1, 1, 0);
  13839. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13840. builder.MoveToCell(0, i + 1, 2, 0);
  13841. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13842. var trip = dtSource.Rows[i]["Trip"].ToString();
  13843. builder.MoveToCell(0, i + 1, 3, 0);
  13844. builder.Write(trip);
  13845. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13846. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13847. // 获取特定索引的段落
  13848. Paragraph paragraph = (Paragraph)paragraphs[0];
  13849. Run run = paragraph.Runs[0];
  13850. Aspose.Words.Font font = run.Font;
  13851. font.Name = "黑体";
  13852. //设置双休红色
  13853. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13854. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13855. paragraph = (Paragraph)paragraphs[1];
  13856. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13857. {
  13858. run = paragraph.Runs[0];
  13859. font = run.Font;
  13860. font.Color = Color.Red;
  13861. }
  13862. }
  13863. }
  13864. catch (Exception ex)
  13865. {
  13866. }
  13867. //删除多余行
  13868. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13869. {
  13870. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13871. }
  13872. var targetTextList = new List<string>();
  13873. // 遍历文档中的表格
  13874. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13875. {
  13876. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13877. {
  13878. var cellIndex = 0;
  13879. foreach (Cell cell in row.Cells)
  13880. {
  13881. if (cellIndex == 1 && row.Cells.Count == 4)
  13882. {
  13883. foreach (var target in targetTextDic.Keys)
  13884. {
  13885. if (cell.GetText().Contains(target))
  13886. {
  13887. targetTextList = targetTextDic[target];
  13888. break;
  13889. }
  13890. }
  13891. }
  13892. // 遍历单元格中的所有段落
  13893. foreach (Paragraph paragraph in cell.Paragraphs)
  13894. {
  13895. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13896. var runs = new List<Run>();
  13897. foreach (Run run in paragraph.Runs)
  13898. {
  13899. runs.Add(run);
  13900. }
  13901. foreach (Run run in runs)
  13902. {
  13903. foreach (var targetText in targetTextList)
  13904. {
  13905. // 检查文字是否包含指定文字
  13906. if (run.Text.Contains(targetText))
  13907. {
  13908. // 将包含的部分设置为红色
  13909. HighlightText(run, targetText, Color.Red);
  13910. }
  13911. }
  13912. }
  13913. }
  13914. cellIndex++;
  13915. }
  13916. }
  13917. }
  13918. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13919. if (!Directory.Exists(savePath))
  13920. {
  13921. try
  13922. {
  13923. Directory.CreateDirectory(savePath);
  13924. }
  13925. catch
  13926. {
  13927. }
  13928. }
  13929. string path = savePath + Find.TeamName + "出访日程";
  13930. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13931. try
  13932. {
  13933. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13934. string postfix = ".docx";
  13935. if (dto.IsPDF == 1)
  13936. {
  13937. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13938. postfix = ".pdf";
  13939. }
  13940. doc.Save(path + postfix, saveFormat);
  13941. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13942. }
  13943. catch (Exception)
  13944. {
  13945. jw = JsonView(false);
  13946. }
  13947. return Ok(jw);
  13948. }
  13949. /// <summary>
  13950. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13951. /// </summary>
  13952. /// <param name="num"></param>
  13953. /// <returns></returns>
  13954. static string GetNum(string num)
  13955. {
  13956. string str = "";
  13957. switch (num)
  13958. {
  13959. case "1":
  13960. str = "一";
  13961. break;
  13962. case "2":
  13963. str = "二";
  13964. break;
  13965. case "3":
  13966. str = "三";
  13967. break;
  13968. case "4":
  13969. str = "四";
  13970. break;
  13971. case "5":
  13972. str = "五";
  13973. break;
  13974. case "6":
  13975. str = "六";
  13976. break;
  13977. case "7":
  13978. str = "七";
  13979. break;
  13980. case "8":
  13981. str = "八";
  13982. break;
  13983. case "9":
  13984. str = "九";
  13985. break;
  13986. case "10":
  13987. str = "十";
  13988. break;
  13989. case "11":
  13990. str = "十一";
  13991. break;
  13992. case "12":
  13993. str = "十二";
  13994. break;
  13995. case "一":
  13996. str = "1";
  13997. break;
  13998. case "二":
  13999. str = "2";
  14000. break;
  14001. case "三":
  14002. str = "3";
  14003. break;
  14004. case "四":
  14005. str = "4";
  14006. break;
  14007. case "五":
  14008. str = "5";
  14009. break;
  14010. case "六":
  14011. str = "6";
  14012. break;
  14013. case "七":
  14014. str = "7";
  14015. break;
  14016. case "八":
  14017. str = "8";
  14018. break;
  14019. case "九":
  14020. str = "9";
  14021. break;
  14022. case "十":
  14023. str = "10";
  14024. break;
  14025. case "十一":
  14026. str = "11";
  14027. break;
  14028. case "十二":
  14029. str = "12";
  14030. break;
  14031. }
  14032. return str;
  14033. }
  14034. /// <summary>
  14035. /// 高亮包含指定文字的部分
  14036. /// </summary>
  14037. /// <param name="run"></param>
  14038. /// <param name="targetText"></param>
  14039. /// <param name="color"></param>
  14040. static void HighlightText(Run run, string targetText, Color color)
  14041. {
  14042. string text = run.Text;
  14043. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14044. if (startIndex >= 0)
  14045. {
  14046. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14047. // 前部分
  14048. if (startIndex > 0)
  14049. {
  14050. Run beforeRun = (Run)run.Clone(true);
  14051. beforeRun.Text = text.Substring(0, startIndex);
  14052. parentParagraph.InsertBefore(beforeRun, run);
  14053. }
  14054. // 匹配部分
  14055. Run matchRun = (Run)run.Clone(true);
  14056. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14057. matchRun.Font.Color = color;
  14058. parentParagraph.InsertBefore(matchRun, run);
  14059. // 后部分
  14060. if (startIndex + targetText.Length < text.Length)
  14061. {
  14062. Run afterRun = (Run)run.Clone(true);
  14063. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14064. parentParagraph.InsertBefore(afterRun, run);
  14065. }
  14066. // 删除原始Run
  14067. run.Remove();
  14068. }
  14069. }
  14070. #endregion
  14071. #endregion
  14072. #region 团组成本
  14073. /// <summary>
  14074. /// 团组成本数据初始化
  14075. /// </summary>
  14076. /// <param name="dto"></param>
  14077. /// <returns></returns>
  14078. [HttpPost]
  14079. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14080. {
  14081. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14082. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14083. WHEN COUNT(*) >= 0 THEN 'True'
  14084. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14085. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14086. ").ToList(); //团组列表
  14087. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14088. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14089. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14090. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14091. if (groupinfoValue != null)
  14092. {
  14093. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14094. var spArr = new string[1] { countryArr };
  14095. if (countryArr.Contains("|"))
  14096. {
  14097. spArr = countryArr.Split("|");
  14098. }
  14099. else if (countryArr.Contains("、"))
  14100. {
  14101. spArr = countryArr.Split("、");
  14102. }
  14103. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14104. {
  14105. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14106. if (dbQueryCountry != null)
  14107. {
  14108. visaCountryInfoArr.Add(dbQueryCountry);
  14109. }
  14110. }
  14111. }
  14112. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14113. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14114. #region 屏蔽黑屏代码生成
  14115. //var create = _GroupCostRepository.
  14116. // CreateGroupCostByBlackCode(dto.Diid);
  14117. //if (groupCost.Count == 0 && create.Code == 0)
  14118. //{
  14119. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14120. //}
  14121. #endregion
  14122. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14123. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14124. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14125. groupCostMap = groupCostMap.Select(x =>
  14126. {
  14127. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14128. {
  14129. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14130. }
  14131. return x;
  14132. }).ToList();
  14133. //GroupCostParameter.Add(new
  14134. // Grp_GroupCostParameter());
  14135. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14136. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14137. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14138. return Ok(JsonView(new
  14139. {
  14140. groupList,
  14141. groupInfo,
  14142. groupChecks,
  14143. groupCost = groupCostMap,
  14144. hotelNumber,
  14145. GroupCostParameter = GroupCostParameterMap,
  14146. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14147. {
  14148. x.VisaCountry,
  14149. x.VisaPrice,
  14150. x.Id,
  14151. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14152. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14153. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14154. x.VisaTime, // 一般签证时间
  14155. }).ToList(),
  14156. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14157. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14158. hotelIsTrue,
  14159. groupModuleOperators
  14160. }));
  14161. }
  14162. /// <summary>
  14163. /// 团组成本信息保存
  14164. /// </summary>
  14165. /// <param name="dto"></param>
  14166. /// <returns></returns>
  14167. [HttpPost]
  14168. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14169. {
  14170. if (dto.Diid <= 0 || dto.Userid <= 0)
  14171. {
  14172. return Ok(JsonView(false));
  14173. }
  14174. JsonView jw = null;
  14175. bool isTrue = false;
  14176. #region 复制团组成本
  14177. //if (dto.Diid == 2581)
  14178. //{
  14179. // dto.Diid = 2599;
  14180. // dto.CheckBoxs.ForEach(x =>
  14181. // {
  14182. // x.Diid = 2599;
  14183. // });
  14184. // dto.GroupCosts.ForEach(x =>
  14185. // {
  14186. // x.Diid = 2599;
  14187. // });
  14188. // dto.CostTypeHotelNumbers.ForEach(x =>
  14189. // {
  14190. // x.Diid = 2599;
  14191. // });
  14192. // dto.GroupCostParameters.ForEach(x =>
  14193. // {
  14194. // x.DiId = 2599;
  14195. // });
  14196. //}
  14197. #endregion
  14198. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14199. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14200. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14201. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14202. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14203. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14204. try
  14205. {
  14206. _sqlSugar.BeginTran();
  14207. isTrue = await _GroupCostRepository.
  14208. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14209. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14210. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14211. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14212. _sqlSugar.CommitTran();
  14213. jw = JsonView(true, "保存成功!", isTrue);
  14214. }
  14215. catch (Exception)
  14216. {
  14217. _sqlSugar.RollbackTran();
  14218. jw = JsonView(false);
  14219. }
  14220. return Ok(jw);
  14221. }
  14222. /// <summary>
  14223. /// 复制团组成本信息
  14224. /// </summary>
  14225. /// <param name="dto"></param>
  14226. /// <returns></returns>
  14227. [HttpPost]
  14228. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14229. {
  14230. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14231. {
  14232. return Ok(JsonView(false, "参数有误!"));
  14233. }
  14234. #region 复制团组成本
  14235. dto.Diid = dto.ToGroupId;
  14236. dto.CheckBoxs.ForEach(x =>
  14237. {
  14238. x.Diid = dto.ToGroupId;
  14239. });
  14240. dto.GroupCosts.ForEach(x =>
  14241. {
  14242. x.Diid = dto.ToGroupId;
  14243. });
  14244. dto.CostTypeHotelNumbers.ForEach(x =>
  14245. {
  14246. x.Diid = dto.ToGroupId;
  14247. });
  14248. dto.GroupCostParameters.ForEach(x =>
  14249. {
  14250. x.DiId = dto.ToGroupId;
  14251. });
  14252. #endregion
  14253. JsonView jw = null;
  14254. bool isTrue = false;
  14255. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14256. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14257. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14258. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14259. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14260. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14261. try
  14262. {
  14263. _sqlSugar.BeginTran();
  14264. isTrue = await _GroupCostRepository.
  14265. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14266. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14267. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14268. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14269. _sqlSugar.CommitTran();
  14270. jw = JsonView(true, "保存成功!", isTrue);
  14271. }
  14272. catch (Exception)
  14273. {
  14274. _sqlSugar.RollbackTran();
  14275. jw = JsonView(false);
  14276. }
  14277. return Ok(jw);
  14278. }
  14279. /// <summary>
  14280. /// 司兼导数据
  14281. /// </summary>
  14282. /// <param name="dto"></param>
  14283. /// <returns></returns>
  14284. [HttpPost]
  14285. public IActionResult GetCarGuides(CarGuidesDto dto)
  14286. {
  14287. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14288. return Ok(JsonView(true, "获取成功!", Data));
  14289. }
  14290. /// <summary>
  14291. /// 导游数据
  14292. /// </summary>
  14293. /// <param name="dto"></param>
  14294. /// <returns></returns>
  14295. [HttpPost]
  14296. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14297. {
  14298. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14299. // 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
  14300. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14301. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14302. return Ok(JsonView(true, "获取成功!", Data));
  14303. }
  14304. /// <summary>
  14305. /// 成本车数据
  14306. /// </summary>
  14307. /// <param name="dto"></param>
  14308. /// <returns></returns>
  14309. [HttpPost]
  14310. public IActionResult GetCarInfo(CarGuidesDto dto)
  14311. {
  14312. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14313. return Ok(JsonView(true, "获取成功!", Data));
  14314. }
  14315. /// <summary>
  14316. /// 景点数据
  14317. /// </summary>
  14318. /// <param name="dto"></param>
  14319. /// <returns></returns>
  14320. [HttpPost]
  14321. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14322. {
  14323. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14324. return Ok(JsonView(true, "获取成功!", Data));
  14325. }
  14326. /// <summary>
  14327. /// 成本通知
  14328. /// </summary>
  14329. /// <param name="dto"></param>
  14330. /// <returns></returns>
  14331. [HttpPost]
  14332. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14333. {
  14334. if (dto.Diid < 0)
  14335. {
  14336. return Ok(JsonView(false));
  14337. }
  14338. JsonView jw;
  14339. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14340. if (GroupCostParameter != null)
  14341. {
  14342. int IsShare = 0;
  14343. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14344. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14345. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14346. string msg = string.Empty;
  14347. if (isTrue)
  14348. {
  14349. if (IsShare == 0)
  14350. {
  14351. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14352. }
  14353. else
  14354. {
  14355. #region 企微通知对应岗位用户
  14356. try
  14357. {
  14358. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14359. }
  14360. catch (Exception)
  14361. {
  14362. }
  14363. #endregion
  14364. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14365. }
  14366. jw = JsonView(isTrue, msg, new { IsShare });
  14367. }
  14368. else
  14369. {
  14370. msg = "修改失败!";
  14371. jw = JsonView(isTrue, msg);
  14372. }
  14373. }
  14374. else
  14375. {
  14376. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14377. }
  14378. return Ok(jw);
  14379. }
  14380. /// <summary>
  14381. /// 导出报价单
  14382. /// </summary>
  14383. /// <param name="dto"></param>
  14384. /// <returns></returns>
  14385. [HttpPost]
  14386. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14387. {
  14388. if (dto.Diid == 0)
  14389. {
  14390. return Ok(JsonView(false, "请传递团组id"));
  14391. }
  14392. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14393. if (deleInfo.Code != 0)
  14394. {
  14395. return Ok(JsonView(false, "团组信息查询失败!"));
  14396. }
  14397. var di = deleInfo.Data as DelegationInfoWebView;
  14398. if (di != null)
  14399. {
  14400. di.TeamName = di.TeamName.Replace("|", "、");
  14401. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14402. //文件名
  14403. string strFileName = di.TeamName + "-收款账单.doc";
  14404. //获取模板
  14405. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14406. //载入模板
  14407. Document doc = new Document(tmppath);
  14408. decimal TotalPrice = 0.00M;
  14409. string itemStr = string.Empty;
  14410. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14411. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14412. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14413. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14414. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14415. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14416. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14417. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14418. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14419. foreach (var cost in groupCostType)
  14420. {
  14421. var List = cost.ToList();
  14422. if (cost.Key == "A")
  14423. {
  14424. foreach (var ListItem in List)
  14425. {
  14426. if (ListItem.number > 0)
  14427. {
  14428. if (ListItem.code.Contains("TBR"))
  14429. {
  14430. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14431. }
  14432. else
  14433. {
  14434. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14435. }
  14436. TotalPrice += (ListItem.number * ListItem.price);
  14437. }
  14438. }
  14439. }
  14440. else
  14441. {
  14442. itemStr = itemStr.Insert(0, "A段\r\n");
  14443. itemStr += "B段\r\n";
  14444. foreach (var ListItem in List)
  14445. {
  14446. if (ListItem.number > 0)
  14447. {
  14448. if (ListItem.code.Contains("TBR"))
  14449. {
  14450. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14451. }
  14452. else
  14453. {
  14454. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14455. }
  14456. TotalPrice += (ListItem.number * ListItem.price);
  14457. }
  14458. }
  14459. }
  14460. }
  14461. #region 替换Word模板书签内容
  14462. Dictionary<string, string> marks = new Dictionary<string, string>();
  14463. marks.Add("To", di.ClientUnit);//付款方
  14464. marks.Add("ToTel", di.TellPhone);//付款方电话
  14465. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14466. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14467. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14468. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14469. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14470. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14471. marks.Add("PayItemContent", itemStr);//详细信息
  14472. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14473. #endregion
  14474. ////注
  14475. //if (doc.Range.Bookmarks["Attention"] != null)
  14476. //{
  14477. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14478. // mark.Text = frList[0].Attention;
  14479. //}
  14480. foreach (var item in marks.Keys)
  14481. {
  14482. if (doc.Range.Bookmarks[item] != null)
  14483. {
  14484. Bookmark mark = doc.Range.Bookmarks[item];
  14485. mark.Text = marks[item];
  14486. }
  14487. }
  14488. byte[] bytes = null;
  14489. using (MemoryStream stream = new MemoryStream())
  14490. {
  14491. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14492. bytes = stream.ToArray();
  14493. }
  14494. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14495. return Ok(JsonView(true, "", new
  14496. {
  14497. Data = bytes,
  14498. strFileName,
  14499. }));
  14500. }
  14501. else
  14502. {
  14503. return Ok(JsonView(false, "团组信息不存在!"));
  14504. }
  14505. }
  14506. /// <summary>
  14507. /// 导出团组成本
  14508. /// </summary>
  14509. /// <param name="dto"></param>
  14510. /// <returns></returns>
  14511. [HttpPost]
  14512. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14513. {
  14514. var jw = JsonView(false);
  14515. if (dto.Diid == 0)
  14516. {
  14517. return Ok(JsonView(false, "请传递团组id"));
  14518. }
  14519. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14520. if (deleInfo.Code != 0)
  14521. {
  14522. return Ok(JsonView(false, "团组信息查询失败!"));
  14523. }
  14524. var di = deleInfo.Data as DelegationInfoWebView;
  14525. if (di == null)
  14526. {
  14527. return Ok(JsonView(false, "团组信息查询失败!"));
  14528. }
  14529. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14530. WorkbookDesigner designer = new WorkbookDesigner();
  14531. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14532. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14533. for (int i = 0; i < List_GC.Count; i++)
  14534. {
  14535. GroupCost_Excel gc = new GroupCost_Excel();
  14536. gc.Id = List_GC[i].Id;
  14537. gc.Diid = List_GC[i].Diid.ToString();
  14538. gc.DAY = List_GC[i].DAY;
  14539. string week = "";
  14540. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14541. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14542. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14543. gc.ITIN = List_GC[i].ITIN;
  14544. gc.CarType = List_GC[i].CarType;
  14545. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  14546. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  14547. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  14548. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  14549. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  14550. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  14551. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  14552. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  14553. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  14554. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  14555. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  14556. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  14557. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14558. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14559. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  14560. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  14561. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  14562. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  14563. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  14564. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  14565. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  14566. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  14567. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  14568. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  14569. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  14570. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  14571. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  14572. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  14573. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  14574. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  14575. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  14576. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  14577. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  14578. List_GC1.Add(gc);
  14579. }
  14580. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14581. dt.TableName = "TB";
  14582. //报表标题等不用dt的值
  14583. designer.SetDataSource("TeamName", dto.title.TeamName);
  14584. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14585. designer.SetDataSource("Tax", dto.title.Tax);
  14586. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14587. designer.SetDataSource("Currency", dto.title.Currency);
  14588. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14589. designer.SetDataSource("Rate", dto.title.Rate);
  14590. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14591. var Aparams = hotels.Find(x => x.Type == "Default");
  14592. if (Aparams == null)
  14593. {
  14594. return Ok(jw);
  14595. }
  14596. //酒店数量
  14597. var txtSGRNumber = Aparams.SGR.ToString();
  14598. var txtTBRNumber = Aparams.TBR.ToString();
  14599. var txtJSESNumber = Aparams.JSES.ToString();
  14600. var txtSUITENumbe = Aparams.SUITE.ToString();
  14601. if (dto.costType == "B")
  14602. {
  14603. Aparams = hotels.Find(x => x.Type == "A");
  14604. var Bparams = hotels.Find(x => x.Type == "B");
  14605. if (Aparams == null || Bparams == null)
  14606. {
  14607. return Ok(jw);
  14608. }
  14609. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14610. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14611. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14612. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14613. }
  14614. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14615. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14616. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14617. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14618. var ws = designer.Workbook.Worksheets[0];
  14619. int Row = List_GC.Count;
  14620. int startIndex = 11;
  14621. int HideRows = 0;
  14622. List<int> hideRowsList = new List<int>();
  14623. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14624. #region A段left数据
  14625. var left = dto.leftInfo.Find(x => x.Type == "A");
  14626. if (left == null)
  14627. {
  14628. return Ok(jw);
  14629. }
  14630. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14631. if (leftBindData != null)
  14632. {
  14633. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14634. designer.SetDataSource("VisaRS", leftBindData.rs);
  14635. designer.SetDataSource("VisaXS", leftBindData.xs);
  14636. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14637. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14638. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14639. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14640. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14641. }
  14642. else
  14643. {
  14644. hideRowsList.Add(Row + startIndex + HideRows);
  14645. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14646. }
  14647. HideRows += 2;
  14648. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14649. if (leftBindData != null)
  14650. {
  14651. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14652. designer.SetDataSource("BXRS", leftBindData.rs);
  14653. designer.SetDataSource("BXXS", leftBindData.xs);
  14654. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14655. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14656. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14657. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14658. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14659. }
  14660. else
  14661. {
  14662. hideRowsList.Add(Row + startIndex + HideRows);
  14663. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14664. }
  14665. HideRows += 2;
  14666. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14667. if (leftBindData != null)
  14668. {
  14669. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14670. designer.SetDataSource("HSRS", leftBindData.rs);
  14671. designer.SetDataSource("HSXS", leftBindData.xs);
  14672. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14673. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14674. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14675. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14676. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14677. }
  14678. else
  14679. {
  14680. hideRowsList.Add(Row + startIndex + HideRows);
  14681. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14682. }
  14683. HideRows += 2;
  14684. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14685. if (leftBindData != null)
  14686. {
  14687. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14688. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14689. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14690. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14691. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14692. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14693. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14694. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14695. }
  14696. else
  14697. {
  14698. hideRowsList.Add(Row + startIndex + HideRows);
  14699. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14700. }
  14701. HideRows += 2;
  14702. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14703. if (leftBindData != null)
  14704. {
  14705. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14706. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14707. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14708. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14709. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14710. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14711. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14712. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14713. }
  14714. else
  14715. {
  14716. hideRowsList.Add(Row + startIndex + HideRows);
  14717. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14718. }
  14719. HideRows += 2;
  14720. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14721. if (leftBindData != null)
  14722. {
  14723. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14724. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14725. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14726. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14727. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14728. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14729. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14730. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14731. }
  14732. else
  14733. {
  14734. hideRowsList.Add(Row + startIndex + HideRows);
  14735. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14736. }
  14737. HideRows += 2;
  14738. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14739. if (leftBindData != null)
  14740. {
  14741. ////TBR
  14742. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14743. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14744. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14745. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14746. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14747. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14748. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14749. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14750. }
  14751. else
  14752. {
  14753. hideRowsList.Add(Row + startIndex + HideRows);
  14754. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14755. }
  14756. HideRows += 2;
  14757. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14758. if (leftBindData != null)
  14759. {
  14760. ////SGR
  14761. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14762. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14763. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14764. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14765. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14766. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14767. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14768. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14769. }
  14770. else
  14771. {
  14772. hideRowsList.Add(Row + startIndex + HideRows);
  14773. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14774. }
  14775. HideRows += 2;
  14776. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14777. if (leftBindData != null)
  14778. {
  14779. ////JS/ES
  14780. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14781. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14782. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14783. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14784. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14785. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14786. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14787. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14788. }
  14789. else
  14790. {
  14791. hideRowsList.Add(Row + startIndex + HideRows);
  14792. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14793. }
  14794. HideRows += 2;
  14795. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14796. if (leftBindData != null)
  14797. {
  14798. ////SUITE
  14799. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14800. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14801. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14802. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14803. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14804. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14805. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14806. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14807. }
  14808. else
  14809. {
  14810. hideRowsList.Add(Row + startIndex + HideRows);
  14811. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14812. }
  14813. HideRows += 2;
  14814. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14815. if (leftBindData != null)
  14816. {
  14817. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14818. designer.SetDataSource("DJRS", leftBindData.rs);
  14819. designer.SetDataSource("DJXS", leftBindData.xs);
  14820. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14821. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14822. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14823. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14824. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14825. }
  14826. else
  14827. {
  14828. hideRowsList.Add(Row + startIndex + HideRows);
  14829. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14830. }
  14831. HideRows += 2;
  14832. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14833. if (leftBindData != null)
  14834. {
  14835. designer.SetDataSource("HCPCB", leftBindData.cb);
  14836. designer.SetDataSource("HCPRS", leftBindData.rs);
  14837. designer.SetDataSource("HCPXS", leftBindData.xs);
  14838. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14839. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14840. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14841. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14842. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14843. }
  14844. else
  14845. {
  14846. hideRowsList.Add(Row + startIndex + HideRows);
  14847. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14848. }
  14849. HideRows += 2;
  14850. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14851. if (leftBindData != null)
  14852. {
  14853. designer.SetDataSource("CPCB", leftBindData.cb);
  14854. designer.SetDataSource("CPRS", leftBindData.rs);
  14855. designer.SetDataSource("CPXS", leftBindData.xs);
  14856. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14857. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14858. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14859. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14860. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14861. }
  14862. else
  14863. {
  14864. hideRowsList.Add(Row + startIndex + HideRows);
  14865. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14866. }
  14867. HideRows += 2;
  14868. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14869. if (leftBindData != null)
  14870. {
  14871. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14872. designer.SetDataSource("GWRS", leftBindData.rs);
  14873. designer.SetDataSource("GWXS", leftBindData.xs);
  14874. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14875. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14876. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14877. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14878. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14879. }
  14880. else
  14881. {
  14882. hideRowsList.Add(Row + startIndex + HideRows);
  14883. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14884. }
  14885. HideRows += 2;
  14886. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14887. if (leftBindData != null)
  14888. {
  14889. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14890. designer.SetDataSource("LYJRS", leftBindData.rs);
  14891. designer.SetDataSource("LYJXS", leftBindData.xs);
  14892. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14893. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14894. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14895. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14896. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14897. }
  14898. else
  14899. {
  14900. hideRowsList.Add(Row + startIndex + HideRows);
  14901. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14902. }
  14903. #endregion
  14904. #region A段Right信息
  14905. var right = dto.rightInfo.Find(x => x.Type == "A");
  14906. if (right == null)
  14907. {
  14908. return Ok(jw);
  14909. }
  14910. HideRows += 4;
  14911. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14912. if (rightBindData != null)
  14913. {
  14914. //经济舱 + 双人间 TBR
  14915. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14916. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14917. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14918. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14919. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14920. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14921. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14922. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14923. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14924. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14925. }
  14926. else
  14927. {
  14928. hideRowsList.Add(Row + startIndex + HideRows);
  14929. }
  14930. HideRows += 2;
  14931. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14932. if (rightBindData != null)
  14933. {
  14934. //经济舱 + 单人间 SGR
  14935. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14936. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14937. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14938. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14939. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14940. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14941. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14942. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14943. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14944. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14945. }
  14946. else
  14947. {
  14948. hideRowsList.Add(Row + startIndex + HideRows);
  14949. }
  14950. HideRows += 2;
  14951. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14952. if (rightBindData != null)
  14953. {
  14954. //公务舱 + 单人间 SGR
  14955. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14956. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14957. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14958. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14959. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14960. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14961. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14962. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14963. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14964. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14965. }
  14966. else
  14967. {
  14968. hideRowsList.Add(Row + startIndex + HideRows);
  14969. }
  14970. HideRows += 2;
  14971. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14972. if (rightBindData != null)
  14973. {
  14974. //公务舱 + 小套房 JSES
  14975. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14976. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14977. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14978. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14979. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14980. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14981. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14982. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14983. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14984. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14985. }
  14986. else
  14987. {
  14988. hideRowsList.Add(Row + startIndex + HideRows);
  14989. }
  14990. HideRows += 2;
  14991. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14992. if (rightBindData != null)
  14993. {
  14994. //公务舱 + 小套房 JSES
  14995. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14996. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14997. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14998. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14999. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15000. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15001. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15002. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15003. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15004. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15005. }
  15006. else
  15007. {
  15008. hideRowsList.Add(Row + startIndex + HideRows);
  15009. }
  15010. HideRows += 2;
  15011. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15012. if (rightBindData != null)
  15013. {
  15014. //经济舱 + 大套房
  15015. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15016. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15017. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15018. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15019. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15020. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15021. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15022. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15023. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15024. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15025. }
  15026. else
  15027. {
  15028. hideRowsList.Add(Row + startIndex + HideRows);
  15029. }
  15030. HideRows += 2;
  15031. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15032. if (rightBindData != null)
  15033. {
  15034. //头等舱 + 小套房 JSES
  15035. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15036. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15037. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15038. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15039. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15040. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15041. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15042. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15043. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15044. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15045. }
  15046. else
  15047. {
  15048. hideRowsList.Add(Row + startIndex + HideRows);
  15049. }
  15050. HideRows += 2;
  15051. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15052. if (rightBindData != null)
  15053. {
  15054. //头等舱 + 大套房
  15055. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15056. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15057. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15058. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15059. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15060. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15061. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15062. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15063. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15064. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15065. }
  15066. else
  15067. {
  15068. hideRowsList.Add(Row + startIndex + HideRows);
  15069. }
  15070. #endregion
  15071. #region B段标题清空
  15072. designer.SetDataSource("CostBDRCB", "");
  15073. designer.SetDataSource("CostBRS", "");
  15074. designer.SetDataSource("CostBXS", "");
  15075. designer.SetDataSource("CostBZCB", "");
  15076. designer.SetDataSource("CostBDRBJ", "");
  15077. designer.SetDataSource("CostBZBJ", "");
  15078. designer.SetDataSource("CostBDRLR", "");
  15079. designer.SetDataSource("CostBZLR", "");
  15080. designer.SetDataSource("CostBDRCBOM", "");
  15081. designer.SetDataSource("CostBRSOM", "");
  15082. designer.SetDataSource("CostBZCBOM", "");
  15083. designer.SetDataSource("CostBDRBJOM", "");
  15084. designer.SetDataSource("CostBZBJOM", "");
  15085. designer.SetDataSource("CostBDRLROM", "");
  15086. designer.SetDataSource("CostBZLROM", "");
  15087. #endregion
  15088. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15089. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15090. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15091. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15092. designer.SetDataSource("DJName", "地接(CNY)");
  15093. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15094. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15095. designer.SetDataSource("GWName", "公务(CNY)");
  15096. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15097. designer.SetDataSource("LYJName", "零用金(CNY)");
  15098. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15099. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15100. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15101. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15102. designer.SetDataSource("BXName", "保险(CNY)");
  15103. designer.SetDataSource("VisaName", "签证(CNY)");
  15104. #region B段基本数据
  15105. if (dto.costType == "B")
  15106. {
  15107. left = dto.leftInfo.Find(x => x.Type == "B");
  15108. if (left == null)
  15109. {
  15110. return Ok(jw);
  15111. }
  15112. #region B段left数据
  15113. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15114. if (leftBindData != null)
  15115. {
  15116. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15117. designer.SetDataSource("BHSRS", leftBindData.rs);
  15118. designer.SetDataSource("BHSXS", leftBindData.xs);
  15119. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15120. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15121. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15122. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15123. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15124. }
  15125. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15126. if (leftBindData != null)
  15127. {
  15128. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15129. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15130. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15131. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15132. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15133. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15134. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15135. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15136. }
  15137. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15138. if (leftBindData != null)
  15139. {
  15140. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15141. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15142. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15143. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15144. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15145. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15146. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15147. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15148. }
  15149. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15150. if (leftBindData != null)
  15151. {
  15152. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15153. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15154. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15155. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15156. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15157. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15158. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15159. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15160. }
  15161. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15162. if (leftBindData != null)
  15163. {
  15164. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15165. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15166. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15167. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15168. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15169. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15170. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15171. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15172. }
  15173. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15174. if (leftBindData != null)
  15175. {
  15176. designer.SetDataSource("BCPCB", leftBindData.cb);
  15177. designer.SetDataSource("BCPRS", leftBindData.rs);
  15178. designer.SetDataSource("BCPXS", leftBindData.xs);
  15179. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15180. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15181. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15182. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15183. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15184. }
  15185. //TBR
  15186. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15187. if (leftBindData != null)
  15188. {
  15189. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15190. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15191. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15192. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15193. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15194. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15195. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15196. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15197. }
  15198. //SGR
  15199. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15200. if (leftBindData != null)
  15201. {
  15202. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15203. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15204. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15205. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15206. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15207. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15208. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15209. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15210. }
  15211. //JS/ES
  15212. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15213. if (leftBindData != null)
  15214. {
  15215. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15216. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15217. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15218. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15219. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15220. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15221. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15222. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15223. }
  15224. //SUITE
  15225. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15226. if (leftBindData != null)
  15227. {
  15228. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15229. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15230. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15231. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15232. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15233. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15234. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15235. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15236. }
  15237. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15238. if (leftBindData != null)
  15239. {
  15240. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15241. designer.SetDataSource("BDJRS", leftBindData.rs);
  15242. designer.SetDataSource("BDJXS", leftBindData.xs);
  15243. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15244. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15245. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15246. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15247. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15248. }
  15249. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15250. if (leftBindData != null)
  15251. {
  15252. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15253. designer.SetDataSource("BGWRS", leftBindData.rs);
  15254. designer.SetDataSource("BGWXS", leftBindData.xs);
  15255. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15256. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15257. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15258. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15259. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15260. }
  15261. #region 优化方案
  15262. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15263. //excelBind.Add("零用金", new {
  15264. //cb="",
  15265. //rs="",
  15266. //xs ="",
  15267. //zcb = "",
  15268. //});
  15269. #endregion
  15270. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15271. if (leftBindData != null)
  15272. {
  15273. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15274. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15275. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15276. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15277. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15278. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15279. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15280. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15281. }
  15282. #endregion
  15283. #region B段Right信息
  15284. right = dto.rightInfo.Find(x => x.Type == "B");
  15285. if (right == null)
  15286. {
  15287. return Ok(jw);
  15288. }
  15289. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15290. if (rightBindData != null)
  15291. {
  15292. //经济舱 + 双人间 TBR
  15293. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15294. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15295. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15296. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15297. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15298. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15299. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15300. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15301. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15302. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15303. }
  15304. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15305. if (rightBindData != null)
  15306. {
  15307. //经济舱 + 单人间 SGR
  15308. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15309. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15310. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15311. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15312. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15313. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15314. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15315. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15316. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15317. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15318. }
  15319. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15320. if (rightBindData != null)
  15321. {
  15322. //公务舱 + 单人间 SGR
  15323. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15324. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15325. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15326. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15327. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15328. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15329. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15330. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15331. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15332. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15333. }
  15334. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15335. if (rightBindData != null)
  15336. {
  15337. //公务舱 + 小套房 JSES
  15338. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15339. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15340. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15341. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15342. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15343. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15344. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15345. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15346. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15347. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15348. }
  15349. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15350. if (rightBindData != null)
  15351. {
  15352. //公务舱 + 小套房 JSES
  15353. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15354. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15355. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15356. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15357. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15358. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15359. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15360. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15361. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15362. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15363. }
  15364. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15365. if (rightBindData != null)
  15366. {
  15367. //经济舱 + 大套房
  15368. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15369. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15370. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15371. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15372. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15373. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15374. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15375. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15376. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15377. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15378. }
  15379. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15380. if (rightBindData != null)
  15381. {
  15382. //头等舱 + 小套房 JSES
  15383. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15384. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15385. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15386. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15387. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15388. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15389. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15390. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15391. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15392. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15393. }
  15394. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15395. if (rightBindData != null)
  15396. {
  15397. //头等舱 + 大套房
  15398. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15399. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15400. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15401. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15402. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15403. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15404. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15405. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15406. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15407. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15408. }
  15409. #endregion
  15410. #region 标题
  15411. designer.SetDataSource("CostBDRCB", "单人成本");
  15412. designer.SetDataSource("CostBRS", "人数");
  15413. designer.SetDataSource("CostBXS", "系数");
  15414. designer.SetDataSource("CostBZCB", "总成本");
  15415. designer.SetDataSource("CostBDRBJ", "单人报价");
  15416. designer.SetDataSource("CostBZBJ", "总报价");
  15417. designer.SetDataSource("CostBDRLR", "单人利润");
  15418. designer.SetDataSource("CostBZLR", "总利润");
  15419. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15420. designer.SetDataSource("CostBRSOM", "人数");
  15421. designer.SetDataSource("CostBZCBOM", "总成本");
  15422. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15423. designer.SetDataSource("CostBZBJOM", "总报价");
  15424. designer.SetDataSource("CostBDRLROM", "单人利润");
  15425. designer.SetDataSource("CostBZLROM", "总利润");
  15426. #endregion
  15427. }
  15428. #endregion
  15429. designer.SetDataSource("TzZCB2", TzZCB2);
  15430. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15431. designer.SetDataSource("TzZLR2", TzZLR2);
  15432. string[] dataSourceKeys = new string[]
  15433. {
  15434. "VF",
  15435. "TGS",
  15436. "TGOF",
  15437. "TGM",
  15438. "TGA",
  15439. "TGTF",
  15440. "TGEF",
  15441. "CFM",
  15442. "CFOF",
  15443. "B",
  15444. "L",
  15445. "D",
  15446. "TBR",
  15447. "SGR",
  15448. "JSES",
  15449. "Suite",
  15450. "TV",
  15451. "1L",
  15452. "IF",
  15453. "EF",
  15454. "BRF",
  15455. "TE",
  15456. "TGT",
  15457. "DRVT",
  15458. "PC",
  15459. "TLF",
  15460. "ECT"
  15461. };
  15462. foreach (var item in dataSourceKeys)
  15463. {
  15464. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  15465. if (find != null)
  15466. {
  15467. designer.SetDataSource(item, find.text);
  15468. }
  15469. else
  15470. {
  15471. designer.SetDataSource(item, 0);
  15472. }
  15473. }
  15474. designer.SetDataSource(dt);
  15475. //根据数据源处理生成报表内容
  15476. designer.Process();
  15477. designer.Workbook.Worksheets[0].Name = "清单";
  15478. Worksheet sheet = designer.Workbook.Worksheets[0];
  15479. foreach (var Rowindex in hideRowsList)
  15480. {
  15481. ws.Cells.HideRows(Rowindex, 2);
  15482. }
  15483. byte[] bytes = null;
  15484. string strFileName = di.TeamName + "-团组-成本.xls";
  15485. using (MemoryStream stream = new MemoryStream())
  15486. {
  15487. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15488. bytes = stream.ToArray();
  15489. }
  15490. return Ok(JsonView(true, "", new
  15491. {
  15492. Data = bytes,
  15493. strFileName,
  15494. }));
  15495. }
  15496. /// <summary>
  15497. /// 导出客户报表
  15498. /// </summary>
  15499. /// <returns></returns>
  15500. [HttpPost]
  15501. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15502. {
  15503. var jw = JsonView(false);
  15504. if (dto.Diid == 0)
  15505. {
  15506. return Ok(JsonView(false, "请传递团组id"));
  15507. }
  15508. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15509. if (deleInfo.Code != 0)
  15510. {
  15511. return Ok(JsonView(false, "团组信息查询失败!"));
  15512. }
  15513. var di = deleInfo.Data as DelegationInfoWebView;
  15514. if (di == null)
  15515. {
  15516. return Ok(JsonView(false, "团组信息查询失败!"));
  15517. }
  15518. //文件名
  15519. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15520. //获取模板
  15521. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15522. //载入模板
  15523. Document doc = new Document(tmppath);
  15524. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15525. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15526. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15527. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15528. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15529. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15530. if (AParameter == null)
  15531. {
  15532. return Ok(JsonView(false, "系数不存在!"));
  15533. }
  15534. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15535. , TzAirDesc, TzZCost;
  15536. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15537. = TzAirDesc = TzZCost = string.Empty;
  15538. TzNumber = AParameter.CostTypenumber.ToString();
  15539. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15540. CarGuides1 = dto.CarGuides1;
  15541. Meal = dto.Meal;
  15542. SubsidizedMeals = dto.SubsidizedMeals;
  15543. NightRepair = dto.NightRepair;
  15544. AttractionsTickets = dto.AttractionsTickets;
  15545. MiscellaneousFees = dto.MiscellaneousFees;
  15546. ATip = dto.ATip;
  15547. TzHotelDesc = "";
  15548. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15549. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15550. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15551. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15552. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15553. TzAirDesc = "";
  15554. TzZCost = dto.TzZCost;
  15555. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15556. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15557. var index = 1;
  15558. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15559. foreach (var item in TzHotelDescArr)
  15560. {
  15561. if (AinfoArr != null)
  15562. {
  15563. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15564. if (Ainfo != null)
  15565. {
  15566. if (int.Parse(Ainfo.rs) <= 0)
  15567. {
  15568. continue;
  15569. }
  15570. var hotelText = string.Empty;
  15571. switch (item)
  15572. {
  15573. case "SGR":
  15574. hotelText = "单人间";
  15575. break;
  15576. case "JSES":
  15577. hotelText = "小套房";
  15578. break;
  15579. case "SUITE":
  15580. hotelText = "套房";
  15581. break;
  15582. case "TBR":
  15583. hotelText = "双人间";
  15584. break;
  15585. }
  15586. if (item != "TBR")
  15587. {
  15588. 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";
  15589. }
  15590. else
  15591. {
  15592. 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";
  15593. }
  15594. index++;
  15595. }
  15596. }
  15597. }
  15598. index = 1;
  15599. foreach (var item in TzAirDescArr)
  15600. {
  15601. if (AinfoArr != null)
  15602. {
  15603. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15604. if (Ainfo != null)
  15605. {
  15606. if (int.Parse(Ainfo.rs) <= 0)
  15607. {
  15608. continue;
  15609. }
  15610. 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";
  15611. index++;
  15612. }
  15613. }
  15614. }
  15615. if (dto.costType == "B")
  15616. {
  15617. if (BParameter == null)
  15618. {
  15619. return Ok(JsonView(false, "B段系数不存在!"));
  15620. }
  15621. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15622. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15623. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15624. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15625. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15626. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15627. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15628. foreach (var item in TzHotelDescArr)
  15629. {
  15630. if (AinfoArr != null)
  15631. {
  15632. TzHotelDesc += "B段信息 \r\n";
  15633. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15634. if (Ainfo != null)
  15635. {
  15636. if (int.Parse(Ainfo.rs) <= 0)
  15637. {
  15638. continue;
  15639. }
  15640. var hotelText = string.Empty;
  15641. switch (item)
  15642. {
  15643. case "SGR":
  15644. hotelText = "单人间";
  15645. break;
  15646. case "JSES":
  15647. hotelText = "小套房";
  15648. break;
  15649. case "SUITE":
  15650. hotelText = "套房";
  15651. break;
  15652. case "TBR":
  15653. hotelText = "双人间";
  15654. break;
  15655. }
  15656. if (item != "TBR")
  15657. {
  15658. 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";
  15659. }
  15660. else
  15661. {
  15662. 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";
  15663. }
  15664. index++;
  15665. }
  15666. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15667. }
  15668. }
  15669. index = 1;
  15670. foreach (var item in TzAirDescArr)
  15671. {
  15672. if (AinfoArr != null)
  15673. {
  15674. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15675. if (Ainfo != null)
  15676. {
  15677. if (int.Parse(Ainfo.rs) <= 0)
  15678. {
  15679. continue;
  15680. }
  15681. 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";
  15682. index++;
  15683. }
  15684. }
  15685. }
  15686. }
  15687. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15688. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15689. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15690. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15691. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15692. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15693. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15694. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15695. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15696. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15697. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15698. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15699. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15700. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15701. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15702. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15703. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15704. DickeyValue.Add("TzZCost", TzZCost);
  15705. foreach (var key in DickeyValue.Keys)
  15706. {
  15707. if (doc.Range.Bookmarks[key] != null)
  15708. {
  15709. Bookmark mark = doc.Range.Bookmarks[key];
  15710. mark.Text = DickeyValue[key];
  15711. }
  15712. }
  15713. byte[] bytes = null;
  15714. string strFileName = di.TeamName + "-客户报价.doc";
  15715. using (MemoryStream stream = new MemoryStream())
  15716. {
  15717. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15718. bytes = stream.ToArray();
  15719. }
  15720. return Ok(JsonView(true, "", new
  15721. {
  15722. Data = bytes,
  15723. strFileName,
  15724. }));
  15725. }
  15726. /// <summary>
  15727. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15728. /// </summary>
  15729. /// <param name="dto"></param>
  15730. /// <returns></returns>
  15731. [HttpPost]
  15732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15733. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15734. {
  15735. try
  15736. {
  15737. #region 参数验证
  15738. if (dto.DiId < 0)
  15739. {
  15740. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15741. }
  15742. List<int> cTableIds = new List<int>() {
  15743. 76 ,//酒店预订
  15744. 77 ,//行程
  15745. 79 ,//车/导游地接
  15746. 80 ,//签证
  15747. 81 ,//邀请/公务活
  15748. 82 ,//团组客户保险
  15749. 85 ,//机票预订
  15750. 98 ,//其他款项
  15751. 285 ,//收款退还
  15752. 751 ,//酒店早餐
  15753. 1015 // 超支费用
  15754. };
  15755. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15756. {
  15757. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15758. }
  15759. #endregion
  15760. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15761. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15762. if (_GroupCostParameters.Count <= 0)
  15763. {
  15764. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15765. }
  15766. if (_GroupCostParameters[0].IsShare == 0)
  15767. {
  15768. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15769. }
  15770. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15771. //处理date为空问题
  15772. if (_GroupCosts.Count > 0)
  15773. {
  15774. for (int i = 0; i < _GroupCosts.Count; i++)
  15775. {
  15776. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15777. {
  15778. if (i > 0)
  15779. {
  15780. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15781. }
  15782. }
  15783. }
  15784. }
  15785. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15786. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15787. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15788. string currCode = "";
  15789. #region currCode 验证
  15790. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15791. if (isInt)
  15792. {
  15793. var currData = currDatas.Find(it => it.Id == intCurrency);
  15794. if (currData != null)
  15795. {
  15796. currCode = currData.Name;
  15797. }
  15798. }
  15799. else
  15800. {
  15801. currCode = _GroupCostParameters[0].Currency.Trim();
  15802. }
  15803. #endregion
  15804. //op,酒店单段模式存储
  15805. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15806. {
  15807. CurrencyCode = currCode,
  15808. Rate = _GroupCostParameters[0].Rate,
  15809. CostType = _GroupCostParameters[0].CostType,
  15810. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15811. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15812. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15813. };
  15814. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15815. if (_GroupCostParameters.Count == 2)
  15816. {
  15817. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15818. }
  15819. foreach (var item in _GroupCostParameters)
  15820. {
  15821. decimal _rate = 1;
  15822. decimal _rate1 = item.Rate;
  15823. decimal _scale = 1;
  15824. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15825. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15826. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15827. //if (userInfo != null)
  15828. //{
  15829. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15830. // {
  15831. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15832. // {
  15833. // _scale = 1.00M;
  15834. // }
  15835. // }
  15836. //}
  15837. #endregion
  15838. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15839. {
  15840. CurrencyCode = currCode,
  15841. Rate = _rate1,
  15842. CostType = item.CostType,
  15843. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15844. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15845. CostTypeNumber = item.CostTypenumber
  15846. };
  15847. if (_GroupCostParameters.Count > 1)
  15848. {
  15849. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15850. }
  15851. else
  15852. {
  15853. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15854. }
  15855. if (dto.CTable == 79)//
  15856. {
  15857. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15858. modulePromptInfo.TotalCost = item.DJCB;
  15859. }
  15860. List<string> costTypes = new List<string>() { "A", "B" };
  15861. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15862. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15863. if (_GroupCostsDuplicates.Count() == 1)
  15864. {
  15865. _GroupCostsTypeData = _GroupCosts;
  15866. }
  15867. else
  15868. {
  15869. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15870. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15871. }
  15872. /*
  15873. * 76 酒店预订
  15874. * 77 行程
  15875. * 79 车/导游地接
  15876. * 80 签证
  15877. * 81 邀请/公务活动
  15878. * 82 团组客户保险
  15879. * 85 机票预订
  15880. * 98 其他款项
  15881. * 285 收款退还
  15882. * 751 酒店早餐
  15883. * 1015 超支费用
  15884. */
  15885. switch (dto.CTable)
  15886. {
  15887. case 76: // 酒店预订
  15888. _ModuleSubPromptInfo.AddRange(
  15889. _GroupCostsTypeData.Select(it => new
  15890. {
  15891. it.DAY,
  15892. it.Date,
  15893. it.ACCON,
  15894. it.ITIN,
  15895. it.SGR,
  15896. it.TBR,
  15897. it.JS_ES,
  15898. it.Suite
  15899. })
  15900. );
  15901. break;
  15902. case 79: // 车/导游地接
  15903. _ModuleSubPromptInfo.AddRange(
  15904. _GroupCostsTypeData.Select(it => new
  15905. {
  15906. Date = it.Date, //日期
  15907. CarFee = it.CarCost * _rate * _scale, //车费用
  15908. CarType = it.CarType, //车型
  15909. DriverFee = it.CFS * _rate * _scale, //司机工资
  15910. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15911. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15912. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15913. GuideFee = it.TGS * _rate * _scale, //导游费用
  15914. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15915. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15916. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15917. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15918. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15919. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15920. Breakfast = it.B * _rate * _scale, //早餐费
  15921. Lunch = it.L * _rate * _scale, //午餐费
  15922. Dinner = it.D * _rate * _scale, //晚餐费
  15923. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15924. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15925. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15926. TicketFee = it.EF * _rate * _scale, //门票费
  15927. TicketRemark = it.EFR, //门票费描述
  15928. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15929. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15930. SpentCash = it.PC * _rate * _scale, //零用金
  15931. LeadersFee = it.TLF * _rate * _scale, //领队费
  15932. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15933. })
  15934. );
  15935. break;
  15936. case 85: // 机票
  15937. List<dynamic> datas = new List<dynamic>();
  15938. datas.Add(
  15939. new
  15940. {
  15941. AirType = "经济舱",
  15942. AirNum = item.JJCRS,
  15943. AirDRCB = item.JJCCB,
  15944. AirZCB = (item.JJCRS * item.JJCCB)
  15945. }
  15946. );
  15947. datas.Add(
  15948. new
  15949. {
  15950. AirType = "公务舱",
  15951. AirNum = item.GWCRS,
  15952. AirDRCB = item.GWCCB,
  15953. AirZCB = (item.GWCRS * item.GWCCB)
  15954. }
  15955. );
  15956. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15957. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15958. modulePromptInfo.Data = new
  15959. {
  15960. airFeeData = datas,
  15961. airInitData = initDatas
  15962. };
  15963. _ModulePromptInfos.Add(modulePromptInfo);
  15964. break;
  15965. default:
  15966. break;
  15967. }
  15968. }
  15969. if (dto.CTable != 85)
  15970. {
  15971. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15972. _ModulePromptInfos.Add(_ModulePromptInfo);
  15973. }
  15974. _view.ModulePromptInfos = _ModulePromptInfos;
  15975. return Ok(JsonView(true, "操作成功!", _view));
  15976. }
  15977. catch (Exception ex)
  15978. {
  15979. return Ok(JsonView(false, ex.Message));
  15980. }
  15981. }
  15982. /// <summary>
  15983. /// 根据黑屏代码重新生成行程
  15984. /// </summary>
  15985. /// <param name="dto"></param>
  15986. /// <returns></returns>
  15987. [HttpPost]
  15988. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15989. {
  15990. var jw = JsonView(false, "Error");
  15991. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15992. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15993. .Select(x => new
  15994. {
  15995. x.Id,
  15996. x.Title
  15997. })
  15998. .ToList();
  15999. if (Create.Any())
  16000. {
  16001. jw.Msg = "获取成功!";
  16002. jw.Code = 200;
  16003. jw.Data = new
  16004. {
  16005. BlackCodeListSelect = Create,
  16006. blackCodeIsTrue = true
  16007. };
  16008. }
  16009. else
  16010. {
  16011. jw.Code = 400;
  16012. jw.Data = new
  16013. {
  16014. BlackCodeListSelect = Create,
  16015. blackCodeIsTrue = false,
  16016. };
  16017. }
  16018. return Ok(jw);
  16019. }
  16020. /// <summary>
  16021. /// 根据黑屏代码Id重新生成行程
  16022. /// </summary>
  16023. /// <param name="dto"></param>
  16024. /// <returns></returns>
  16025. [HttpPost]
  16026. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16027. {
  16028. var jw = JsonView(false, "Error");
  16029. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16030. if (result.Code == 0)
  16031. {
  16032. jw.Msg = "获取成功!";
  16033. jw.Code = 200;
  16034. jw.Data = new
  16035. {
  16036. groupCost = result.Data,
  16037. blackCodeIsTrue = true
  16038. };
  16039. }
  16040. else
  16041. {
  16042. jw.Code = 400;
  16043. jw.Data = new
  16044. {
  16045. groupCost = result.Data,
  16046. blackCodeIsTrue = false,
  16047. };
  16048. }
  16049. return Ok(jw);
  16050. }
  16051. /// <summary>
  16052. /// 成本获取OP历史车费用
  16053. /// </summary>
  16054. /// <param name="dto"></param>
  16055. /// <returns></returns>
  16056. [HttpPost]
  16057. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16058. {
  16059. var jw = JsonView(false);
  16060. try
  16061. {
  16062. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16063. //获取现有所有车的数据
  16064. if (!dto.Param.IsNullOrWhiteSpace())
  16065. {
  16066. string sql = $@"
  16067. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16068. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16069. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16070. 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
  16071. AND gctggr.ServiceEndTime is not NULL
  16072. ORDER by gctggrc.id DESC
  16073. ";
  16074. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16075. var numeberResult = await Task.Run(() =>
  16076. {
  16077. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16078. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16079. return numberArr;
  16080. });
  16081. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16082. foreach (var item in numeberResult)
  16083. {
  16084. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16085. {
  16086. Country = "数据异常!",
  16087. City = string.Empty,
  16088. };
  16089. item.Area = find.Country + " " + find.City;
  16090. }
  16091. dbResult.AddRange(numeberResult);
  16092. if (dto.Param.Contains("、"))
  16093. {
  16094. var sp = dto.Param.Split("、");
  16095. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16096. .Where(x =>
  16097. {
  16098. return System.Array.Exists(sp, e =>
  16099. {
  16100. bool where = false;
  16101. if (x.Area != null)
  16102. {
  16103. where = x.Area.Contains(e);
  16104. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16105. {
  16106. return false;
  16107. }
  16108. }
  16109. if (x.PriceName != null && !where)
  16110. {
  16111. where = x.PriceName.Contains(e);
  16112. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16113. {
  16114. return false;
  16115. }
  16116. }
  16117. return where;
  16118. });
  16119. }).ToList();
  16120. }
  16121. else
  16122. {
  16123. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16124. .Where(x =>
  16125. {
  16126. bool where = false;
  16127. if (x.Area != null)
  16128. {
  16129. where = x.Area.Contains(dto.Param);
  16130. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16131. {
  16132. return false;
  16133. }
  16134. }
  16135. if (x.PriceName != null && !where)
  16136. {
  16137. where = x.PriceName.Contains(dto.Param);
  16138. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16139. {
  16140. return false;
  16141. }
  16142. }
  16143. return where;
  16144. }
  16145. )
  16146. .ToList();
  16147. }
  16148. }
  16149. var view = dbResult.Select(x =>
  16150. {
  16151. decimal dp = 0.00M;
  16152. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16153. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16154. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16155. {
  16156. if (startB && endB)
  16157. {
  16158. var timesp = endD.Subtract(startD);
  16159. if ((timesp.Days + 1) != 0)
  16160. {
  16161. dp = x.Price / (timesp.Days + 1);
  16162. }
  16163. }
  16164. }
  16165. else
  16166. {
  16167. dp = x.Price;
  16168. }
  16169. return new
  16170. {
  16171. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16172. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16173. x.Area,
  16174. x.id,
  16175. price = x.Price.ToString("F2"),
  16176. x.PriceName,
  16177. x.PriceContent,
  16178. x.TeamName,
  16179. x.DatePrice,
  16180. dayPrice = dp.ToString("F2"),
  16181. };
  16182. }).OrderByDescending(x => x.id).ToList();
  16183. jw = JsonView(true, "获取成功!", view);
  16184. }
  16185. catch (Exception e)
  16186. {
  16187. jw = JsonView(false, e.Message);
  16188. }
  16189. return Ok(jw);
  16190. }
  16191. [HttpPost]
  16192. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16193. {
  16194. var jw = JsonView(true);
  16195. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16196. #region SQL语句
  16197. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16198. //{
  16199. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16200. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16201. // WHEN COUNT(*) >= 0 THEN 'True'
  16202. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16203. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16204. // ")
  16205. // .ToList();
  16206. //}
  16207. //else
  16208. //{
  16209. // string likeKey = string.Empty;
  16210. // foreach (var item in dto.Keyword)
  16211. // {
  16212. // likeKey += "%" + item;
  16213. // }
  16214. // likeKey += "%";
  16215. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16216. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16217. // WHEN COUNT(*) >= 0 THEN 'True'
  16218. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16219. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16220. // ")
  16221. // .ToList();
  16222. //}
  16223. #endregion
  16224. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16225. {
  16226. @KeyWord = dto.Keyword
  16227. });
  16228. if (table != null && table.Rows.Count > 0)
  16229. {
  16230. foreach (DataRow row in table.Rows)
  16231. {
  16232. matches.Add(new DelegationInfoAndIsTrueView
  16233. {
  16234. Id = row.Field<int>("Id"),
  16235. GroupName = row.Field<string>("GroupName"),
  16236. isTrue = row.Field<string>("isTrue")
  16237. });
  16238. }
  16239. }
  16240. if (matches.Any())
  16241. {
  16242. jw.Data = matches;
  16243. }
  16244. else
  16245. {
  16246. jw.Code = 201;
  16247. jw.Msg = "empty list";
  16248. jw.Data = new List<string>(1);
  16249. }
  16250. return Ok(jw);
  16251. }
  16252. /// <summary>
  16253. /// 报价Word下载
  16254. /// </summary>
  16255. /// <param name="dto"></param>
  16256. /// <returns></returns>
  16257. [HttpPost]
  16258. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16259. {
  16260. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16261. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16262. if (di == null)
  16263. {
  16264. return Ok(JsonView(false, "团组不存在!"));
  16265. }
  16266. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16267. if (mainPrice == null || mainPrice.IsShare == 0)
  16268. {
  16269. return Ok(JsonView(false, "团组成本不存在!"));
  16270. }
  16271. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16272. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16273. if (costTypeHotelNumbers == null)
  16274. {
  16275. return Ok(JsonView(false, "团组成本不存在!"));
  16276. }
  16277. //文件名
  16278. string strFileName = di.TeamName + "-收款账单.doc";
  16279. //获取模板
  16280. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16281. //载入模板
  16282. Document doc = new Document(tmppath);
  16283. decimal allPrice = 0.00M;
  16284. string itemStr = string.Empty;
  16285. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16286. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16287. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16288. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16289. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16290. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16291. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16292. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16293. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16294. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16295. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16296. {
  16297. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16298. ("BXRS", "BXCB", "BXXS", "bx"),
  16299. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16300. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16301. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16302. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16303. ("CPRS", "CPCB", "CPXS", "cp"),
  16304. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16305. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16306. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16307. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16308. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16309. ("DJRS", "DJCB", "DJXS", "dj"),
  16310. ("GWRS", "GWCB", "GWXS", "gw"),
  16311. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16312. };
  16313. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16314. var rightSum = 0.00M;
  16315. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16316. {
  16317. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16318. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16319. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16320. if (prefix == "tbr")
  16321. {
  16322. rsValue *= 2;
  16323. cbValue /= 2;
  16324. }
  16325. if (OtherCostPropertyBJ.Contains(prefix))
  16326. {
  16327. rightSum += cbValue * xsValue;
  16328. }
  16329. }
  16330. var hotelRooms = new Dictionary<string, int>
  16331. {
  16332. { "SGR", costTypeHotelNumbers.SGR },
  16333. { "TBR", costTypeHotelNumbers.TBR },
  16334. { "JSES", costTypeHotelNumbers.JSES },
  16335. { "SUITE", costTypeHotelNumbers.SUITE }
  16336. };
  16337. var flights = new Dictionary<string, int>
  16338. {
  16339. { "经济舱", mainPrice.JJCRS },
  16340. { "公务舱", mainPrice.GWCRS },
  16341. { "头等舱", mainPrice.TDCRS }
  16342. };
  16343. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16344. {
  16345. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16346. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16347. { "头等舱", new[] { "SUITE", "JSES" } }
  16348. };
  16349. var result = new Dictionary<string, int>();
  16350. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16351. foreach (var flight in flights.Keys)
  16352. {
  16353. // 获取当前舱位的匹配规则
  16354. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16355. {
  16356. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16357. }
  16358. }
  16359. #region right计算
  16360. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16361. {
  16362. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16363. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16364. airHotelPriceList.Add(new
  16365. AirHotelPrice
  16366. {
  16367. Name = "经济舱TBR",
  16368. Price = rightSum + air + hotel,
  16369. Count = result["经济舱TBR"] * 2
  16370. });
  16371. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16372. }
  16373. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16374. {
  16375. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16376. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16377. airHotelPriceList.Add(new
  16378. AirHotelPrice
  16379. {
  16380. Name = "经济舱SGR",
  16381. Price = rightSum + air + hotel,
  16382. Count = result["经济舱SGR"]
  16383. });
  16384. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16385. }
  16386. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16387. {
  16388. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16389. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16390. airHotelPriceList.Add(new
  16391. AirHotelPrice
  16392. {
  16393. Name = "公务舱SGR",
  16394. Price = rightSum + air + hotel,
  16395. Count = result["公务舱SGR"]
  16396. });
  16397. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16398. }
  16399. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16400. {
  16401. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16402. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16403. airHotelPriceList.Add(new
  16404. AirHotelPrice
  16405. {
  16406. Name = "公务舱JSES",
  16407. Price = rightSum + air + hotel,
  16408. Count = result["公务舱JSES"]
  16409. });
  16410. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16411. }
  16412. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16413. {
  16414. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16415. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16416. airHotelPriceList.Add(new
  16417. AirHotelPrice
  16418. {
  16419. Name = "公务舱SUITE",
  16420. Price = rightSum + air + hotel,
  16421. Count = result["公务舱SUITE"]
  16422. });
  16423. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16424. }
  16425. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16426. {
  16427. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16428. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16429. airHotelPriceList.Add(new
  16430. AirHotelPrice
  16431. {
  16432. Name = "经济舱SUITE",
  16433. Price = rightSum + air + hotel,
  16434. Count = result["经济舱SUITE"]
  16435. });
  16436. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16437. }
  16438. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16439. {
  16440. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16441. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16442. airHotelPriceList.Add(new
  16443. AirHotelPrice
  16444. {
  16445. Name = "头等舱JSES",
  16446. Price = rightSum + air + hotel,
  16447. Count = result["头等舱JSES"]
  16448. });
  16449. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16450. }
  16451. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16452. {
  16453. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16454. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16455. airHotelPriceList.Add(new
  16456. AirHotelPrice
  16457. {
  16458. Name = "头等舱SUITE",
  16459. Price = rightSum + air + hotel,
  16460. Count = result["头等舱SUITE"]
  16461. });
  16462. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16463. }
  16464. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16465. {
  16466. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16467. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16468. airHotelPriceList.Add(new
  16469. AirHotelPrice
  16470. {
  16471. Name = "经济舱JSES",
  16472. Price = rightSum + air + hotel,
  16473. Count = result["经济舱JSES"]
  16474. });
  16475. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16476. }
  16477. #endregion
  16478. foreach (var item in airSouer.Keys)
  16479. {
  16480. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16481. if (find != null && find.Count > 0)
  16482. {
  16483. if (item.Contains("TBR"))
  16484. {
  16485. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16486. }
  16487. else
  16488. {
  16489. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16490. }
  16491. }
  16492. }
  16493. #region 替换Word模板书签内容
  16494. Dictionary<string, string> marks = new Dictionary<string, string>();
  16495. marks.Add("To", di.ClientUnit);//付款方
  16496. marks.Add("ToTel", di.TellPhone);//付款方电话
  16497. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16498. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16499. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16500. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16501. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16502. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16503. marks.Add("PayItemContent", itemStr);//详细信息
  16504. marks.Add("Total", allPrice.ToString("F2"));//合计
  16505. #endregion
  16506. foreach (var item in marks.Keys)
  16507. {
  16508. if (doc.Range.Bookmarks[item] != null)
  16509. {
  16510. Bookmark mark = doc.Range.Bookmarks[item];
  16511. mark.Text = marks[item];
  16512. }
  16513. }
  16514. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16515. doc.Save(savePaht);
  16516. var jw = new JsonView();
  16517. jw.Msg = "生成成功!";
  16518. jw.Code = 200;
  16519. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16520. return Ok(jw);
  16521. }
  16522. /// <summary>
  16523. /// 详细报价费用Excel下载
  16524. /// </summary>
  16525. /// <param name="dto"></param>
  16526. /// <returns></returns>
  16527. [HttpPost]
  16528. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16529. {
  16530. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16531. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16532. if (di == null)
  16533. {
  16534. return Ok(JsonView(false, "团组不存在!"));
  16535. }
  16536. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16537. if (mainPrice == null || mainPrice.IsShare == 0)
  16538. {
  16539. return Ok(JsonView(false, "团组成本不存在!"));
  16540. }
  16541. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16542. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16543. if (costTypeHotelNumbers == null)
  16544. {
  16545. return Ok(JsonView(false, "团组成本不存在!"));
  16546. }
  16547. WorkbookDesigner designer = new WorkbookDesigner();
  16548. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16549. List<int> hideRowsList = new List<int>();
  16550. int conterStartIndex = 3;
  16551. int rowIndex = conterStartIndex;
  16552. designer.SetDataSource("GroupName", di.TeamName);
  16553. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16554. {
  16555. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16556. ("BXRS", "BXCB", "BXXS", "bx"),
  16557. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16558. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16559. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16560. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16561. ("CPRS", "CPCB", "CPXS", "cp") ,
  16562. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16563. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16564. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16565. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16566. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16567. ("DJRS", "DJCB", "DJXS", "dj") ,
  16568. ("GWRS", "GWCB", "GWXS", "gw") ,
  16569. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16570. };
  16571. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16572. var rightSum = 0.00M;
  16573. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16574. {
  16575. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16576. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16577. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16578. if (prefix == "tbr")
  16579. {
  16580. rsValue *= 2;
  16581. cbValue /= 2;
  16582. }
  16583. if (OtherCostPropertyBJ.Contains(prefix))
  16584. {
  16585. rightSum += cbValue * xsValue;
  16586. }
  16587. if (rsValue == 0)
  16588. {
  16589. hideRowsList.Add(rowIndex);
  16590. }
  16591. else
  16592. {
  16593. designer.SetDataSource($"{prefix}rs", rsValue);
  16594. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16595. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16596. }
  16597. rowIndex += 2;
  16598. }
  16599. var hotelRooms = new Dictionary<string, int>
  16600. {
  16601. { "SGR", costTypeHotelNumbers.SGR },
  16602. { "TBR", costTypeHotelNumbers.TBR },
  16603. { "JSES", costTypeHotelNumbers.JSES },
  16604. { "SUITE", costTypeHotelNumbers.SUITE }
  16605. };
  16606. var flights = new Dictionary<string, int>
  16607. {
  16608. { "经济舱", mainPrice.JJCRS },
  16609. { "公务舱", mainPrice.GWCRS },
  16610. { "头等舱", mainPrice.TDCRS }
  16611. };
  16612. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16613. {
  16614. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16615. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16616. { "头等舱", new[] { "SUITE", "JSES" } }
  16617. };
  16618. var result = new Dictionary<string, int>();
  16619. foreach (var flight in flights.Keys)
  16620. {
  16621. // 获取当前舱位的匹配规则
  16622. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16623. {
  16624. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16625. }
  16626. }
  16627. var allPrice = 0.00M;
  16628. #region right计算
  16629. int airRowIndex = 35;
  16630. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16631. {
  16632. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16633. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16634. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16635. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16636. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16637. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16638. }
  16639. else
  16640. {
  16641. hideRowsList.Add(airRowIndex);
  16642. }
  16643. airRowIndex += 2;
  16644. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16645. {
  16646. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16647. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16648. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16649. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16650. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16651. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16652. }
  16653. else
  16654. {
  16655. hideRowsList.Add(airRowIndex);
  16656. }
  16657. airRowIndex += 2;
  16658. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16659. {
  16660. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16661. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16662. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16663. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16664. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16665. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16666. }
  16667. else
  16668. {
  16669. hideRowsList.Add(airRowIndex);
  16670. }
  16671. airRowIndex += 2;
  16672. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16673. {
  16674. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16675. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16676. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16677. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16678. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16679. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16680. }
  16681. else
  16682. {
  16683. hideRowsList.Add(airRowIndex);
  16684. }
  16685. airRowIndex += 2;
  16686. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16687. {
  16688. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16689. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16690. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16691. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16692. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16693. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16694. }
  16695. else
  16696. {
  16697. hideRowsList.Add(airRowIndex);
  16698. }
  16699. airRowIndex += 2;
  16700. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16701. {
  16702. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16703. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16704. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16705. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16706. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16707. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16708. }
  16709. else
  16710. {
  16711. hideRowsList.Add(airRowIndex);
  16712. }
  16713. airRowIndex += 2;
  16714. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16715. {
  16716. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16717. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16718. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16719. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16720. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16721. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16722. }
  16723. else
  16724. {
  16725. hideRowsList.Add(airRowIndex);
  16726. }
  16727. airRowIndex += 2;
  16728. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16729. {
  16730. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16731. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16732. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16733. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16734. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16735. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16736. }
  16737. else
  16738. {
  16739. hideRowsList.Add(airRowIndex);
  16740. }
  16741. airRowIndex += 2;
  16742. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16743. {
  16744. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16745. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16746. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16747. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16748. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16749. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16750. }
  16751. else
  16752. {
  16753. hideRowsList.Add(airRowIndex);
  16754. }
  16755. #endregion
  16756. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  16757. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  16758. var ws = designer.Workbook.Worksheets[0];
  16759. foreach (var Rowindex in hideRowsList)
  16760. {
  16761. ws.Cells.HideRows(Rowindex, 2);
  16762. }
  16763. designer.Process();
  16764. designer.Workbook.Save(savePaht);
  16765. return Ok(JsonView(true, "生成成功!", new
  16766. {
  16767. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16768. }));
  16769. }
  16770. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  16771. {
  16772. foreach (var roomType in roomTypes)
  16773. {
  16774. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16775. {
  16776. hotelRooms[roomType]--;
  16777. flights[flightType]--;
  16778. if (roomType == "TBR")
  16779. {
  16780. flights[flightType]--; // 双人间在减少1
  16781. }
  16782. string key = flightType + roomType;
  16783. if (result.Keys.Contains(key))
  16784. {
  16785. result[key]++;
  16786. }
  16787. else
  16788. {
  16789. result.Add(key, 1);
  16790. }
  16791. }
  16792. }
  16793. }
  16794. private class AirHotelPrice
  16795. {
  16796. public string Name { get; set; }
  16797. public decimal Price { get; set; }
  16798. public int Count { get; set; }
  16799. }
  16800. private class HotelSum
  16801. {
  16802. internal decimal SGR { get; set; }
  16803. internal decimal TBR { get; set; }
  16804. internal decimal JSES { get; set; }
  16805. internal decimal SUITE { get; set; }
  16806. internal decimal AllPrice {
  16807. get { return SGR + TBR + JSES + SUITE; }
  16808. }
  16809. }
  16810. [HttpPost]
  16811. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  16812. {
  16813. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16814. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16815. if (di == null)
  16816. {
  16817. return Ok(JsonView(false, "团组不存在!"));
  16818. }
  16819. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>()
  16820. .Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  16821. .ToList();
  16822. var groupHotelNumber = _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16823. .Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  16824. .ToList();
  16825. var groupHotelNumberDefault = groupHotelNumber.FirstOrDefault(x => x.Type == "Default");
  16826. HotelSum hotelSumP = new ();
  16827. if (groupCost.Any())
  16828. {
  16829. hotelSumP.SGR = groupHotelNumberDefault.SGR > 0 ? groupCost.Sum(x => x.SGR) * groupHotelNumberDefault.SGR : 0 ;
  16830. hotelSumP.TBR = groupHotelNumberDefault.TBR > 0 ? groupCost.Sum(x => x.TBR) * groupHotelNumberDefault.TBR : 0;
  16831. hotelSumP.JSES = groupHotelNumberDefault.JSES > 0 ? groupCost.Sum(x => x.JS_ES) * groupHotelNumberDefault.JSES : 0;
  16832. hotelSumP.SUITE = groupHotelNumberDefault.SUITE > 0 ? groupCost.Sum(x => x.Suite) * groupHotelNumberDefault.SUITE : 0;
  16833. }
  16834. #region 地接系数
  16835. Func<int, decimal> coefficientByDJ = (number) =>
  16836. {
  16837. if (number < 1) return 0.00M;
  16838. return number switch
  16839. {
  16840. < 6 => 2.5M,
  16841. 6 => 2.4M,
  16842. 7 => 1.8M,
  16843. 8 => 2.0M,
  16844. 9 => 3.0M,
  16845. 10 => 1.75M,
  16846. > 10 => 1.9M,
  16847. };
  16848. };
  16849. #endregion
  16850. #region 酒店系数
  16851. #endregion
  16852. return Ok(JsonView(true, "查询成功", new
  16853. {
  16854. HotelSum = hotelSumP,
  16855. CoefficientByDJ = coefficientByDJ(di.VisitPNumber) // 示例调用
  16856. }));
  16857. }
  16858. #endregion
  16859. #region 酒店预订 New 2023-12-28 17:45
  16860. /// <summary>
  16861. /// 酒店预订
  16862. /// 酒店费用列表 根据团组Id查询
  16863. /// </summary>
  16864. /// <param name="_dto"></param>
  16865. /// <returns></returns>
  16866. [HttpPost]
  16867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16868. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  16869. {
  16870. #region 参数验证
  16871. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16872. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16873. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16874. #region 团组操作权限验证 76 酒店预定模块
  16875. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16876. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16877. #endregion
  16878. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16879. #region 页面操作权限验证
  16880. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16881. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16882. #endregion
  16883. #endregion
  16884. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  16885. }
  16886. /// <summary>
  16887. /// 酒店预订
  16888. /// 基础数据
  16889. /// </summary>
  16890. /// <param name="_dto"></param>
  16891. /// <returns></returns>
  16892. [HttpPost]
  16893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16894. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  16895. {
  16896. #region 参数验证
  16897. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16898. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16899. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16900. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16901. #region 页面操作权限验证
  16902. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16903. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16904. #endregion
  16905. #region 团组操作权限验证 76 酒店预定模块
  16906. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16907. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16908. #endregion
  16909. #endregion
  16910. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  16911. }
  16912. /// <summary>
  16913. /// 酒店预订
  16914. /// 创建 入住卷号码
  16915. /// </summary>
  16916. /// <param name="_dto"></param>
  16917. /// <returns></returns>
  16918. [HttpPost]
  16919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16920. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  16921. {
  16922. #region 参数验证
  16923. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16924. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16925. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16926. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16927. #region 页面操作权限验证
  16928. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16929. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16930. #endregion
  16931. #region 团组操作权限验证 76 酒店预定模块
  16932. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16933. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16934. #endregion
  16935. #endregion
  16936. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  16937. if (data.Code != 0)
  16938. {
  16939. return Ok(JsonView(false, data.Msg));
  16940. }
  16941. return Ok(JsonView(true, data.Msg, data.Data));
  16942. }
  16943. /// <summary>
  16944. /// 酒店预订
  16945. /// 详情
  16946. /// </summary>
  16947. /// <param name="_dto"></param>
  16948. /// <returns></returns>
  16949. [HttpPost]
  16950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16951. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  16952. {
  16953. #region 参数验证
  16954. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  16955. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16956. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  16957. #region 团组操作权限验证 76 酒店预定模块
  16958. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16959. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16960. #endregion
  16961. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16962. #region 页面操作权限验证
  16963. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16964. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16965. #endregion
  16966. #endregion
  16967. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  16968. }
  16969. /// <summary>
  16970. /// 酒店预订
  16971. /// Add Or Edit
  16972. /// </summary>
  16973. /// <param name="_dto"></param>
  16974. /// <returns></returns>
  16975. [HttpPost]
  16976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16977. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  16978. {
  16979. #region 参数验证
  16980. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16981. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16982. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16983. #region 团组操作权限验证 76 酒店预定模块
  16984. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16985. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16986. #endregion
  16987. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16988. #region 页面操作权限验证
  16989. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16990. if (_dto.Id == 0) // Add
  16991. {
  16992. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16993. }
  16994. else if (_dto.Id > 1) // Edit
  16995. {
  16996. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16997. }
  16998. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  16999. #endregion
  17000. #endregion
  17001. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17002. if (_view.Code != 200)
  17003. {
  17004. return Ok(_view);
  17005. }
  17006. #region 成本无酒店价格数据进入超支
  17007. _sqlSugar.BeginTran();
  17008. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17009. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17010. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17011. for (int i = 0; i < groupCost.Count; i++)
  17012. {
  17013. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17014. {
  17015. groupCost[i].Date = groupCost[i - 1].Date;
  17016. }
  17017. }
  17018. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17019. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17020. List<Fin_GroupExtraCostDto_OP>();
  17021. if (start_Bool && end_Bool)
  17022. {
  17023. while (start_Time < end_Time)
  17024. {
  17025. foreach (var item in groupCost_Grp)
  17026. {
  17027. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17028. {
  17029. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17030. {
  17031. extraCostList.Add(new
  17032. Fin_GroupExtraCostDto_OP
  17033. {
  17034. Area = _dto.AreaId,
  17035. coefficient = 1.5M,
  17036. createUser = _dto.UserId,
  17037. currency = _dto.CardPriceCurrency,
  17038. diId = _dto.DiId,
  17039. ManagerConfirm = 0,
  17040. SupervisorConfirm = 0,
  17041. SYsupervisorConfirm = 0,
  17042. editType = 1,
  17043. PortType = 1,
  17044. price = _dto.CardPrice,
  17045. PriceCount = 1,
  17046. priceType = 1027,
  17047. priceDetailType = 1044,
  17048. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17049. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17050. });
  17051. }
  17052. }
  17053. }
  17054. start_Time = start_Time.AddDays(1);
  17055. }
  17056. }
  17057. if (extraCostList.Any())
  17058. {
  17059. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17060. }
  17061. _sqlSugar.CommitTran();
  17062. #endregion
  17063. #region 应用推送
  17064. try
  17065. {
  17066. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17067. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17068. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17069. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17070. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17071. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17072. var diId = _dto.DiId;
  17073. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17074. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17075. #region 操作记录
  17076. var opInfo = new Crm_TableOperationRecord()
  17077. {
  17078. TableName = "Grp_HotelReservations",
  17079. PortType = _dto.PortType,
  17080. DataId = hotelId,
  17081. CreateUserId = _dto.UserId
  17082. };
  17083. //var opStatus = OperationEnum.NoOperation;
  17084. if (_dto.Id < 1) //添加操作
  17085. {
  17086. opInfo.OperationItem = OperationEnum.Add;
  17087. }
  17088. else if (_dto.Id > 0)
  17089. {
  17090. opInfo.OperationItem = OperationEnum.Edit;
  17091. }
  17092. string opRemark = string.Empty;
  17093. if (ccpInfo != null)
  17094. {
  17095. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17096. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17097. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17098. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17099. }
  17100. opInfo.Remark = opRemark;
  17101. await _tableorRep.AddAsync(opInfo);
  17102. #endregion
  17103. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17104. //2024-10-21 新增LZ UID
  17105. var userIds = new List<int>() { 21 };
  17106. string title = $"费用审核";
  17107. string content = "";
  17108. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17109. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17110. try
  17111. {
  17112. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17113. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17114. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17115. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17116. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17117. }
  17118. catch (Exception ex)
  17119. {
  17120. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17121. }
  17122. }
  17123. catch (Exception ex)
  17124. {
  17125. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17126. }
  17127. try
  17128. {
  17129. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17130. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17131. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17132. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17133. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17134. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17135. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17136. //自动审核
  17137. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17138. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17139. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17140. //2024-10-21 新增LZ UID
  17141. var userIds = new List<int>() { 21 };
  17142. string title = $"系统通知";
  17143. var diId = _dto.DiId;
  17144. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17145. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17146. string content = "";
  17147. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17148. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17149. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17150. }
  17151. catch (Exception ex)
  17152. {
  17153. }
  17154. #endregion
  17155. return Ok(_view);
  17156. }
  17157. /// <summary>
  17158. /// 酒店自动审核测试
  17159. /// Add Or Edit
  17160. /// </summary>
  17161. /// <param name="diid"></param>
  17162. /// <param name="dataId"></param>
  17163. /// <returns></returns>
  17164. [HttpPost]
  17165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17166. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17167. {
  17168. #region 应用推送
  17169. try
  17170. {
  17171. //自动审核
  17172. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17173. }
  17174. catch (Exception ex)
  17175. {
  17176. return Ok(JsonView(false, ex.Message));
  17177. }
  17178. #endregion
  17179. return Ok(JsonView(false, "操作成功"));
  17180. }
  17181. /// <summary>
  17182. /// 酒店预订
  17183. /// Del
  17184. /// </summary>
  17185. /// <param name="_dto"></param>
  17186. /// <returns></returns>
  17187. [HttpPost]
  17188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17189. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17190. {
  17191. #region 参数验证
  17192. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17193. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17194. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17195. #region 团组操作权限验证 76 酒店预定模块
  17196. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17197. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17198. #endregion
  17199. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17200. #region 页面操作权限验证
  17201. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17202. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17203. #endregion
  17204. #endregion
  17205. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  17206. #region 操作记录
  17207. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17208. {
  17209. TableName = "Grp_HotelReservations",
  17210. PortType = _dto.PortType,
  17211. OperationItem = OperationEnum.Del,
  17212. DataId = _dto.Id,
  17213. CreateUserId = _dto.UserId
  17214. });
  17215. #endregion
  17216. return Ok(data);
  17217. }
  17218. /// <summary>
  17219. /// 酒店预订
  17220. /// 生成VOUCHER
  17221. /// 2024.05.06 之前版本
  17222. /// </summary>
  17223. /// <param name="_dto"></param>
  17224. /// <returns></returns>
  17225. [HttpPost]
  17226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17227. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  17228. {
  17229. try
  17230. {
  17231. #region 参数验证
  17232. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17233. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17234. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17235. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  17236. #region 团组操作权限验证 76 酒店预定模块
  17237. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17238. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17239. #endregion
  17240. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17241. #region 页面操作权限验证
  17242. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17243. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17244. #endregion
  17245. #endregion
  17246. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  17247. //判断数据是否完整
  17248. if (hr != null)
  17249. {
  17250. if (!string.IsNullOrEmpty(hr.DetermineNo))
  17251. {
  17252. string strFileName = "HotelStatement/";
  17253. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17254. if (dele != null)
  17255. strFileName += dele.TourCode;
  17256. //载入模板
  17257. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  17258. Document doc = new Document(sss);
  17259. DocumentBuilder builder = new DocumentBuilder(doc);
  17260. #region 替换Word模板书签内容
  17261. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  17262. //入住卷预定号码
  17263. if (doc.Range.Bookmarks["VNO"] != null)
  17264. {
  17265. Bookmark mark = doc.Range.Bookmarks["VNO"];
  17266. mark.Text = hr.CheckNumber;
  17267. }
  17268. //酒店时间
  17269. if (doc.Range.Bookmarks["Date"] != null)
  17270. {
  17271. Bookmark mark = doc.Range.Bookmarks["Date"];
  17272. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17273. }
  17274. //团号
  17275. if (doc.Range.Bookmarks["TNo"] != null)
  17276. {
  17277. Bookmark mark = doc.Range.Bookmarks["TNo"];
  17278. mark.Text = dele.TourCode;
  17279. }
  17280. //预定号码
  17281. if (doc.Range.Bookmarks["BookingId"] != null)
  17282. {
  17283. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  17284. mark.Text = hr.ReservationsNo;
  17285. }
  17286. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  17287. {
  17288. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  17289. mark.Text = hr.DetermineNo;
  17290. }
  17291. //酒店城市
  17292. if (doc.Range.Bookmarks["City"] != null)
  17293. {
  17294. Bookmark mark = doc.Range.Bookmarks["City"];
  17295. mark.Text = hr.City;
  17296. }
  17297. //酒店名称
  17298. if (doc.Range.Bookmarks["HName"] != null)
  17299. {
  17300. Bookmark mark = doc.Range.Bookmarks["HName"];
  17301. mark.Text = hr.HotelName;
  17302. }
  17303. //酒店地址
  17304. if (doc.Range.Bookmarks["Address"] != null)
  17305. {
  17306. Bookmark mark = doc.Range.Bookmarks["Address"];
  17307. mark.Text = hr.HotelAddress;
  17308. }
  17309. //酒店电话
  17310. if (doc.Range.Bookmarks["Tel"] != null)
  17311. {
  17312. Bookmark mark = doc.Range.Bookmarks["Tel"];
  17313. mark.Text = hr.HotelTel;
  17314. }
  17315. //酒店传真
  17316. if (doc.Range.Bookmarks["Fax"] != null)
  17317. {
  17318. Bookmark mark = doc.Range.Bookmarks["Fax"];
  17319. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17320. {
  17321. mark.Text = hr.HotelFax;
  17322. }
  17323. }
  17324. //入住时间
  17325. if (doc.Range.Bookmarks["CIn"] != null)
  17326. {
  17327. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17328. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17329. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17330. }
  17331. //退房时间
  17332. if (doc.Range.Bookmarks["COut"] != null)
  17333. {
  17334. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17335. Bookmark mark = doc.Range.Bookmarks["COut"];
  17336. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17337. }
  17338. //客户名称
  17339. if (doc.Range.Bookmarks["GName"] != null)
  17340. {
  17341. string guestName = "";
  17342. string[] clients = Array.Empty<string>();
  17343. if (hr.GuestName.Contains(","))
  17344. {
  17345. clients = hr.GuestName.Split(",");
  17346. }
  17347. else
  17348. {
  17349. clients = new string[] { hr.GuestName };
  17350. }
  17351. List<int> clientIds_int = new List<int>();
  17352. if (clients.Length > 0)
  17353. {
  17354. foreach (var item in clients)
  17355. {
  17356. if (item.IsNumeric())
  17357. {
  17358. clientIds_int.Add(int.Parse(item));
  17359. }
  17360. }
  17361. }
  17362. if (clientIds_int.Count > 0)
  17363. {
  17364. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  17365. foreach (var client in _clientDatas)
  17366. {
  17367. //男
  17368. if (client.Sex == 0) guestName += $"Mr.";
  17369. //女
  17370. else if (client.Sex == 1) guestName += $"Ms.";
  17371. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17372. {
  17373. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17374. }
  17375. //guestName += $"{client.Pinyin},";
  17376. }
  17377. if (guestName.Length > 0)
  17378. {
  17379. guestName = guestName.Substring(0, guestName.Length - 1);
  17380. }
  17381. }
  17382. else
  17383. {
  17384. guestName = hr.GuestName;
  17385. }
  17386. Bookmark mark = doc.Range.Bookmarks["GName"];
  17387. mark.Text = guestName;
  17388. }
  17389. //房间介绍
  17390. if (doc.Range.Bookmarks["ROOM"] != null)
  17391. {
  17392. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  17393. mark.Text = hr.RoomExplanation;
  17394. }
  17395. //报价描述
  17396. if (doc.Range.Bookmarks["NOTE"] != null)
  17397. {
  17398. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  17399. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  17400. if (ss != null)
  17401. mark.Text = ss.Name;
  17402. }
  17403. //入住时间
  17404. if (doc.Range.Bookmarks["CheckIn"] != null)
  17405. {
  17406. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17407. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  17408. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17409. }
  17410. //退房时间
  17411. if (doc.Range.Bookmarks["CheckOut"] != null)
  17412. {
  17413. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17414. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  17415. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17416. }
  17417. //日期
  17418. if (doc.Range.Bookmarks["DT"] != null)
  17419. {
  17420. Bookmark mark = doc.Range.Bookmarks["DT"];
  17421. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17422. }
  17423. //名称
  17424. if (doc.Range.Bookmarks["VName"] != null)
  17425. {
  17426. Bookmark mark = doc.Range.Bookmarks["VName"];
  17427. mark.Text = hr.HotelName;
  17428. }
  17429. //号码
  17430. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17431. {
  17432. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17433. mark.Text = hr.CheckNumber;
  17434. }
  17435. #endregion
  17436. strFileName += "VOUCHER.doc";
  17437. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17438. doc.Save(fileDir);
  17439. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17440. return Ok(JsonView(true, "操作成功!", Url));
  17441. }
  17442. else
  17443. {
  17444. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17445. }
  17446. }
  17447. else
  17448. {
  17449. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17450. }
  17451. }
  17452. catch (Exception ex)
  17453. {
  17454. return Ok(JsonView(false, ex.Message));
  17455. }
  17456. }
  17457. /// <summary>
  17458. /// 酒店预订
  17459. /// 生成VOUCHER
  17460. /// 2024.05.06 之后版本
  17461. /// </summary>
  17462. /// <param name="_dto"></param>
  17463. /// <returns></returns>
  17464. [HttpPost]
  17465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17466. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17467. {
  17468. #region 参数验证
  17469. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17470. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17471. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17472. #region 团组操作权限验证 76 酒店预定模块
  17473. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17474. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17475. #endregion
  17476. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17477. #region 页面操作权限验证
  17478. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17479. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17480. #endregion
  17481. #endregion
  17482. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17483. //判断数据是否完整
  17484. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17485. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17486. string strFileName = "HotelStatement/";
  17487. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17488. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17489. #region 数据处理
  17490. List<int> guestIds = new List<int>();
  17491. //int index = 0;
  17492. foreach (var item in hrDtas)
  17493. {
  17494. if (item.GuestName.Contains(","))
  17495. {
  17496. string[] guestIdArr = item.GuestName.Split(',');
  17497. foreach (var guestIdStr in guestIdArr)
  17498. {
  17499. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17500. if (guestBool)
  17501. {
  17502. guestIds.Add(guestId);
  17503. }
  17504. }
  17505. }
  17506. else guestNames += item.GuestName;
  17507. var voucherInfo = new HotelVoucherInfoView()
  17508. {
  17509. HotelName = item.HotelName,
  17510. CheckInDate = item.CheckInDate,
  17511. CheckOutDate = item.CheckOutDate,
  17512. ConfirmationNumber = item.DetermineNo.Trim(),
  17513. RoomType = item.RoomExplanation
  17514. };
  17515. vouchers.Add(voucherInfo);
  17516. }
  17517. if (guestIds.Count > 0)
  17518. {
  17519. guestIds = guestIds.Distinct().ToList();
  17520. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17521. if (guestDatas.Count > 0)
  17522. {
  17523. guestNames = "";
  17524. foreach (var guest in guestDatas)
  17525. {
  17526. string guestName = "";
  17527. if (guest.Sex == 0) guestName += @"MR.";
  17528. else if (guest.Sex == 1) guestName += @"MS.";
  17529. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17530. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17531. guestNames += @$"{guestName.Trim()}、";
  17532. }
  17533. if (guestNames.Length > 0)
  17534. {
  17535. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17536. }
  17537. }
  17538. }
  17539. #endregion
  17540. //载入模板
  17541. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17542. Document doc = new Document(sss);
  17543. DocumentBuilder builder = new DocumentBuilder(doc);
  17544. if (doc.Range.Bookmarks["GuestName"] != null)
  17545. {
  17546. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17547. mark.Text = guestNames;
  17548. }
  17549. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17550. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17551. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17552. for (int i = 1; i <= vouchers.Count; i++)
  17553. {
  17554. HotelVoucherInfoView hviv = vouchers[i - 1];
  17555. builder.MoveToCell(0, i, 0, 0);
  17556. builder.Write(hviv.HotelName);
  17557. builder.MoveToCell(0, i, 1, 0);
  17558. builder.Write(hviv.CheckInDate);
  17559. builder.MoveToCell(0, i, 2, 0);
  17560. builder.Write(hviv.CheckOutDate);
  17561. builder.MoveToCell(0, i, 3, 0);
  17562. builder.Write(hviv.RoomType);
  17563. builder.MoveToCell(0, i, 4, 0);
  17564. builder.Write(hviv.ConfirmationNumber);
  17565. }
  17566. //删除多余行
  17567. int currRowIndex = vouchers.Count + 1;
  17568. int delRows = 21 - currRowIndex;
  17569. if (delRows > 0)
  17570. {
  17571. for (int i = 0; i < delRows; i++)
  17572. {
  17573. table.Rows.RemoveAt(currRowIndex);
  17574. //cultivateRowIndex++;
  17575. }
  17576. }
  17577. strFileName += "VOUCHER.docx";
  17578. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17579. doc.Save(fileDir);
  17580. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17581. return Ok(JsonView(true, "操作成功!", Url));
  17582. }
  17583. /// <summary>
  17584. /// 酒店预订
  17585. /// 生成VOUCHER 批量生成
  17586. /// New
  17587. /// </summary>
  17588. /// <param name="_dto"></param>
  17589. /// <returns></returns>
  17590. [HttpPost]
  17591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17592. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17593. {
  17594. #region 参数验证
  17595. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17596. if (_dto.PageId < 1) _dto.PageId = 28;
  17597. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17598. #region 团组操作权限验证 76 酒店预定模块
  17599. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17600. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17601. #endregion
  17602. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17603. #region 页面操作权限验证
  17604. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17605. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17606. #endregion
  17607. #endregion
  17608. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17609. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17610. .OrderBy(x => x.CheckInDate)
  17611. .ToListAsync();
  17612. //判断数据是否完整
  17613. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17614. string strFileName = "HotelStatement/";
  17615. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17616. if (dele != null)
  17617. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17618. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17619. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17620. .Where(it => it.IsDel == 0)
  17621. .ToListAsync();
  17622. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17623. for (int i = 0; i < hrDtas.Count; i++)
  17624. {
  17625. string guestNames = string.Empty;
  17626. List<int> guestIds = new List<int>();
  17627. var item = hrDtas[i];
  17628. //处理客户姓名
  17629. if (item.GuestName.Contains(","))
  17630. {
  17631. string[] guestIdArr = item.GuestName.Split(',');
  17632. foreach (var guestIdStr in guestIdArr)
  17633. if (int.TryParse(guestIdStr, out int guestId))
  17634. guestIds.Add(guestId);
  17635. }
  17636. else
  17637. {
  17638. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17639. if (guestIdBool)
  17640. {
  17641. guestIds.Add(guestId);
  17642. }
  17643. //NaN
  17644. if (item.GuestName.Contains("NaN"))
  17645. {
  17646. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17647. }
  17648. }
  17649. if (guestIds.Count > 0)
  17650. {
  17651. guestIds = guestIds.Distinct().ToList();
  17652. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17653. if (guestDatas1.Count > 0)
  17654. {
  17655. guestNames = "";
  17656. foreach (var guest in guestDatas1)
  17657. {
  17658. string guestName = "";
  17659. if (guest.Sex == 0) guestName += @"MR.";
  17660. else if (guest.Sex == 1) guestName += @"MS.";
  17661. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17662. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17663. guestNames += @$"{guestName.Trim()}、";
  17664. }
  17665. if (guestNames.Length > 0)
  17666. {
  17667. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17668. }
  17669. }
  17670. }
  17671. //if (!string.IsNullOrEmpty(guestNames))
  17672. //{
  17673. hrDtas[i].GuestName = guestNames;
  17674. //}
  17675. }
  17676. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17677. Document doc = new Document();
  17678. DocumentBuilder builder = new DocumentBuilder(doc);
  17679. try
  17680. {
  17681. builder.MoveToDocumentStart();
  17682. foreach (var item in hrDtas)
  17683. {
  17684. //标题
  17685. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17686. builder.ParagraphFormat.LineSpacing = 1;
  17687. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17688. builder.ParagraphFormat.Style.Font.Size = 9;
  17689. builder.ParagraphFormat.Style.Font.Bold = true;
  17690. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17691. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17692. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17693. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17694. builder.ParagraphFormat.LineSpacing = 1;
  17695. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17696. builder.ParagraphFormat.Style.Font.Size = 9;
  17697. builder.ParagraphFormat.Style.Font.Bold = true;
  17698. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17699. builder.StartTable();
  17700. // 设置边框颜色
  17701. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17702. //设置边框样式
  17703. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17704. //表格
  17705. #region 第一行
  17706. builder.InsertCell();
  17707. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17708. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17709. //builder.CellFormat.AllowAutoFit = false;
  17710. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17711. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17712. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17713. builder.CellFormat.WrapText = true; //自动换行
  17714. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17715. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17716. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17717. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17718. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17719. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17720. builder.Write("TOUR NO:");
  17721. builder.InsertCell();
  17722. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17723. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17724. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17725. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17726. builder.ParagraphFormat.Style.Font.Bold = false;
  17727. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17728. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17729. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17730. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17731. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17732. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17733. builder.Write($"{dele?.TourCode ?? "-"}");
  17734. builder.InsertCell();
  17735. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17736. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17737. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17738. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17739. builder.ParagraphFormat.Style.Font.Bold = false;
  17740. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17741. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17742. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17743. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17744. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17745. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17746. builder.Write($"CITY:");
  17747. builder.InsertCell();
  17748. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17749. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17750. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17751. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17752. builder.ParagraphFormat.Style.Font.Bold = false;
  17753. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17754. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17755. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17756. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17757. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17758. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17759. builder.Write($"{item.City}");
  17760. builder.EndRow();
  17761. #endregion
  17762. #region 第二行
  17763. builder.InsertCell();
  17764. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17765. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17766. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17767. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17768. builder.ParagraphFormat.Style.Font.Bold = false;
  17769. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17770. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17771. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17772. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17773. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17774. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17775. builder.Write("CONFIRMATION NO:");
  17776. builder.InsertCell();
  17777. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17778. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17779. builder.ParagraphFormat.Style.Font.Size = 8;
  17780. builder.ParagraphFormat.Style.Font.Bold = false;
  17781. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17782. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17783. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17784. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17785. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17786. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17787. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17788. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17789. builder.Write($"{item.DetermineNo}");
  17790. builder.InsertCell();
  17791. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17792. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17793. builder.InsertCell();
  17794. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17795. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17796. builder.EndRow();
  17797. #endregion
  17798. #region 第三行
  17799. builder.InsertCell();
  17800. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17801. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17802. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17803. builder.ParagraphFormat.Style.Font.Bold = false;
  17804. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17805. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17806. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17807. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17808. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17809. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17810. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17811. builder.Write($"HOTEL NAME:");
  17812. builder.InsertCell();
  17813. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17814. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17815. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17816. builder.ParagraphFormat.Style.Font.Bold = false;
  17817. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17818. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17819. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17820. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17821. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17822. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17823. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17824. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17825. builder.Write($"{item.HotelName}");
  17826. builder.InsertCell();
  17827. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17828. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17829. builder.InsertCell();
  17830. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17831. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17832. builder.EndRow();
  17833. #endregion
  17834. #region 第四行
  17835. builder.InsertCell();
  17836. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17837. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17838. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17839. builder.ParagraphFormat.Style.Font.Bold = false;
  17840. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17841. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17842. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17843. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17844. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17845. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17846. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17847. builder.Write($"HOTEL ADDRESS:");
  17848. builder.InsertCell();
  17849. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17850. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17851. builder.ParagraphFormat.Style.Font.Size = 8;
  17852. builder.ParagraphFormat.Style.Font.Bold = false;
  17853. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17854. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17855. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17856. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17857. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17858. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17859. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17860. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17861. builder.Write($"{item.HotelAddress}");
  17862. builder.InsertCell();
  17863. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17864. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17865. builder.InsertCell();
  17866. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17867. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17868. builder.EndRow();
  17869. #endregion
  17870. #region 第五行
  17871. builder.InsertCell();
  17872. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17873. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17874. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17875. builder.ParagraphFormat.Style.Font.Bold = false;
  17876. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17877. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17878. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17879. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17880. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17881. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17882. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17883. builder.Write("TEL:");
  17884. builder.InsertCell();
  17885. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17886. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17887. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17888. builder.ParagraphFormat.Style.Font.Bold = false;
  17889. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17890. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17891. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17892. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17893. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17894. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17895. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17896. builder.Write($"{item.HotelTel}");
  17897. builder.InsertCell();
  17898. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17899. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17900. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17901. builder.ParagraphFormat.Style.Font.Bold = false;
  17902. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17903. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17904. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17905. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17906. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17907. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17908. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17909. builder.Write($"FAX:");
  17910. builder.InsertCell();
  17911. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17912. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17913. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17914. builder.ParagraphFormat.Style.Font.Bold = false;
  17915. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17916. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17917. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17918. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17919. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17920. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17921. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17922. builder.Write($"{item.HotelFax}");
  17923. builder.EndRow();
  17924. #endregion
  17925. #region 第六行
  17926. builder.InsertCell();
  17927. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17928. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17929. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17930. builder.ParagraphFormat.Style.Font.Bold = false;
  17931. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17932. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17933. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17934. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17935. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17936. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17937. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17938. builder.Write("CHECK IN:");
  17939. builder.InsertCell();
  17940. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17941. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17942. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17943. builder.ParagraphFormat.Style.Font.Bold = false;
  17944. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17945. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17946. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17947. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17948. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17949. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17950. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17951. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  17952. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17953. builder.Write($"{checkInStr}");
  17954. builder.InsertCell();
  17955. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17956. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17957. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17958. builder.ParagraphFormat.Style.Font.Bold = false;
  17959. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17960. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17961. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17962. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17963. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17964. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17965. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17966. builder.Write($"CHECK OUT:");
  17967. builder.InsertCell();
  17968. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17969. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17970. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17971. builder.ParagraphFormat.Style.Font.Bold = false;
  17972. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17973. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17974. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17975. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17976. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17977. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17978. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17979. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  17980. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  17981. builder.Write($"{checkOutStr}");
  17982. builder.EndRow();
  17983. #endregion
  17984. #region 第七行
  17985. builder.InsertCell();
  17986. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17987. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17988. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17989. builder.ParagraphFormat.Style.Font.Bold = false;
  17990. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17991. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17992. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17993. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17994. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17995. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17996. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17997. builder.Write($"GUEST NAME:");
  17998. builder.InsertCell();
  17999. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18000. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18001. builder.ParagraphFormat.Style.Font.Size = 8;
  18002. builder.ParagraphFormat.Style.Font.Bold = false;
  18003. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18004. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18005. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18006. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18007. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18008. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18009. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18010. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18011. builder.Write($"{item.GuestName.Trim()}");
  18012. builder.InsertCell();
  18013. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18014. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18015. builder.InsertCell();
  18016. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18017. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18018. builder.EndRow();
  18019. #endregion
  18020. #region 第八行
  18021. builder.InsertCell();
  18022. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18023. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18024. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18025. builder.ParagraphFormat.Style.Font.Bold = false;
  18026. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18027. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18028. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18029. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18030. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18031. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18032. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18033. builder.Write($"ROOM TYPE:");
  18034. builder.InsertCell();
  18035. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18036. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18037. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18038. builder.ParagraphFormat.Style.Font.Bold = false;
  18039. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18040. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18041. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18042. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18043. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18044. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18045. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18046. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18047. builder.Write($"{item.RoomExplanation}");
  18048. builder.InsertCell();
  18049. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18050. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18051. builder.InsertCell();
  18052. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18053. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18054. builder.EndRow();
  18055. #endregion
  18056. #region 第九行
  18057. builder.InsertCell();
  18058. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18059. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18060. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18061. builder.ParagraphFormat.Style.Font.Bold = false;
  18062. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18063. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18064. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18065. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18066. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18067. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18068. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18069. builder.Write($"NOTE:");
  18070. builder.InsertCell();
  18071. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18072. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18073. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18074. builder.ParagraphFormat.Style.Font.Bold = false;
  18075. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18076. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18077. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18078. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18079. 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.");
  18080. builder.InsertCell();
  18081. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18082. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18083. builder.InsertCell();
  18084. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18085. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18086. builder.EndRow();
  18087. #endregion
  18088. builder.EndTable();
  18089. //换行
  18090. builder.Writeln("");
  18091. builder.Writeln("");
  18092. }
  18093. #region 获取文档中的所有表格 设置文字自适应
  18094. // 获取文档中的所有表格。
  18095. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18096. {
  18097. // 遍历表格中的所有行。
  18098. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18099. {
  18100. foreach (Cell cell in row.Cells)
  18101. {
  18102. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18103. cellFormat.Width = 0;
  18104. }
  18105. }
  18106. }
  18107. #endregion
  18108. #region 设置页眉
  18109. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18110. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18111. if (System.IO.File.Exists(voucherHeaderPath))
  18112. {
  18113. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18114. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18115. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18116. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18117. // 调整图片位置
  18118. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18119. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18120. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18121. shape.Left = 0; // 将图片距离页面左边缘的距离
  18122. shape.Width = 81; // 设置图片宽度
  18123. shape.Height = 36; // 设置图片高度
  18124. }
  18125. //靠右
  18126. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18127. //// 设置页脚上下边距
  18128. //builder.PageSetup.HeaderDistance = 42;
  18129. // 添加页眉线
  18130. Aspose.Words.Border borderHeader = null;
  18131. try
  18132. {
  18133. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18134. }
  18135. catch (Exception e)
  18136. {
  18137. // TODO Auto-generated catch block
  18138. //e.printStackTrace();
  18139. }
  18140. borderHeader.Shadow = true;
  18141. borderHeader.DistanceFromText = 2;
  18142. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18143. #endregion
  18144. }
  18145. catch (Exception ex)
  18146. {
  18147. }
  18148. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18149. doc.Save(fileDir);
  18150. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18151. return Ok(JsonView(true, "操作成功!", Url));
  18152. }
  18153. /// <summary>
  18154. /// 酒店预订
  18155. /// 生成 预定成本 Excel
  18156. /// </summary>
  18157. /// <param name="_dto"></param>
  18158. /// <returns></returns>
  18159. [HttpPost]
  18160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18161. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18162. {
  18163. #region 参数验证
  18164. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18165. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18166. if (!vadalitorRes.IsValid)
  18167. {
  18168. var errors = new StringBuilder();
  18169. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18170. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18171. }
  18172. #region 团组操作权限验证 76 酒店预定模块
  18173. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18174. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18175. #endregion
  18176. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18177. #region 页面操作权限验证
  18178. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18179. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18180. #endregion
  18181. #endregion
  18182. decimal _rate = 1.00M;
  18183. string _currency = string.Empty;
  18184. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18185. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18186. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18187. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18188. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18189. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18190. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18191. if (_GroupCostParameter == null)
  18192. {
  18193. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18194. bool isIntType = int.TryParse(_currency, out int currId);
  18195. if (isIntType)
  18196. {
  18197. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18198. }
  18199. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18200. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18201. if (currInfo == null)
  18202. {
  18203. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18204. }
  18205. else _rate = currInfo.Rate;
  18206. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18207. {
  18208. _rate = _GroupCostParameter.Rate;
  18209. }
  18210. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18211. //string strFileName = "HotelStatement/";
  18212. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18213. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18214. var rateDatas = new List<dynamic>();
  18215. #region 数据处理
  18216. foreach (var item in hrDtas)
  18217. {
  18218. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18219. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18220. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18221. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18222. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18223. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  18224. {
  18225. continue;
  18226. }
  18227. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18228. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  18229. string singleRoomFeeStr = string.Empty,
  18230. doubleRoomFeeStr = string.Empty,
  18231. suiteRoomFeeStr = string.Empty,
  18232. otherRoomFeeStr = string.Empty,
  18233. payMoneyStr = string.Empty,
  18234. cardPriceStr = string.Empty;
  18235. if (roomCurr.Equals("CNY"))
  18236. {
  18237. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  18238. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18239. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18240. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18241. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18242. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  18243. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  18244. }
  18245. else
  18246. {
  18247. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18248. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18249. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18250. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18251. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18252. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18253. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18254. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18255. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18256. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18257. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  18258. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  18259. if (ccpPaymentCurrency.Equals("CNY"))
  18260. {
  18261. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  18262. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18263. }
  18264. else
  18265. {
  18266. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  18267. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  18268. }
  18269. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  18270. if (hotelcardPriceCurrency.Equals("CNY"))
  18271. {
  18272. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18273. }
  18274. else
  18275. {
  18276. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  18277. }
  18278. }
  18279. string breakfastPriceStr = string.Empty,
  18280. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18281. governmentRentStr = string.Empty,
  18282. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18283. cityTaxStr = string.Empty,
  18284. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18285. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  18286. if (!string.IsNullOrEmpty(breakfastCurrency1))
  18287. {
  18288. if (breakfastCurrency1.Equals("CNY"))
  18289. {
  18290. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18291. }
  18292. else
  18293. {
  18294. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  18295. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  18296. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  18297. }
  18298. }
  18299. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18300. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  18301. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  18302. {
  18303. if (governmentRentCurrency.Equals("CNY"))
  18304. {
  18305. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18306. }
  18307. else
  18308. {
  18309. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  18310. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  18311. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  18312. }
  18313. }
  18314. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18315. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  18316. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  18317. {
  18318. if (cityTaxStrCurrency1.Equals("CNY"))
  18319. {
  18320. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18321. }
  18322. else
  18323. {
  18324. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18325. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18326. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18327. }
  18328. }
  18329. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18330. int payDId = roomInfo?.PayDId ?? 0;
  18331. pcfds.Add(new HotelReservations_PCFD_View()
  18332. {
  18333. City = item.City,
  18334. HotelName = item.HotelName,
  18335. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18336. // SingleRoomCount = item.SingleRoomCount,
  18337. SingleRoomPrice = singleRoomFeeStr,
  18338. // DoubleRoomCount = item.DoubleRoomCount,
  18339. DoubleRoomPrice = doubleRoomFeeStr,
  18340. //SuiteRoomCount = item.SuiteRoomCount,
  18341. SuiteRoomPrice = suiteRoomFeeStr,
  18342. OtherRoomPrice = otherRoomFeeStr,
  18343. //OtherRoomCount = item.OtherRoomCount,
  18344. BreakfastPrice = breakfastPriceStr,
  18345. GovernmentRent = governmentRentStr,
  18346. CityTax = cityTaxStr,
  18347. RoomExplanation = item.RoomExplanation,
  18348. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18349. PayTime = roomInfo?.ConsumptionDate,
  18350. BankNo = roomInfo?.BankNo,
  18351. PayMoney = payMoneyStr,
  18352. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18353. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18354. CardPrice = cardPriceStr,
  18355. Remark = ccpInfo.Remark
  18356. });
  18357. }
  18358. #endregion
  18359. //载入模板
  18360. WorkbookDesigner designer = new WorkbookDesigner();
  18361. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18362. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18363. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18364. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18365. var rateDatas1 = rateDatas.Distinct();
  18366. var rateStr = string.Empty;
  18367. foreach (var item in rateDatas1)
  18368. {
  18369. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18370. }
  18371. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18372. designer.SetDataSource("Opertor", userInfo.CnName);
  18373. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18374. dt.TableName = "ViewMyHotelReservations";
  18375. designer.SetDataSource(dt);
  18376. designer.Process();
  18377. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18378. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18379. designer.Workbook.Save(serverPath);
  18380. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18381. #region 删除指定行
  18382. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18383. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18384. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18385. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18386. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18387. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18388. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18389. cssIndex = dt.Columns["CityTax"].Ordinal,
  18390. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18391. remarkIndex = dt.Columns["Remark"].Ordinal;
  18392. //删除指定列
  18393. foreach (DataRow item in dt.Rows)
  18394. {
  18395. string singleStr = item["SingleRoomPrice"].ToString();
  18396. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18397. if (containsDigitButNotZero1) singleDel = false;
  18398. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18399. string doubleStr = item["DoubleRoomPrice"].ToString();
  18400. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18401. if (containsDigitButNotZero2) doubleDel = false;
  18402. string suiteStr = item["SuiteRoomPrice"].ToString();
  18403. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18404. if (containsDigitButNotZero3) suiteDel = false;
  18405. string otherStr = item["OtherRoomPrice"].ToString();
  18406. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18407. if (containsDigitButNotZero4) otherDel = false;
  18408. string zcStr = item["BreakfastPrice"].ToString();
  18409. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18410. if (containsDigitButNotZero5) zcDel = false;
  18411. string dsStr = item["GovernmentRent"].ToString();
  18412. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18413. if (containsDigitButNotZero6) dsDel = false;
  18414. string cssStr = item["CityTax"].ToString();
  18415. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18416. if (containsDigitButNotZero7) cssDel = false;
  18417. string cpStr = item["ConsumptionPatterns"].ToString();
  18418. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18419. string remarkStr = item["Remark"].ToString();
  18420. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18421. }
  18422. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18423. DeleteColumn(serverPath, cpIndex, cpDel);
  18424. DeleteColumn(serverPath, dsIndex, dsDel);
  18425. DeleteColumn(serverPath, cssIndex, cssDel);
  18426. DeleteColumn(serverPath, zcIndex, zcDel);
  18427. DeleteColumn(serverPath, otherIndex, otherDel);
  18428. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18429. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18430. DeleteColumn(serverPath, singleIndex, singleDel);
  18431. #endregion
  18432. //只保留第一个表格
  18433. DeleteSheet(serverPath);
  18434. return Ok(JsonView(true, "操作成功", url = rst));
  18435. }
  18436. else
  18437. {
  18438. _currency = _GroupCostParameter.Currency;
  18439. bool isIntType = int.TryParse(_currency, out int currId);
  18440. if (isIntType)
  18441. {
  18442. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18443. }
  18444. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18445. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18446. if (currInfo == null)
  18447. {
  18448. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18449. }
  18450. if (!_currency.ToUpper().Equals("CNY"))
  18451. {
  18452. _rate = _GroupCostParameter.Rate;
  18453. }
  18454. _rate = currInfo.Rate;
  18455. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18456. //string strFileName = "HotelStatement/";
  18457. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18458. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18459. #region 数据处理
  18460. foreach (var item in hrDtas)
  18461. {
  18462. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18463. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18464. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18465. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18466. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18467. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18468. string singleRoomFeeStr = string.Empty,
  18469. doubleRoomFeeStr = string.Empty,
  18470. suiteRoomFeeStr = string.Empty,
  18471. otherRoomFeeStr = string.Empty,
  18472. payMoneyStr = string.Empty,
  18473. cardPriceStr = string.Empty;
  18474. if (roomCurr.Equals(_currency))
  18475. {
  18476. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18477. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18478. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18479. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18480. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18481. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18482. }
  18483. else
  18484. {
  18485. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18486. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18487. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18488. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18489. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18490. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18491. }
  18492. string breakfastPriceStr = string.Empty,
  18493. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18494. governmentRentStr = string.Empty,
  18495. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18496. cityTaxStrStr = string.Empty,
  18497. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18498. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18499. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18500. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18501. int payDId = roomInfo?.PayDId ?? 0;
  18502. pcfds.Add(new HotelReservations_PCFD_View()
  18503. {
  18504. City = item.City,
  18505. HotelName = item.HotelName,
  18506. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18507. // SingleRoomCount = item.SingleRoomCount,
  18508. SingleRoomPrice = singleRoomFeeStr,
  18509. // DoubleRoomCount = item.DoubleRoomCount,
  18510. DoubleRoomPrice = doubleRoomFeeStr,
  18511. //SuiteRoomCount = item.SuiteRoomCount,
  18512. SuiteRoomPrice = suiteRoomFeeStr,
  18513. OtherRoomPrice = otherRoomFeeStr,
  18514. //OtherRoomCount = item.OtherRoomCount,
  18515. BreakfastPrice = breakfastPriceStr,
  18516. GovernmentRent = governmentRentStr,
  18517. CityTax = cityTaxStrStr,
  18518. RoomExplanation = item.RoomExplanation,
  18519. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18520. PayTime = roomInfo?.ConsumptionDate,
  18521. BankNo = roomInfo?.BankNo,
  18522. PayMoney = payMoneyStr,
  18523. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18524. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18525. CardPrice = cardPriceStr,
  18526. Remark = ccpInfo.Remark
  18527. });
  18528. }
  18529. #endregion
  18530. //载入模板
  18531. WorkbookDesigner designer = new WorkbookDesigner();
  18532. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18533. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18534. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18535. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18536. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18537. designer.SetDataSource("Opertor", userInfo.CnName);
  18538. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18539. dt.TableName = "ViewMyHotelReservations";
  18540. designer.SetDataSource(dt);
  18541. designer.Process();
  18542. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18543. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18544. designer.Workbook.Save(serverPath);
  18545. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18546. #region 删除指定行
  18547. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18548. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18549. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18550. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18551. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18552. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18553. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18554. cssIndex = dt.Columns["CityTax"].Ordinal,
  18555. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18556. remarkIndex = dt.Columns["Remark"].Ordinal;
  18557. //删除指定列
  18558. foreach (DataRow item in dt.Rows)
  18559. {
  18560. string singleStr = item["SingleRoomPrice"].ToString();
  18561. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18562. if (containsDigitButNotZero1) singleDel = false;
  18563. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18564. string doubleStr = item["DoubleRoomPrice"].ToString();
  18565. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18566. if (containsDigitButNotZero2) doubleDel = false;
  18567. string suiteStr = item["SuiteRoomPrice"].ToString();
  18568. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18569. if (containsDigitButNotZero3) suiteDel = false;
  18570. string otherStr = item["OtherRoomPrice"].ToString();
  18571. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18572. if (containsDigitButNotZero4) otherDel = false;
  18573. string zcStr = item["BreakfastPrice"].ToString();
  18574. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18575. if (containsDigitButNotZero5) zcDel = false;
  18576. string dsStr = item["GovernmentRent"].ToString();
  18577. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18578. if (containsDigitButNotZero6) dsDel = false;
  18579. string cssStr = item["CityTax"].ToString();
  18580. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18581. if (containsDigitButNotZero7) cssDel = false;
  18582. string cpStr = item["ConsumptionPatterns"].ToString();
  18583. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18584. string remarkStr = item["Remark"].ToString();
  18585. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18586. }
  18587. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18588. DeleteColumn(serverPath, cpIndex, cpDel);
  18589. DeleteColumn(serverPath, dsIndex, dsDel);
  18590. DeleteColumn(serverPath, cssIndex, cssDel);
  18591. DeleteColumn(serverPath, zcIndex, zcDel);
  18592. DeleteColumn(serverPath, otherIndex, otherDel);
  18593. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18594. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18595. DeleteColumn(serverPath, singleIndex, singleDel);
  18596. #endregion
  18597. //只保留第一个表格
  18598. DeleteSheet(serverPath);
  18599. return Ok(JsonView(true, "操作成功", url = rst));
  18600. }
  18601. //return Ok(JsonView(false));
  18602. }
  18603. /// <summary>
  18604. /// 删除指定列
  18605. /// </summary>
  18606. /// <param name="file"></param>
  18607. /// <param name="columnIndex"></param>
  18608. /// <param name="isDel"></param>
  18609. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18610. {
  18611. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18612. //wb.Save(file);
  18613. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18614. if (sheet1 != null)
  18615. {
  18616. if (isDel)
  18617. {
  18618. Cells cells = sheet1.Cells;
  18619. cells.DeleteColumn(columnIndex);
  18620. }
  18621. }
  18622. wb.Save(file);
  18623. }
  18624. /// <summary>
  18625. /// 删除sheet
  18626. /// </summary>
  18627. /// <param name="file"></param>
  18628. private void DeleteSheet(string file)
  18629. {
  18630. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18631. //wb.Save(file);
  18632. List<string> sheets = new List<string>();
  18633. foreach (var item in wb.Worksheets)
  18634. {
  18635. sheets.Add(item.Name);
  18636. }
  18637. if (sheets.Count > 0)
  18638. {
  18639. sheets.RemoveAt(0);//不删除第一个sheet
  18640. foreach (var item in sheets)
  18641. {
  18642. wb.Worksheets.RemoveAt(item);
  18643. }
  18644. }
  18645. wb.Save(file);
  18646. }
  18647. /// <summary>
  18648. /// 酒店预订
  18649. /// 确认单
  18650. /// </summary>
  18651. /// <param name="_dto"></param>
  18652. /// <returns></returns>
  18653. [HttpPost]
  18654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18655. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18656. {
  18657. try
  18658. {
  18659. #region 参数验证
  18660. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18661. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18662. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18663. #region 团组操作权限验证 76 酒店预定模块
  18664. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18665. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18666. #endregion
  18667. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18668. #region 页面操作权限验证
  18669. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18670. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18671. #endregion
  18672. #endregion
  18673. //团组信息
  18674. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18675. //酒店数据
  18676. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18677. if (listhoteldata.Count < 0)
  18678. {
  18679. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18680. }
  18681. //利datatable存储
  18682. DataTable dt = new DataTable();
  18683. dt.Columns.Add("CheckInDate", typeof(string));
  18684. dt.Columns.Add("City", typeof(string));
  18685. dt.Columns.Add("Hotel", typeof(string));
  18686. dt.Columns.Add("Room", typeof(string));
  18687. for (int i = 0; i < listhoteldata.Count; i++)
  18688. {
  18689. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18690. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18691. while (dayStart < dayEnd)
  18692. {
  18693. string temp = "";
  18694. DataRow row = dt.NewRow();
  18695. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18696. row["City"] = listhoteldata[i].City;
  18697. row["Hotel"] = listhoteldata[i].HotelName;
  18698. if (listhoteldata[i].SingleRoomCount > 0)
  18699. {
  18700. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18701. }
  18702. if (listhoteldata[i].DoubleRoomCount > 0)
  18703. {
  18704. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18705. }
  18706. if (listhoteldata[i].SuiteRoomCount > 0)
  18707. {
  18708. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18709. }
  18710. if (listhoteldata[i].OtherRoomCount > 0)
  18711. {
  18712. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18713. }
  18714. row["Room"] = temp;
  18715. dt.Rows.Add(row);
  18716. dayStart = dayStart.AddDays(1);
  18717. }
  18718. }
  18719. Dictionary<string, string> dic = new Dictionary<string, string>();
  18720. dic.Add("Dele", di.TeamName);
  18721. dic.Add("City", di.VisitCountry);
  18722. //模板路径
  18723. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18724. //载入模板
  18725. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18726. DocumentBuilder builder = new DocumentBuilder(doc);
  18727. foreach (var key in dic.Keys)
  18728. {
  18729. builder.MoveToBookmark(key);
  18730. builder.Write(dic[key]);
  18731. }
  18732. //获取word里所有表格
  18733. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18734. //获取所填表格的序数
  18735. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18736. var rowStart = tableOne.Rows[0]; //获取第1行
  18737. //循环赋值
  18738. for (int i = 0; i < dt.Rows.Count; i++)
  18739. {
  18740. builder.MoveToCell(0, i + 1, 0, 0);
  18741. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18742. builder.MoveToCell(0, i + 1, 1, 0);
  18743. builder.Write(dt.Rows[i]["City"].ToString());
  18744. builder.MoveToCell(0, i + 1, 2, 0);
  18745. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18746. builder.MoveToCell(0, i + 1, 3, 0);
  18747. builder.Write(dt.Rows[i]["Room"].ToString());
  18748. }
  18749. //删除多余行
  18750. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18751. {
  18752. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18753. }
  18754. string strFileName = di.TeamName + "酒店确认单.doc";
  18755. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18756. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18757. return Ok(JsonView(true, "成功", url));
  18758. }
  18759. catch (Exception ex)
  18760. {
  18761. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18762. }
  18763. }
  18764. #endregion
  18765. #region 团组状态
  18766. /// <summary>
  18767. /// 团组状态列表 Page
  18768. /// </summary>
  18769. /// <param name="dto">团组列表请求dto</param>
  18770. /// <returns></returns>
  18771. [HttpPost]
  18772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18773. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18774. {
  18775. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18776. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18777. {
  18778. string sqlWhere = string.Empty;
  18779. if (dto.IsSure == 0) //未完成
  18780. {
  18781. sqlWhere += string.Format(@" And IsSure = 0");
  18782. }
  18783. else if (dto.IsSure == 1) //已完成
  18784. {
  18785. sqlWhere += string.Format(@" And IsSure = 1");
  18786. }
  18787. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18788. {
  18789. string tj = dto.SearchCriteria;
  18790. 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}%')",
  18791. tj, tj, tj, tj, tj);
  18792. }
  18793. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  18794. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  18795. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  18796. From (
  18797. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  18798. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  18799. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  18800. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  18801. From Grp_DelegationInfo gdi
  18802. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  18803. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  18804. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  18805. Where gdi.IsDel = 0 {0}
  18806. ) temp ", sqlWhere);
  18807. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  18808. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  18809. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  18810. }
  18811. else
  18812. {
  18813. return Ok(JsonView(false, "查询失败"));
  18814. }
  18815. }
  18816. /// <summary>
  18817. /// 团组状态
  18818. /// 设置操作完成
  18819. /// </summary>
  18820. /// <param name="dto">团组列表请求dto</param>
  18821. /// <returns></returns>
  18822. [HttpPost]
  18823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18824. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  18825. {
  18826. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18827. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  18828. {
  18829. Id = dto.Id,
  18830. IsSure = 1
  18831. };
  18832. var result = await _sqlSugar.Updateable(_DelegationInfo)
  18833. .UpdateColumns(it => new { it.IsSure })
  18834. .WhereColumns(it => new { it.Id })
  18835. .ExecuteCommandAsync();
  18836. if (result > 0)
  18837. {
  18838. return Ok(JsonView(true, "操作完成!"));
  18839. }
  18840. return Ok(JsonView(false, "操作失败!"));
  18841. }
  18842. #endregion
  18843. #region 保险费用录入
  18844. /// <summary>
  18845. /// 根据团组Id查询保险费用列表
  18846. /// </summary>
  18847. /// <param name="dto"></param>
  18848. /// <returns></returns>
  18849. [HttpPost]
  18850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18851. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  18852. {
  18853. Result groupData = await _customersRep.CustomersByDiId(dto);
  18854. if (groupData.Code != 0)
  18855. {
  18856. return Ok(JsonView(false, groupData.Msg));
  18857. }
  18858. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18859. }
  18860. /// <summary>
  18861. /// 根据保险费用Id查询保险费用详细
  18862. /// </summary>
  18863. /// <param name="dto"></param>
  18864. /// <returns></returns>
  18865. [HttpPost]
  18866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18867. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  18868. {
  18869. try
  18870. {
  18871. Result groupData = await _customersRep.CustomersById(dto);
  18872. if (groupData.Code != 0)
  18873. {
  18874. return Ok(JsonView(false, groupData.Msg));
  18875. }
  18876. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18877. }
  18878. catch (Exception ex)
  18879. {
  18880. return Ok(JsonView(false, ex.Message));
  18881. }
  18882. }
  18883. /// <summary>
  18884. /// 保险费用录入页面初始化绑定
  18885. /// </summary>
  18886. /// <param name="dto"></param>
  18887. /// <returns></returns>
  18888. [HttpPost]
  18889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18890. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  18891. {
  18892. try
  18893. {
  18894. Result groupData = await _customersRep.CustomersInitialize(dto);
  18895. if (groupData.Code != 0)
  18896. {
  18897. return Ok(JsonView(false, groupData.Msg));
  18898. }
  18899. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18900. }
  18901. catch (Exception ex)
  18902. {
  18903. return Ok(JsonView(false, ex.Message));
  18904. }
  18905. }
  18906. /// <summary>
  18907. /// 保险费用操作(Status:1.新增,2.修改)
  18908. /// </summary>
  18909. /// <param name="dto"></param>
  18910. /// <returns></returns>
  18911. [HttpPost]
  18912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18913. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  18914. {
  18915. Result groupData = await _customersRep.OpCustomers(dto);
  18916. if (groupData.Code != 0)
  18917. {
  18918. return Ok(JsonView(false, groupData.Msg));
  18919. }
  18920. #region 应用推送
  18921. try
  18922. {
  18923. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  18924. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  18925. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  18926. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18927. //自动审核
  18928. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  18929. //2024-10-21 新增LZ UID
  18930. var userIds = new List<int>() { 21 };
  18931. string title = $"系统通知";
  18932. var diId = dto.DiId;
  18933. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18934. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18935. string content = "";
  18936. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18937. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18938. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18939. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  18940. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  18941. }
  18942. catch (Exception ex)
  18943. {
  18944. }
  18945. #endregion
  18946. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18947. }
  18948. /// <summary>
  18949. /// 保险文件上传
  18950. /// </summary>
  18951. /// <param name="file"></param>
  18952. /// <returns></returns>
  18953. [HttpPost]
  18954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18955. public async Task<IActionResult> UploadCus(IFormFile file)
  18956. {
  18957. try
  18958. {
  18959. if (file != null)
  18960. {
  18961. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18962. //文件名称
  18963. string projectFileName = file.FileName;
  18964. //上传的文件的路径
  18965. string filePath = "";
  18966. if (!Directory.Exists(fileDir))
  18967. {
  18968. Directory.CreateDirectory(fileDir);
  18969. }
  18970. //上传的文件的路径
  18971. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  18972. using (FileStream fs = System.IO.File.Create(filePath))
  18973. {
  18974. file.CopyTo(fs);
  18975. fs.Flush();
  18976. }
  18977. return Ok(JsonView(true, "上传成功!", projectFileName));
  18978. }
  18979. else
  18980. {
  18981. return Ok(JsonView(false, "上传失败!"));
  18982. }
  18983. }
  18984. catch (Exception ex)
  18985. {
  18986. return Ok(JsonView(false, ex.Message));
  18987. }
  18988. }
  18989. /// <summary>
  18990. /// 保险删除指定文件
  18991. /// </summary>
  18992. /// <param name="dto"></param>
  18993. /// <returns></returns>
  18994. [HttpPost]
  18995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18996. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  18997. {
  18998. try
  18999. {
  19000. string filePath = "";
  19001. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19002. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19003. //int id = 0;
  19004. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19005. // 删除该文件
  19006. try
  19007. {
  19008. System.IO.File.Delete(filePath);
  19009. 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()
  19010. {
  19011. Attachment = "",
  19012. }).ExecuteCommandAsync();
  19013. if (result != 0)
  19014. {
  19015. return Ok(JsonView(true, "成功!"));
  19016. }
  19017. else
  19018. {
  19019. return Ok(JsonView(false, "失败!"));
  19020. }
  19021. }
  19022. catch (Exception)
  19023. {
  19024. 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()
  19025. {
  19026. Attachment = "",
  19027. }).ExecuteCommandAsync();
  19028. if (result != 0)
  19029. {
  19030. return Ok(JsonView(true, "成功!"));
  19031. }
  19032. else
  19033. {
  19034. return Ok(JsonView(false, "失败!"));
  19035. }
  19036. }
  19037. }
  19038. catch (Exception ex)
  19039. {
  19040. return Ok(JsonView(false, "程序错误!"));
  19041. throw;
  19042. }
  19043. }
  19044. /// <summary>
  19045. /// 保险费用操作(删除)
  19046. /// </summary>
  19047. /// <param name="dto"></param>
  19048. /// <returns></returns>
  19049. [HttpPost]
  19050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19051. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19052. {
  19053. try
  19054. {
  19055. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19056. if (!res)
  19057. {
  19058. return Ok(JsonView(false, "删除失败"));
  19059. }
  19060. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19061. {
  19062. IsDel = 1,
  19063. DeleteUserId = dto.DeleteUserId,
  19064. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19065. }).ExecuteCommandAsync();
  19066. return Ok(JsonView(true, "删除成功!"));
  19067. }
  19068. catch (Exception ex)
  19069. {
  19070. return Ok(JsonView(false, "程序错误!"));
  19071. throw;
  19072. }
  19073. }
  19074. #endregion
  19075. #region 接团客户名单 PageId 104
  19076. /// <summary>
  19077. /// 接团客户名单
  19078. /// 迁移数据(慎用!)
  19079. /// </summary>
  19080. /// <returns></returns>
  19081. [HttpPost]
  19082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19083. public async Task<IActionResult> PostTourClientListChange()
  19084. {
  19085. try
  19086. {
  19087. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19088. //var groupClinetData1
  19089. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19090. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19091. int updateCount = 0;
  19092. if (oldOAClientList.Count > 0)
  19093. {
  19094. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19095. _sqlSugar.BeginTran();
  19096. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19097. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19098. foreach (var item in oldOAClientList)
  19099. {
  19100. int comId = 0;
  19101. string format = "yyyy-MM-dd HH:mm:ss";
  19102. string data11 = "1990-01-01 00:00";
  19103. var data1 = IsValidDate(item.OPdate, format);
  19104. if (data1) data11 = item.OPdate;
  19105. //客户公司验证
  19106. if (!string.IsNullOrEmpty(item.Company))
  19107. {
  19108. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19109. if (clientComInfo == null) // add
  19110. {
  19111. var addInfo = new Crm_CustomerCompany()
  19112. {
  19113. CompanyAbbreviation = "",
  19114. CompanyFullName = item.Company,
  19115. Address = "",
  19116. PostCodes = "",
  19117. LastedOpUserId = item.OPer,
  19118. LastedOpDt = Convert.ToDateTime(data11),
  19119. CreateUserId = item.OPer,
  19120. CreateTime = Convert.ToDateTime(data11),
  19121. IsDel = 0
  19122. };
  19123. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19124. if (comId1 > 0) comId = comId1;
  19125. }
  19126. else comId = clientComInfo.Id;
  19127. }
  19128. //客户人员验证
  19129. int clientId = 0;
  19130. string name = item.LastName + item.Name;
  19131. if (!string.IsNullOrEmpty(name))
  19132. {
  19133. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19134. if (clientInfo == null)
  19135. {
  19136. DateTime? dateTime = null;
  19137. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19138. if (isDt) dateTime = birthDayDt;
  19139. var addInfo1 = new Crm_DeleClient()
  19140. {
  19141. CrmCompanyId = comId,
  19142. DiId = -1,
  19143. LastName = item.LastName,
  19144. FirstName = item.Name,
  19145. OldName = "",
  19146. Pinyin = item.Pinyin,
  19147. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19148. Marriage = 0,
  19149. Phone = item.Phone,
  19150. Job = item.Job,
  19151. BirthDay = dateTime
  19152. };
  19153. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19154. if (clientId1 > 0) clientId = clientId1;
  19155. }
  19156. else clientId = clientInfo.Id;
  19157. }
  19158. if (clientId < 1)
  19159. {
  19160. continue;
  19161. }
  19162. int airType = 0;
  19163. if (item.AirType == "超经舱") airType = 459;
  19164. else if (item.AirType == "公务舱") airType = 458;
  19165. else if (item.AirType == "经济舱") airType = 460;
  19166. else if (item.AirType == "其他") airType = 565;
  19167. else if (item.AirType == "头等舱") airType = 457;
  19168. var _TourClientListEntity = new Grp_TourClientList()
  19169. {
  19170. DiId = item.Diid,
  19171. ClientId = clientId,
  19172. CreateUserId = item.OPer,
  19173. CreateTime = Convert.ToDateTime(data11),
  19174. Remark = item.Remark,
  19175. IsDel = item.Isdel,
  19176. ShippingSpaceTypeId = airType,
  19177. ShippingSpaceSpecialNeeds = item.AirRemark,
  19178. HotelSpecialNeeds = item.RoomType
  19179. };
  19180. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19181. if (_TourClientList > 0)
  19182. {
  19183. updateCount++;
  19184. }
  19185. }
  19186. _sqlSugar.CommitTran();
  19187. }
  19188. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19189. }
  19190. catch (Exception ex)
  19191. {
  19192. _sqlSugar.RollbackTran();
  19193. return Ok(JsonView(false, ex.Message));
  19194. }
  19195. //return Ok(JsonView(true));
  19196. }
  19197. private bool IsValidDate(string dateString, string format)
  19198. {
  19199. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  19200. }
  19201. /// <summary>
  19202. /// 接团客户名单
  19203. /// 根据团组Id查询List
  19204. /// </summary>
  19205. /// <param name="_dto"></param>
  19206. /// <returns></returns>
  19207. [HttpPost]
  19208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19209. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  19210. {
  19211. #region 参数验证
  19212. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  19213. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  19214. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  19215. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19216. #region 页面操作权限验证
  19217. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19218. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19219. #endregion
  19220. #endregion
  19221. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  19222. if (viewData.Code != 0)
  19223. {
  19224. return Ok(JsonView(false, viewData.Msg));
  19225. }
  19226. return Ok(JsonView(viewData.Data));
  19227. }
  19228. /// <summary>
  19229. /// 接团客户名单
  19230. /// 基础数据 Init
  19231. /// </summary>
  19232. /// <param name="_dto"></param>
  19233. /// <returns></returns>
  19234. [HttpPost]
  19235. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19236. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  19237. {
  19238. #region 参数验证
  19239. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19240. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19241. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19242. #region 页面操作权限验证
  19243. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19244. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19245. #endregion
  19246. #endregion
  19247. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  19248. }
  19249. /// <summary>
  19250. /// 接团客户名单
  19251. /// 根据 Id查询 Details
  19252. /// </summary>
  19253. /// <param name="_dto"></param>
  19254. /// <returns></returns>
  19255. [HttpPost]
  19256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19257. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  19258. {
  19259. #region 参数验证
  19260. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19261. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19262. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19263. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19264. #region 页面操作权限验证
  19265. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19266. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19267. #endregion
  19268. #endregion
  19269. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  19270. if (viewData.Code != 0)
  19271. {
  19272. return Ok(JsonView(false, viewData.Msg));
  19273. }
  19274. return Ok(JsonView(viewData.Data));
  19275. }
  19276. /// <summary>
  19277. /// 接团客户名单
  19278. /// Add Or Edit
  19279. /// </summary>
  19280. /// <param name="_dto"></param>
  19281. /// <returns></returns>
  19282. [HttpPost]
  19283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19284. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  19285. {
  19286. #region 参数验证
  19287. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19288. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19289. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19290. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19291. #region 页面操作权限验证
  19292. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19293. if (_dto.Id == 0) //添加
  19294. {
  19295. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19296. }
  19297. else if (_dto.Id >= 0) //修改
  19298. {
  19299. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  19300. }
  19301. #endregion
  19302. #endregion
  19303. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  19304. if (viewData.Code != 0)
  19305. {
  19306. return Ok(JsonView(false, viewData.Msg));
  19307. }
  19308. return Ok(JsonView(true));
  19309. }
  19310. /// <summary>
  19311. /// 接团客户名单
  19312. /// json字符串 AddMultiple(添加多个)
  19313. /// </summary>
  19314. /// <param name="_dto"></param>
  19315. /// <returns></returns>
  19316. [HttpPost]
  19317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19318. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19319. {
  19320. #region 参数验证
  19321. string jsonLabel = _dto.JsonLabel;
  19322. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19323. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19324. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19325. #region 页面操作权限验证
  19326. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19327. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19328. #endregion
  19329. #endregion
  19330. var request = new TourClientListAddMultipleDto();
  19331. request.DiId = _dto.DiId;
  19332. request.UserId = _dto.UserId;
  19333. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19334. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19335. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19336. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19337. var infos = new List<TourClientListInfo>();
  19338. foreach (var data in datas)
  19339. {
  19340. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19341. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19342. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19343. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19344. {
  19345. continue;
  19346. }
  19347. infos.Add(new TourClientListInfo()
  19348. {
  19349. IsAccompany = 1,
  19350. LastName = lastName,
  19351. FirstName = firstName,
  19352. Pinyin = lastNameEn + @"/" + firstNameEn,
  19353. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  19354. CompanyFullName = data.CompanyFullName,
  19355. Job = data.Job
  19356. });
  19357. }
  19358. if (infos.Any())
  19359. {
  19360. var viewData = await _tourClientListRep._AddMultiple(request);
  19361. if (viewData.Code != 0)
  19362. {
  19363. return Ok(JsonView(false, viewData.Msg));
  19364. }
  19365. return Ok(JsonView(true));
  19366. }
  19367. return Ok(JsonView(false));
  19368. }
  19369. /// <summary>
  19370. /// 接团客户名单
  19371. /// AddMultiple(添加多个)
  19372. /// </summary>
  19373. /// <param name="_dto"></param>
  19374. /// <returns></returns>
  19375. [HttpPost]
  19376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19377. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19378. {
  19379. #region 参数验证
  19380. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19381. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19382. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19383. #region 页面操作权限验证
  19384. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19385. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19386. #endregion
  19387. #endregion
  19388. var viewData = await _tourClientListRep._AddMultiple(_dto);
  19389. if (viewData.Code != 0)
  19390. {
  19391. return Ok(JsonView(false, viewData.Msg));
  19392. }
  19393. return Ok(JsonView(true));
  19394. }
  19395. /// <summary>
  19396. /// 接团客户名单
  19397. /// Del
  19398. /// </summary>
  19399. /// <param name="_dto"></param>
  19400. /// <returns></returns>
  19401. [HttpPost]
  19402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19403. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  19404. {
  19405. #region 参数验证
  19406. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19407. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19408. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19409. #region 页面操作权限验证
  19410. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19411. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19412. #endregion
  19413. #endregion
  19414. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19415. if (viewData.Code != 0)
  19416. {
  19417. return Ok(JsonView(false, viewData.Msg));
  19418. }
  19419. return Ok(JsonView(true));
  19420. }
  19421. /// <summary>
  19422. /// 接团客户名单
  19423. /// 文件下载 客户名单
  19424. /// </summary>
  19425. /// <param name="_dto"></param>
  19426. /// <returns></returns>
  19427. [HttpPost]
  19428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19429. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19430. {
  19431. #region 参数验证
  19432. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19433. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19434. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19435. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19436. #region 页面操作权限验证
  19437. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19438. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19439. #endregion
  19440. #endregion
  19441. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19442. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19443. From Grp_TourClientList tcl
  19444. Left Join
  19445. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19446. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19447. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19448. From Crm_DeleClient dc
  19449. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19450. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19451. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19452. Where dc.IsDel = 0) temp
  19453. On temp.DcId =tcl.ClientId
  19454. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19455. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19456. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19457. //载入模板
  19458. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19459. if (_dto.Language == 1)
  19460. {
  19461. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19462. }
  19463. //载入模板
  19464. var doc = new Document(tempPath);
  19465. DocumentBuilder builder = new DocumentBuilder(doc);
  19466. //获取word里所有表格
  19467. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19468. //获取所填表格的序数
  19469. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19470. var rowStart = tableOne.Rows[0]; //获取第1行
  19471. if (_dto.Language == 0)
  19472. {
  19473. //循环赋值
  19474. for (int i = 0; i < DcList.Count; i++)
  19475. {
  19476. EncryptionProcessor.DecryptProperties(DcList[i]);
  19477. builder.MoveToCell(0, i + 1, 0, 0);
  19478. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19479. builder.MoveToCell(0, i + 1, 1, 0);
  19480. int sex = DcList[i].Sex;
  19481. string sexStr = string.Empty;
  19482. if (sex == 0) sexStr = "男";
  19483. else if (sex == 1) sexStr = "女";
  19484. else sexStr = "未设置";
  19485. builder.Write(sexStr);
  19486. builder.MoveToCell(0, i + 1, 2, 0);
  19487. string birthDay = DcList[i].BirthDay;
  19488. string birthDayStr = string.Empty;
  19489. if (!string.IsNullOrEmpty(birthDay))
  19490. {
  19491. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19492. }
  19493. builder.Write(birthDayStr);
  19494. builder.MoveToCell(0, i + 1, 3, 0);
  19495. string company = "";
  19496. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19497. {
  19498. company = DcList[i].CompanyFullName.ToString();
  19499. }
  19500. builder.Write(company);
  19501. builder.MoveToCell(0, i + 1, 4, 0);
  19502. builder.Write(DcList[i].Job);
  19503. }
  19504. }
  19505. else if (_dto.Language == 1)
  19506. {
  19507. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19508. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19509. List<string> transArrayStr = new List<string>();
  19510. string transStrRes1 = "";
  19511. for (int i = 0; i < DcList.Count; i++)
  19512. {
  19513. var dc = DcList[i];
  19514. EncryptionProcessor.DecryptProperties(dc);
  19515. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19516. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19517. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19518. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19519. else transStrRes1 += $"{str1}|";
  19520. }
  19521. #region AI转英文
  19522. string jsonValue = JsonConvert.SerializeObject(DcList);
  19523. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  19524. List<SeedMessages> messages = new List<SeedMessages>()
  19525. {
  19526. new SeedMessages
  19527. {
  19528. Role = KimiRole.user,
  19529. Content = jsonValue + text
  19530. }
  19531. };
  19532. KiMiApiClient client = new KiMiApiClient();
  19533. var kimiApiResult = await client.SeedMessage(messages);
  19534. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19535. string clients = kimiApiResult_JObject["content"].ToString();
  19536. string startStr = "```json", endStr = "```";
  19537. // 判断并清除开头部分
  19538. if (clients.StartsWith(startStr))
  19539. {
  19540. clients = clients.Remove(0, startStr.Length);
  19541. }
  19542. // 判断并清除结尾部分
  19543. if (clients.EndsWith(endStr))
  19544. {
  19545. clients = clients.Remove(clients.Length - endStr.Length);
  19546. }
  19547. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  19548. //循环赋值
  19549. for (int i = 0; i < en_Json.Count; i++)
  19550. {
  19551. var dc = en_Json[i];
  19552. var dc1 = DcList.Find(x => x.Id == dc.Id);
  19553. string PYName = dc.FirstName + " " + dc.LastName;
  19554. builder.MoveToCell(0, i + 1, 0, 0);
  19555. builder.Write(PYName);
  19556. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  19557. builder.MoveToCell(0, i + 1, 1, 0);
  19558. builder.Write(sex);
  19559. DateTime birthDt;
  19560. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  19561. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19562. builder.MoveToCell(0, i + 1, 2, 0);
  19563. builder.Write(birthday);
  19564. string company = string.Empty, job = string.Empty;
  19565. company = dc.CompanyFullName;
  19566. job = dc.Job;
  19567. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  19568. {
  19569. //查询对照表
  19570. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  19571. if (tempCec != null)
  19572. {
  19573. company = tempCec.enName;
  19574. }
  19575. }
  19576. builder.MoveToCell(0, i + 1, 3, 0);
  19577. builder.Write(company);
  19578. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  19579. {
  19580. //查询对照表
  19581. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  19582. if (tempPec != null)
  19583. {
  19584. job = tempPec.enName;
  19585. }
  19586. }
  19587. builder.MoveToCell(0, i + 1, 4, 0);
  19588. builder.Write(job);
  19589. }
  19590. #endregion
  19591. #region 旧翻译英文处理
  19592. ////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";
  19593. //string transStrRes = "";
  19594. //if (transStrRes1.Length > 0)
  19595. //{
  19596. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19597. //}
  19598. ////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
  19599. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19600. ////List<string> transArray = new List<string> { };
  19601. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  19602. //if (transStrRes.Contains("|"))
  19603. //{
  19604. // string[] transArray1 = transStrRes.Split('|');
  19605. // if (transArray1.Length > 0)
  19606. // {
  19607. // foreach (var item in transArray1)
  19608. // {
  19609. // if (item.Contains("&"))
  19610. // {
  19611. // string[] transArray2 = item.Split('&');
  19612. // int index = 0;
  19613. // string companyName = "", job = "";
  19614. // if (transArray2.Length > 0)
  19615. // {
  19616. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  19617. // if (1 < transArray2.Length) companyName = transArray2[1];
  19618. // if (2 < transArray2.Length) job = transArray2[2];
  19619. // }
  19620. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19621. // }
  19622. // }
  19623. // }
  19624. //}
  19625. ////循环赋值
  19626. //for (int i = 0; i < DcList.Count; i++)
  19627. //{
  19628. // string PYName = "";
  19629. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19630. // {
  19631. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19632. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  19633. // PYName = PY_First + " " + PY_Last;
  19634. // }
  19635. // else
  19636. // {
  19637. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19638. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19639. // PYName = PY_First + " " + PY_Last;
  19640. // }
  19641. // builder.MoveToCell(0, i + 1, 0, 0);
  19642. // builder.Write(PYName);
  19643. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19644. // builder.MoveToCell(0, i + 1, 1, 0);
  19645. // builder.Write(sex);
  19646. // DateTime birthDt;
  19647. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19648. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19649. // builder.MoveToCell(0, i + 1, 2, 0);
  19650. // builder.Write(birthday);
  19651. // string company = string.Empty, job = string.Empty;
  19652. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19653. // if (dcTransInfo != null)
  19654. // {
  19655. // company = dcTransInfo.CompanyName;
  19656. // job = dcTransInfo.Job;
  19657. // }
  19658. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19659. // {
  19660. // //查询对照表
  19661. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19662. // if (tempCec != null)
  19663. // {
  19664. // company = tempCec.enName;
  19665. // }
  19666. // //翻译
  19667. // else
  19668. // {
  19669. // }
  19670. // }
  19671. // builder.MoveToCell(0, i + 1, 3, 0);
  19672. // builder.Write(company);
  19673. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19674. // {
  19675. // //查询对照表
  19676. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19677. // if (tempPec != null)
  19678. // {
  19679. // job = tempPec.enName;
  19680. // }
  19681. // //翻译
  19682. // else
  19683. // {
  19684. // }
  19685. // }
  19686. // builder.MoveToCell(0, i + 1, 4, 0);
  19687. // builder.Write(job);
  19688. //}
  19689. #endregion
  19690. }
  19691. //删除多余行
  19692. while (tableOne.Rows.Count > DcList.Count + 1)
  19693. {
  19694. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19695. }
  19696. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19697. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19698. doc.Save(fileDir);
  19699. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19700. return Ok(JsonView(true, "操作成功!", Url));
  19701. }
  19702. private class TranslateInfo
  19703. {
  19704. public int Index { get; set; }
  19705. public string CompanyName { get; set; }
  19706. public string Job { get; set; }
  19707. }
  19708. [HttpPost]
  19709. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19710. {
  19711. if (files.Count == 0)
  19712. {
  19713. return Ok(JsonView(false, "文件为空"));
  19714. }
  19715. KiMiApiClient KiMiApi = new KiMiApiClient();
  19716. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19717. if (seedConter.Count == 0)
  19718. {
  19719. return Ok(JsonView(false, "上传结果为空!"));
  19720. }
  19721. var messages = new List<SeedMessages>
  19722. {
  19723. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19724. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19725. };
  19726. messages.InsertRange(1, seedConter);
  19727. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19728. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19729. string clients = kimiApiResult_JObject["content"].ToString();
  19730. string startStr = "```json", endStr = "```";
  19731. // 判断并清除开头部分
  19732. if (clients.StartsWith(startStr))
  19733. {
  19734. clients = clients.Remove(0, startStr.Length);
  19735. }
  19736. // 判断并清除结尾部分
  19737. if (clients.EndsWith(endStr))
  19738. {
  19739. clients = clients.Remove(clients.Length - endStr.Length);
  19740. }
  19741. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19742. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19743. {
  19744. {"姓", "LastName" },
  19745. {"名", "FirstName" },
  19746. {"姓名拼音", "Pinyin" },
  19747. {"性别", "Sex" },
  19748. {"单位", "CompanyFullName" },
  19749. {"职务", "Job" },
  19750. {"出生日期", "Birthday" },
  19751. };
  19752. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19753. foreach (var item in clients_JObject)
  19754. {
  19755. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19756. foreach (var field in clientFieldMap.Keys)
  19757. {
  19758. if (item.TryGetValue(field, out JToken value))
  19759. {
  19760. var getValue = value.ToString();
  19761. System.Type type = cdc.GetType();
  19762. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19763. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19764. propertyInfo.SetValue(cdc, propertyValue);
  19765. }
  19766. }
  19767. crmClients.Add(cdc);
  19768. }
  19769. return Ok(JsonView(new
  19770. {
  19771. fileCount = files.Count,
  19772. UploadCount = seedConter.Count,
  19773. ApiResult = clients,
  19774. CrmClients = crmClients
  19775. }));
  19776. }
  19777. #endregion
  19778. #region 团组倒推表
  19779. /// <summary>
  19780. /// 倒推表基础数据
  19781. /// Init
  19782. /// </summary>
  19783. /// <returns></returns>
  19784. [HttpPost]
  19785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19786. public async Task<IActionResult> PostInvertedListInit()
  19787. {
  19788. var viewData = await _invertedListRep._Init();
  19789. if (viewData.Code != 0)
  19790. {
  19791. return Ok(JsonView(false, viewData.Msg));
  19792. }
  19793. return Ok(JsonView(viewData.Data));
  19794. }
  19795. /// <summary>
  19796. /// 倒推表
  19797. /// Info
  19798. /// </summary>
  19799. /// <param name="dto"></param>
  19800. /// <returns></returns>
  19801. [HttpPost]
  19802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19803. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  19804. {
  19805. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  19806. if (viewData.Code != 0)
  19807. {
  19808. return Ok(JsonView(false, viewData.Msg));
  19809. }
  19810. return Ok(JsonView(viewData.Data));
  19811. }
  19812. /// <summary>
  19813. /// 倒推表
  19814. /// Create
  19815. /// </summary>
  19816. /// <param name="dto"></param>
  19817. /// <returns></returns>
  19818. [HttpPost]
  19819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19820. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  19821. {
  19822. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  19823. if (viewData.Code != 0)
  19824. {
  19825. return Ok(JsonView(false, viewData.Msg));
  19826. }
  19827. return Ok(JsonView(viewData.Data));
  19828. }
  19829. /// <summary>
  19830. /// 倒推表
  19831. /// Update
  19832. /// </summary>
  19833. /// <param name="dto"></param>
  19834. /// <returns></returns>
  19835. [HttpPost]
  19836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19837. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  19838. {
  19839. var viewData = await _invertedListRep._Update(dto);
  19840. if (viewData.Code != 0)
  19841. {
  19842. return Ok(JsonView(false, viewData.Msg));
  19843. }
  19844. return Ok(JsonView(viewData.Data));
  19845. }
  19846. /// <summary>
  19847. /// 倒推表
  19848. /// File Download
  19849. /// </summary>
  19850. /// <param name="dto"></param>
  19851. /// <returns></returns>
  19852. [HttpPost]
  19853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19854. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  19855. {
  19856. var info2 = await _invertedListRep._Info(1, dto.DiId);
  19857. if (info2.Code != 0)
  19858. {
  19859. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  19860. }
  19861. var info1 = info2.Data as InvertedListInfoView;
  19862. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  19863. string teamName = "";
  19864. if (info != null) teamName = info.TeamName;
  19865. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  19866. var doc = new Document();
  19867. var builder = new DocumentBuilder(doc);
  19868. #region old insert
  19869. ////载入模板
  19870. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  19871. //Document doc = new Document(tempPath);
  19872. //DocumentBuilder builder = new DocumentBuilder(doc);
  19873. //利用键值对存放数据
  19874. //Dictionary<string, string> dic = new Dictionary<string, string>();
  19875. //dic.Add("TeamName", teamName);
  19876. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  19877. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  19878. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  19879. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  19880. //dic.Add("SQRemark", info1.ApprovalRemark);
  19881. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  19882. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  19883. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  19884. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  19885. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  19886. //dic.Add("QZRemark", info1.VisaInformationRemark);
  19887. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  19888. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  19889. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  19890. //dic.Add("CQRemark", info1.IssueVisaRemark);
  19891. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  19892. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  19893. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  19894. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  19895. //#region 填充word模板书签内容
  19896. //foreach (var key in dic.Keys)
  19897. //{
  19898. // builder.MoveToBookmark(key);
  19899. // builder.Write(dic[key]);
  19900. //}
  19901. //#endregion
  19902. #endregion
  19903. #region New Insert
  19904. string titleFont = $"仿宋",
  19905. contentFont = $"仿宋";
  19906. var fontColor = Color.FromArgb(64, 64, 64);
  19907. //设置标题 团组名称
  19908. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19909. builder.Font.Name = titleFont;
  19910. builder.Font.Color = fontColor;
  19911. builder.Font.Size = 12;
  19912. builder.Font.Bold = true;
  19913. builder.Writeln(teamName);
  19914. //设置副标题 团组出访时间
  19915. builder.Font.Size = 12;
  19916. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  19917. builder.Writeln();
  19918. var backgroundColor = Color.FromArgb(199, 199, 199);
  19919. var table = builder.StartTable();
  19920. builder.InsertCell();
  19921. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  19922. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  19923. builder.CellFormat.Borders.LineWidth = 1;
  19924. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  19925. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  19926. builder.RowFormat.Height = 40;
  19927. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19928. builder.Font.Name = contentFont;
  19929. builder.Font.Size = 12;
  19930. builder.Font.Bold = true;
  19931. builder.Font.Color = fontColor;
  19932. builder.Write("时间");
  19933. builder.InsertCell();
  19934. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  19935. builder.Write("流程");
  19936. builder.InsertCell();
  19937. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  19938. builder.Write("说明");
  19939. builder.EndRow();
  19940. //报批资料准备
  19941. if (info1.IsSelectedAirportd)
  19942. {
  19943. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  19944. }
  19945. //报批/提供送签资料
  19946. if (info1.IsSelectedApprovalData)
  19947. {
  19948. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  19949. }
  19950. //出批件护照办理
  19951. if (info1.IsSelectedIssueApproval)
  19952. {
  19953. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  19954. }
  19955. //签证资料准备
  19956. if (info1.IsSelectedVisaInfo)
  19957. {
  19958. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  19959. }
  19960. //送签
  19961. if (info1.IsSelectedSendVisa)
  19962. {
  19963. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  19964. }
  19965. //出签
  19966. if (info1.IsSelectedIssueVisa)
  19967. {
  19968. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  19969. }
  19970. //机票
  19971. if (info1.IsSelectedAirTicket)
  19972. {
  19973. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  19974. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  19975. }
  19976. //酒店
  19977. if (info1.IsSelectedHotel)
  19978. {
  19979. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  19980. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  19981. }
  19982. //开行前会
  19983. if (info1.IsSelectedPreTripMeeting)
  19984. {
  19985. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  19986. }
  19987. //送机
  19988. if (info1.IsSelectedAirportdDropOff)
  19989. {
  19990. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  19991. }
  19992. builder.EndTable();
  19993. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  19994. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  19995. for (int i = 0; i < table.Rows.Count; i++)
  19996. {
  19997. var row = table.Rows[i];
  19998. //设置宽度
  19999. row.Cells[0].CellFormat.Width = 20.00;
  20000. row.Cells[1].CellFormat.Width = 30.00;
  20001. row.Cells[2].CellFormat.Width = 50.00;
  20002. if (i != 0)
  20003. {
  20004. //边框设置
  20005. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20006. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20007. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20008. }
  20009. }
  20010. #region 页脚插入图片
  20011. // 创建页脚
  20012. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20013. doc.FirstSection.HeadersFooters.Add(footer);
  20014. Paragraph para = new Paragraph(doc);
  20015. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20016. footer.AppendChild(para);
  20017. builder.MoveTo(para);
  20018. string imagePath = "./Images/FMGJ_Log.png";
  20019. builder.InsertImage(imagePath);
  20020. #endregion
  20021. #endregion
  20022. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20023. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20024. string filePath = fileDir + $@"InvertedList/{fileName}";
  20025. doc.Save(filePath);
  20026. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20027. return Ok(JsonView(true, "操作成功!", Url));
  20028. }
  20029. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20030. {
  20031. var fontColor = Color.FromArgb(64, 64, 64);
  20032. builder.InsertCell();
  20033. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20034. builder.RowFormat.Height = 40;
  20035. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20036. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20037. builder.Font.Name = fontName;
  20038. builder.Font.Size = 8;
  20039. builder.Font.Bold = true;
  20040. builder.Font.Color = fontColor;
  20041. builder.Write(dateTime);
  20042. builder.InsertCell();
  20043. builder.Font.Size = 9;
  20044. builder.Font.Bold = true;
  20045. builder.Font.Color = fontColor;
  20046. builder.Write(content);
  20047. builder.InsertCell();
  20048. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20049. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20050. builder.Font.Size = 9;
  20051. builder.Font.Bold = false;
  20052. builder.Font.Color = fontColor;
  20053. builder.Write(reamrk);
  20054. builder.EndRow();
  20055. }
  20056. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20057. {
  20058. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20059. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20060. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20061. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20062. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20063. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20064. }
  20065. #endregion
  20066. #region 会务倒推表
  20067. /// <summary>
  20068. /// 会务倒推表
  20069. /// Init
  20070. /// </summary>
  20071. /// <returns></returns>
  20072. [HttpPost]
  20073. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20074. public async Task<IActionResult> InforRetrogressTableInit()
  20075. {
  20076. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20077. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20078. return Ok(JsonView(false, groupData.Msg));
  20079. }
  20080. /// <summary>
  20081. /// 会务倒推表
  20082. /// ExcelDownload
  20083. /// </summary>
  20084. /// <param name="dto"></param>
  20085. /// <returns></returns>
  20086. [HttpPost]
  20087. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20089. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20090. {
  20091. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20092. var validatorRes = await validator.ValidateAsync(dto);
  20093. if (!validatorRes.IsValid)
  20094. {
  20095. StringBuilder sb = new StringBuilder();
  20096. foreach (var item in validatorRes.Errors)
  20097. {
  20098. sb.AppendLine(item.ErrorMessage);
  20099. }
  20100. return Ok(JsonView(false, sb.ToString()));
  20101. }
  20102. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20103. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20104. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20105. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20106. #region Excel
  20107. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20108. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20109. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20110. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20111. var fileNamePrefix = string.Empty;
  20112. if (days >= 30)
  20113. {
  20114. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20115. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20116. }
  20117. else if (days < 30 && days > 7)
  20118. {
  20119. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20120. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20121. }
  20122. else if (days <= 7)
  20123. {
  20124. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20125. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20126. }
  20127. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20128. fileName = CommonFun.ValidFileName(fileName);
  20129. //载入模板
  20130. WorkbookDesigner designer = new WorkbookDesigner();
  20131. designer.Workbook = new Workbook(tempPath);
  20132. designer.Process();
  20133. if (!Directory.Exists(savePath))
  20134. {
  20135. Directory.CreateDirectory(savePath);
  20136. }
  20137. string serverPath = $"{savePath}{fileName}";
  20138. designer.Workbook.Save(serverPath);
  20139. string rst = $"{servicePath}{ftpPath}{fileName}";
  20140. #endregion
  20141. return Ok(JsonView(new { url = rst }));
  20142. }
  20143. #endregion
  20144. #region 三公签证费用(签证费、代办费)
  20145. /// <summary>
  20146. /// 三公签证费用(签证费、代办费)
  20147. /// List
  20148. /// </summary>
  20149. /// <returns></returns>
  20150. [HttpPost]
  20151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20152. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20153. {
  20154. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  20155. if (_view.Code != 0)
  20156. {
  20157. return Ok(JsonView(false, _view.Msg));
  20158. }
  20159. return Ok(JsonView(true, "操作成功!", _view.Data));
  20160. }
  20161. /// <summary>
  20162. /// 三公签证费用(签证费、代办费)
  20163. /// Add Or Update
  20164. /// </summary>
  20165. /// <returns></returns>
  20166. [HttpPost]
  20167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20168. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20169. {
  20170. var _view = await _visaFeeInfoRep._Update(_dto);
  20171. if (_view.Code != 0)
  20172. {
  20173. return Ok(JsonView(false, _view.Msg));
  20174. }
  20175. return Ok(JsonView(true, _view.Msg));
  20176. }
  20177. #endregion
  20178. #region 酒店询价
  20179. /// <summary>
  20180. /// 酒店询价
  20181. /// Init
  20182. /// </summary>
  20183. /// <returns></returns>
  20184. [HttpPost]
  20185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20186. public async Task<IActionResult> PostHotelInquiryInit()
  20187. {
  20188. var res = await _hotelInquiryRep._Init();
  20189. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20190. return Ok(JsonView(true, res.Msg, res.Data));
  20191. }
  20192. /// <summary>
  20193. /// 酒店询价
  20194. /// page Item
  20195. /// </summary>
  20196. /// <param name="_dto"></param>
  20197. /// <returns></returns>
  20198. [HttpPost]
  20199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20200. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20201. {
  20202. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20203. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20204. var view = res.Data as PageDataViewBase;
  20205. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20206. }
  20207. /// <summary>
  20208. /// 酒店询价
  20209. /// info
  20210. /// </summary>
  20211. /// <param name="_dto"></param>
  20212. /// <returns></returns>
  20213. [HttpPost]
  20214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20215. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  20216. {
  20217. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  20218. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20219. return Ok(JsonView(true, res.Msg, res.Data));
  20220. }
  20221. /// <summary>
  20222. /// 酒店询价
  20223. /// Add Or Edit
  20224. /// </summary>
  20225. /// <param name="_dto"></param>
  20226. /// <returns></returns>
  20227. [HttpPost]
  20228. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20229. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  20230. {
  20231. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  20232. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20233. return Ok(JsonView(true, res.Msg, res.Data));
  20234. }
  20235. /// <summary>
  20236. /// 酒店询价
  20237. /// Del
  20238. /// </summary>
  20239. /// <param name="_dto"></param>
  20240. /// <returns></returns>
  20241. [HttpPost]
  20242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20243. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  20244. {
  20245. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  20246. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20247. return Ok(JsonView(true, res.Msg, res.Data));
  20248. }
  20249. #endregion
  20250. #region 下载匹配op行程单
  20251. /// <summary>
  20252. /// 匹配op行程单
  20253. /// Init
  20254. /// </summary>
  20255. /// <param name="dto">团组列表请求dto</param>
  20256. /// <returns></returns>
  20257. [HttpPost]
  20258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20259. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  20260. {
  20261. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20262. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20263. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  20264. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  20265. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  20266. .Where(it => it.IsDel == 0)
  20267. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  20268. .OrderByDescending(it => it.VisitStartDate)
  20269. .ToList();
  20270. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  20271. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20272. var diids = groupInfos.Select(it => it.Id).ToList();
  20273. List<string> countrys = new List<string>();
  20274. foreach (var item in country)
  20275. {
  20276. var data = _groupRepository.FormartTeamName(item);
  20277. var dataArray = _groupRepository.GroupSplitCountry(data);
  20278. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20279. }
  20280. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  20281. List<string> areaArray = new List<string>(); //GetGroupCityLine
  20282. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  20283. foreach (var item in areaItem)
  20284. {
  20285. string areaStr = item.Value;
  20286. if (!string.IsNullOrEmpty(areaStr))
  20287. {
  20288. string[] str1 = areaStr.Split("-");
  20289. if (str1.Length > 0)
  20290. {
  20291. areaArray.AddRange(str1);
  20292. }
  20293. }
  20294. }
  20295. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  20296. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  20297. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  20298. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  20299. .ToList();
  20300. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  20301. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  20302. .Where(it => countriesIds.Contains(it.Id))
  20303. .Select(it => new { it.Id, Name = it.Name_CN })
  20304. .ToList();
  20305. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  20306. .Select(it => it.TeamName).ToList();
  20307. stopwatch.Stop();
  20308. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  20309. }
  20310. ///// <summary>
  20311. ///// 匹配op行程单
  20312. ///// Init 查询区域数据
  20313. ///// </summary>
  20314. ///// <param name="dto">团组列表请求dto</param>
  20315. ///// <returns></returns>
  20316. //[HttpPost]
  20317. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20318. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20319. //{
  20320. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20321. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20322. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20323. // if (string.IsNullOrEmpty(countriesDataStr))
  20324. // {
  20325. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20326. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20327. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20328. // }
  20329. // else
  20330. // {
  20331. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20332. // }
  20333. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20334. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20335. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20336. // List<dynamic> childList = new List<dynamic>();
  20337. // int parentId = dto.CountriesId;
  20338. // if (provinceData.Count > 1)
  20339. // {
  20340. // foreach (var item1 in provinceData)
  20341. // {
  20342. // List<dynamic> childList1 = new List<dynamic>();
  20343. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20344. // foreach (var item2 in citiesData1)
  20345. // {
  20346. // List<dynamic> childList2 = new List<dynamic>();
  20347. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20348. // foreach (var item3 in countiesData1)
  20349. // {
  20350. // childList2.Add(new
  20351. // {
  20352. // id = item3.Id,
  20353. // parentId = item2.Id,
  20354. // level = "district",
  20355. // name = item3.Name_CN,
  20356. // });
  20357. // }
  20358. // childList1.Add(new
  20359. // {
  20360. // id = item2.Id,
  20361. // parentId = item1.Id,
  20362. // level = "city",
  20363. // name = item2.Name_CN,
  20364. // childList = childList2
  20365. // });
  20366. // }
  20367. // childList.Add(new
  20368. // {
  20369. // id = item1.Id,
  20370. // parentId = parentId,
  20371. // level = "province",
  20372. // name = item1.Name_CN,
  20373. // childList = childList1
  20374. // });
  20375. // }
  20376. // //城市
  20377. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20378. // foreach (var item2 in citiesData2)
  20379. // {
  20380. // List<dynamic> childList22 = new List<dynamic>();
  20381. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20382. // foreach (var item3 in countiesData1)
  20383. // {
  20384. // childList22.Add(new
  20385. // {
  20386. // id = item3.Id,
  20387. // parentId = item2.Id,
  20388. // level = "district",
  20389. // name = item3.Name_CN,
  20390. // });
  20391. // }
  20392. // childList.Add(new
  20393. // {
  20394. // id = item2.Id,
  20395. // parentId = parentId,
  20396. // level = "city",
  20397. // name = item2.Name_CN,
  20398. // childList = childList22
  20399. // });
  20400. // }
  20401. // }
  20402. // else
  20403. // {
  20404. // foreach (var item2 in citiesData)
  20405. // {
  20406. // string cname = item2.Name_CN;
  20407. // List<dynamic> childList1 = new List<dynamic>();
  20408. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20409. // foreach (var item3 in countiesData1)
  20410. // {
  20411. // childList1.Add(new
  20412. // {
  20413. // Id = item3.Id,
  20414. // parentId = item2.Id,
  20415. // level = "district",
  20416. // name = item3.Name_CN
  20417. // });
  20418. // }
  20419. // childList.Add(new
  20420. // {
  20421. // id = item2.Id,
  20422. // parentId = parentId,
  20423. // level = "city",
  20424. // name = item2.Name_CN,
  20425. // childList = childList1
  20426. // });
  20427. // }
  20428. // }
  20429. // stopwatch.Stop();
  20430. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20431. //}
  20432. /// <summary>
  20433. /// 匹配op行程单
  20434. /// 接团信息列表 Page
  20435. /// </summary>
  20436. /// <param name="dto">团组列表请求dto</param>
  20437. /// <returns></returns>
  20438. [HttpPost]
  20439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20440. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20441. {
  20442. var swatch = new Stopwatch();
  20443. swatch.Start();
  20444. #region 参数验证
  20445. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20446. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20447. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20448. #region 页面操作权限验证
  20449. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20450. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20451. #endregion
  20452. #endregion
  20453. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20454. {
  20455. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20456. //string sqlWhere = "";
  20457. if (!string.IsNullOrEmpty(dto.Country))
  20458. {
  20459. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20460. }
  20461. if (!string.IsNullOrEmpty(dto.Area))
  20462. {
  20463. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20464. }
  20465. if (!string.IsNullOrEmpty(dto.TeamName))
  20466. {
  20467. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20468. }
  20469. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20470. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20471. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20472. swatch.Stop();
  20473. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20474. }
  20475. else
  20476. {
  20477. return Ok(JsonView(false, "查询失败"));
  20478. }
  20479. }
  20480. /// <summary>
  20481. /// 匹配op行程单
  20482. /// 行程单下载
  20483. /// </summary>
  20484. /// <param name="dto">团组列表请求dto</param>
  20485. /// <returns></returns>
  20486. [HttpPost]
  20487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20488. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  20489. {
  20490. #region 参数验证
  20491. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20492. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20493. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20494. #region 页面操作权限验证
  20495. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20496. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  20497. #endregion
  20498. #endregion
  20499. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20500. {
  20501. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  20502. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  20503. }
  20504. else
  20505. {
  20506. return Ok(JsonView(false, "下载失败!"));
  20507. }
  20508. }
  20509. #endregion
  20510. #region 国家信息 数据 注释
  20511. //[HttpPost]
  20512. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  20513. //{
  20514. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  20515. // foreach (var item in dto)
  20516. // {
  20517. // infos.Add(new Grp_GroupsTaskAssignment()
  20518. // {
  20519. // DIId = item,
  20520. // CTId = 82,
  20521. // UId = 248,
  20522. // IsEnable = 1,
  20523. // CreateUserId = 233,
  20524. // CreateTime = DateTime.Now,
  20525. // IsDel = 0
  20526. // });
  20527. // infos.Add(new Grp_GroupsTaskAssignment()
  20528. // {
  20529. // DIId = item,
  20530. // CTId = 82,
  20531. // UId = 286,
  20532. // IsEnable = 1,
  20533. // CreateUserId = 233,
  20534. // CreateTime = DateTime.Now,
  20535. // IsDel = 0
  20536. // });
  20537. // }
  20538. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20539. // return Ok("操作成功");
  20540. //}
  20541. //public class paramJsonDto
  20542. //{
  20543. // public List<CountriesInfo> str { get; set; }
  20544. //}
  20545. //[HttpPost]
  20546. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20547. //{
  20548. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20549. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20550. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20551. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20552. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20553. // _sqlSugar.BeginTran();
  20554. // int countitiesIndex = 0;
  20555. // foreach (var item in dto.str)
  20556. // {
  20557. // dynamic data = item.c;
  20558. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20559. // if (data != null)
  20560. // {
  20561. // countitiesIndex++;
  20562. // foreach (var item1 in data)
  20563. // {
  20564. // string cnname = item1.cn;
  20565. // string enname = item1.en;
  20566. // Sys_Cities provinceInfo = new Sys_Cities()
  20567. // {
  20568. // CountriesId = countriesId,
  20569. // Name_CN = cnname,
  20570. // Name_EN = enname,
  20571. // ParentId = 0,
  20572. // IsCapital = 1,
  20573. // CreateUserId = 208,
  20574. // CreateTime = DateTime.Now,
  20575. // IsDel = 0
  20576. // };
  20577. // if (item1.lv == "province") //省份
  20578. // {
  20579. // provinceInfo.Level = 1;
  20580. // int provinceId = 0;
  20581. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20582. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20583. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20584. // var data1 = item1.c;
  20585. // foreach (var item2 in data1)
  20586. // {
  20587. // if (item2.lv == "city")
  20588. // {
  20589. // string citycnname = item2.cn;
  20590. // string cityenname = item2.en;
  20591. // Sys_Cities cityInfo = new Sys_Cities()
  20592. // {
  20593. // CountriesId = countriesId,
  20594. // ParentId = provinceId,
  20595. // Level = 2,
  20596. // Name_CN = citycnname,
  20597. // Name_EN = cityenname,
  20598. // IsCapital = 1,
  20599. // CreateUserId = 208,
  20600. // CreateTime = DateTime.Now,
  20601. // IsDel = 0
  20602. // };
  20603. // if (item2.c != null)
  20604. // {
  20605. // int cityId = 0;
  20606. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20607. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20608. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20609. // foreach (var item3 in item2.c)
  20610. // {
  20611. // if (item3.lv == "district")
  20612. // {
  20613. // var districtInfo = new Sys_Cities()
  20614. // {
  20615. // CountriesId = countriesId,
  20616. // Name_CN = item3.cn,
  20617. // Name_EN = item3.en,
  20618. // Level = 3,
  20619. // ParentId = cityId,
  20620. // IsCapital = 1,
  20621. // CreateUserId = 208,
  20622. // CreateTime = DateTime.Now,
  20623. // IsDel = 0
  20624. // };
  20625. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20626. // //{
  20627. // districts.Add(districtInfo);
  20628. // //}
  20629. // }
  20630. // }
  20631. // }
  20632. // else
  20633. // {
  20634. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20635. // //{
  20636. // cities.Add(cityInfo);
  20637. // //}
  20638. // }
  20639. // }
  20640. // }
  20641. // }
  20642. // else if (item1.lv == "city")//城市
  20643. // {
  20644. // provinceInfo.Level = 2;
  20645. // if (item1.c != null)
  20646. // {
  20647. // int cityId = 0;
  20648. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20649. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20650. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20651. // foreach (var item3 in item1.c)
  20652. // {
  20653. // if (item3.lv == "district")
  20654. // {
  20655. // var districtInfo = new Sys_Cities()
  20656. // {
  20657. // CountriesId = countriesId,
  20658. // Name_CN = item3.cn,
  20659. // Name_EN = item3.en,
  20660. // Level = 3,
  20661. // ParentId = cityId,
  20662. // IsCapital = 1,
  20663. // CreateUserId = 208,
  20664. // CreateTime = DateTime.Now,
  20665. // IsDel = 0
  20666. // };
  20667. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20668. // //{
  20669. // districts.Add(districtInfo);
  20670. // //}
  20671. // }
  20672. // }
  20673. // }
  20674. // else
  20675. // {
  20676. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20677. // //{
  20678. // cities.Add(provinceInfo);
  20679. // //}
  20680. // }
  20681. // }
  20682. // }
  20683. // }
  20684. // }
  20685. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20686. // cities = cities.Distinct().ToList();
  20687. // districts = districts.Distinct().ToList();
  20688. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20689. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20690. // cities.AddRange(districts);
  20691. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20692. // //_sqlSugar.RollbackTran();
  20693. // _sqlSugar.CommitTran();
  20694. // return Ok(JsonView(false, "操作成功!"));
  20695. //}
  20696. //[HttpPost]
  20697. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20698. //{
  20699. // List<CountitiesInfo> infos = dto.MyProperty;
  20700. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20701. // _sqlSugar.BeginTran();
  20702. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20703. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20704. // foreach (var item in infos)
  20705. // {
  20706. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20707. // if (countryInfo != null)
  20708. // {
  20709. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20710. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20711. // if (cityInfo1 != null)
  20712. // {
  20713. // cityInfo1.IsCapital = 0;
  20714. // cityInfos.Add(cityInfo1);
  20715. // }
  20716. // }
  20717. // }
  20718. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20719. // .UpdateColumns(it => it.IsCapital)
  20720. // .WhereColumns(it => it.Id)
  20721. // .ExecuteCommand();
  20722. // //_sqlSugar.RollbackTran();
  20723. // _sqlSugar.CommitTran();
  20724. // return Ok(JsonView(false, "操作成功!"));
  20725. //}
  20726. //public class CounrtiesDto
  20727. //{
  20728. // public List<CountitiesInfo> MyProperty { get; set; }
  20729. //}
  20730. //public class CountitiesInfo
  20731. //{
  20732. // /// <summary>
  20733. // /// 圣约翰
  20734. // /// </summary>
  20735. // public string capital_name_chinese { get; set; }
  20736. // /// <summary>
  20737. // ///
  20738. // /// </summary>
  20739. // public string capital_name { get; set; }
  20740. // /// <summary>
  20741. // ///
  20742. // /// </summary>
  20743. // public string country_type { get; set; }
  20744. // /// <summary>
  20745. // /// 安提瓜和巴布达
  20746. // /// </summary>
  20747. // public string country_name_chinese { get; set; }
  20748. // /// <summary>
  20749. // /// 安提瓜和巴布达
  20750. // /// </summary>
  20751. // public string country_name_chinese_short { get; set; }
  20752. // /// <summary>
  20753. // /// 安提瓜和巴布达
  20754. // /// </summary>
  20755. // public string country_name_chinese_UN { get; set; }
  20756. // /// <summary>
  20757. // ///
  20758. // /// </summary>
  20759. // public string country_name_english_abbreviation { get; set; }
  20760. // /// <summary>
  20761. // ///
  20762. // /// </summary>
  20763. // public string country_name_english_formal { get; set; }
  20764. // /// <summary>
  20765. // ///
  20766. // /// </summary>
  20767. // public string country_name_english_UN { get; set; }
  20768. // /// <summary>
  20769. // ///
  20770. // /// </summary>
  20771. // public string continent_name { get; set; }
  20772. // /// <summary>
  20773. // ///
  20774. // /// </summary>
  20775. // public string subregion_name { get; set; }
  20776. // /// <summary>
  20777. // ///
  20778. // /// </summary>
  20779. // public string country_code2 { get; set; }
  20780. // /// <summary>
  20781. // ///
  20782. // /// </summary>
  20783. // public string country_code3 { get; set; }
  20784. // /// <summary>
  20785. // ///
  20786. // /// </summary>
  20787. // public string phone_code { get; set; }
  20788. //}
  20789. //public class CountriesInfo : BasicInfo
  20790. //{
  20791. // public List<CitiesInfo> c { get; set; }
  20792. //}
  20793. //public class CitiesInfo : BasicInfo
  20794. //{
  20795. // public List<AreaInfo> c { get; set; }
  20796. //}
  20797. //public class AreaInfo : BasicInfo
  20798. //{
  20799. // public List<AreaInfo> c { get; set; }
  20800. //}
  20801. //public class BasicInfo
  20802. //{
  20803. // public string code { get; set; }
  20804. // public string cn { get; set; }
  20805. // public string lv { get; set; }
  20806. // public string en { get; set; }
  20807. //}
  20808. #endregion
  20809. #region 查看邀请方
  20810. /// <summary>
  20811. /// 查看邀请方
  20812. /// 邀请方信息 Init
  20813. /// </summary>
  20814. /// <param name="dto"></param>
  20815. /// <returns></returns>
  20816. [HttpPost]
  20817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20818. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  20819. {
  20820. string sqlWhere = string.Empty;
  20821. if (!string.IsNullOrEmpty(dto.Search))
  20822. {
  20823. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  20824. }
  20825. string sql = string.Format($@"Select
  20826. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  20827. Id,
  20828. UnitName
  20829. From Res_InvitationOfficialActivityData
  20830. Where IsDel = 0
  20831. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  20832. RefAsync<int> total = 0;
  20833. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20834. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  20835. }
  20836. /// <summary>
  20837. /// 查看邀请方
  20838. /// 国家信息 Init
  20839. /// </summary>
  20840. /// <param name="dto"></param>
  20841. /// <returns></returns>
  20842. [HttpPost]
  20843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20844. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  20845. {
  20846. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  20847. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20848. var diids = groupInfos.Select(it => it.Id).ToList();
  20849. List<string> countrys = new List<string>();
  20850. foreach (var item in country)
  20851. {
  20852. var data = _groupRepository.FormartTeamName(item);
  20853. var dataArray = _groupRepository.GroupSplitCountry(data);
  20854. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20855. }
  20856. countrys = countrys.Distinct().ToList();
  20857. for (int i = 0; i < countrys.Count; i++)
  20858. {
  20859. string item = countrys[i];
  20860. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  20861. {
  20862. countrys.Remove(item);
  20863. i--;
  20864. }
  20865. }
  20866. RefAsync<int> total = 0;
  20867. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  20868. .Where(it => countrys.Contains(it.Name_CN))
  20869. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20870. .Select(it => new { id = it.Id, name = it.Name_CN })
  20871. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20872. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20873. }
  20874. /// <summary>
  20875. /// 查看邀请方
  20876. /// 城市信息 Init
  20877. /// </summary>
  20878. /// <param name="dto"></param>
  20879. /// <returns></returns>
  20880. [HttpPost]
  20881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20882. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  20883. {
  20884. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  20885. RefAsync<int> total = 0;
  20886. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  20887. .Where(it => it.CountriesId == dto.CountiesId)
  20888. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20889. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  20890. .Select(it => new { id = it.Id, name = it.Name_CN })
  20891. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20892. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20893. }
  20894. /// <summary>
  20895. /// 查看邀请方
  20896. /// 团组名称 Init
  20897. /// </summary>
  20898. /// <param name="dto"></param>
  20899. /// <returns></returns>
  20900. [HttpPost]
  20901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20902. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  20903. {
  20904. var watch = new Stopwatch();
  20905. watch.Start();
  20906. RefAsync<int> total = 0;
  20907. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  20908. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  20909. .Where((oa, di) => oa.IsDel == 0)
  20910. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  20911. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  20912. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  20913. .Distinct()
  20914. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20915. watch.Stop();
  20916. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  20917. }
  20918. /// <summary>
  20919. /// 查看邀请方
  20920. /// 团组 & 邀请方信息
  20921. /// </summary>
  20922. /// <param name="dto"></param>
  20923. /// <returns></returns>
  20924. [HttpPost]
  20925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20926. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  20927. {
  20928. var watch = new Stopwatch();
  20929. watch.Start();
  20930. RefAsync<int> total = 0;
  20931. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  20932. .AS("Grp_DelegationInfo")
  20933. .Includes(x => x.InvitingInfos)
  20934. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  20935. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  20936. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  20937. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  20938. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  20939. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  20940. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20941. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  20942. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  20943. infos.ForEach(x =>
  20944. {
  20945. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  20946. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  20947. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  20948. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  20949. });
  20950. watch.Stop();
  20951. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  20952. }
  20953. #endregion
  20954. #region 报批行程
  20955. /// <summary>
  20956. /// 报批行程初始化
  20957. /// </summary>
  20958. /// <param name="dto"></param>
  20959. /// <returns></returns>
  20960. [HttpPost]
  20961. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  20962. {
  20963. const int chiNumber = 5;
  20964. var jw = JsonView(false);
  20965. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  20966. var group = groupList.First();
  20967. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  20968. group = groupList.First(x => x.Id == diid);
  20969. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20970. .Where(x => x.DiId == diid && x.IsDel == 0)
  20971. .ToArray();
  20972. var count = 1;
  20973. foreach (var item in blackCodeList)
  20974. {
  20975. if (string.IsNullOrWhiteSpace(item.Title))
  20976. {
  20977. item.Title = "未设置名称数据" + count;
  20978. }
  20979. count++;
  20980. }
  20981. ;
  20982. if (group == null)
  20983. {
  20984. jw.Msg = "暂无团组!";
  20985. return Ok(jw);
  20986. }
  20987. var data = new
  20988. {
  20989. groupList = groupList.Select(x => new
  20990. {
  20991. x.TeamName,
  20992. x.Id
  20993. }),
  20994. content = new ArrayList(),
  20995. groupInfo = new
  20996. {
  20997. group.VisitDays,
  20998. group.TourCode,
  20999. group.VisitPNumber,
  21000. group.TeamName,
  21001. group.Id,
  21002. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21003. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21004. group.ClientUnit
  21005. },
  21006. blackCodeList = blackCodeList.Select(x => new
  21007. {
  21008. x.Title,
  21009. x.Id
  21010. }),
  21011. FileTempList = new ArrayList()
  21012. {
  21013. new { Index = 1,FileName = "旧模板" },
  21014. new { Index = 2,FileName = "省外办" },
  21015. new { Index = 3,FileName = "市外办" },
  21016. }
  21017. };
  21018. var resultArr = new ArrayList();
  21019. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21020. #region 默认不生成行程
  21021. //if (content.Count == 0)
  21022. //{
  21023. // var stay = "-";
  21024. // var cityPath = "-";
  21025. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21026. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21027. // .ToList();
  21028. // //添加城市路径以及住宿地
  21029. // //黑屏代码数据
  21030. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21031. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21032. // {
  21033. // jw = JsonView(true, "黑屏代码有误!", data);
  21034. // return Ok(jw);
  21035. // }
  21036. // data = data with
  21037. // {
  21038. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21039. // {
  21040. // x.Title,
  21041. // x.Id,
  21042. // }).ToArray())
  21043. // };
  21044. // foreach (DataRow row in dtBlack.Rows)
  21045. // {
  21046. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21047. // {
  21048. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21049. // return Ok(jw);
  21050. // }
  21051. // }
  21052. // //黑屏代码获取时间区间
  21053. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21054. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21055. // _sqlSugar.BeginTran();
  21056. // for (int i = 0; i < timeArr.Count; i++)
  21057. // {
  21058. // stay = "-";
  21059. // cityPath = "-";
  21060. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21061. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21062. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21063. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21064. // if (tbSelect.Length > 0)
  21065. // {
  21066. // List<string> threeCodeStr = new List<string>();
  21067. // foreach (var item in tbSelect)
  21068. // {
  21069. // var threeCode = item["Three"].ToString() ?? "";
  21070. // if (threeCode.Length == 6)
  21071. // {
  21072. // var start = threeCode.Substring(0, 3);
  21073. // var end = threeCode.Substring(3, 3);
  21074. // if (threeCodeStr.Count == 0)
  21075. // {
  21076. // threeCodeStr.Add(start);
  21077. // threeCodeStr.Add(end);
  21078. // }
  21079. // else
  21080. // {
  21081. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21082. // {
  21083. // threeCodeStr.Add(end);
  21084. // }
  21085. // else
  21086. // {
  21087. // threeCodeStr.Add(start);
  21088. // threeCodeStr.Add(end);
  21089. // }
  21090. // }
  21091. // }
  21092. // }
  21093. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21094. // var last = threeCodeStr.Last();
  21095. // foreach (var item in threeCodeStr)
  21096. // {
  21097. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21098. // if (item.Equals(last))
  21099. // {
  21100. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21101. // }
  21102. // }
  21103. // cityPath = cityPath.Trim('-');
  21104. // }
  21105. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21106. // appro.Diid = diid ?? -1;
  21107. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21108. // appro.Id = thisId;
  21109. // appro.CreateUserId = dto.UserId;
  21110. // appro.CreateTime = DateTime.Now;
  21111. // content.Add(appro);
  21112. // }
  21113. // _sqlSugar.CommitTran();
  21114. //}
  21115. #endregion
  21116. foreach (var x in content)
  21117. {
  21118. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21119. if (chiList.Count < chiNumber)
  21120. {
  21121. for (int i = chiList.Count; i < chiNumber; i++)
  21122. {
  21123. chiList.Add(new Grp_ApprovalTravelDetails());
  21124. }
  21125. }
  21126. resultArr.Add(new
  21127. {
  21128. x.Id,
  21129. x.Date,
  21130. x.Diid,
  21131. chiList = chiList.Select(x1 => new
  21132. {
  21133. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21134. x1.Details,
  21135. x1.ParentId,
  21136. x1.Id
  21137. })
  21138. });
  21139. }
  21140. data = data with
  21141. {
  21142. content = resultArr,
  21143. };
  21144. jw = JsonView(true, "获取成功!", data);
  21145. return Ok(jw);
  21146. }
  21147. /// <summary>
  21148. /// 报批行程删除
  21149. /// </summary>
  21150. /// <param name="dto"></param>
  21151. /// <returns></returns>
  21152. [HttpPost]
  21153. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21154. {
  21155. var jw = JsonView(false);
  21156. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21157. if (group == null)
  21158. {
  21159. jw.Msg = "团组参数有误!";
  21160. return Ok(jw);
  21161. }
  21162. try
  21163. {
  21164. _sqlSugar.BeginTran();
  21165. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21166. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21167. {
  21168. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21169. DeleteUserId = dto.uesrId,
  21170. IsDel = 1
  21171. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21172. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21173. {
  21174. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21175. DeleteUserId = dto.uesrId,
  21176. IsDel = 1
  21177. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21178. _sqlSugar.CommitTran();
  21179. jw = JsonView(true, "删除成功");
  21180. }
  21181. catch (Exception ex)
  21182. {
  21183. jw = JsonView(false, ex.Message);
  21184. }
  21185. return Ok(jw);
  21186. }
  21187. /// <summary>
  21188. /// 报批行程保存
  21189. /// </summary>
  21190. /// <param name="dto"></param>
  21191. /// <returns></returns>
  21192. [HttpPost]
  21193. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21194. {
  21195. var jw = JsonView(false);
  21196. var Find = dto.Arr.Find(x => x.id == 0);
  21197. if (Find != null)
  21198. {
  21199. jw.Msg = "生成的ID为0!";
  21200. return Ok(jw);
  21201. }
  21202. foreach (var item in dto.Arr)
  21203. {
  21204. foreach (var chi in item.chiList)
  21205. {
  21206. if (chi.parentId == 0)
  21207. {
  21208. chi.parentId = item.id;
  21209. }
  21210. }
  21211. }
  21212. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21213. _sqlSugar.BeginTran();
  21214. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  21215. {
  21216. var parentIds = dto.Arr.Select(x => x.id).ToList();
  21217. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  21218. {
  21219. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21220. DeleteUserId = dto.UserId,
  21221. IsDel = 1
  21222. }).ExecuteCommand();
  21223. }
  21224. try
  21225. {
  21226. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  21227. {
  21228. CreateTime = DateTime.Now,
  21229. CreateUserId = dto.UserId,
  21230. Details = x.details,
  21231. ParentId = x.parentId,
  21232. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21233. Remark = "",
  21234. IsDel = 0
  21235. }).ToList()).ExecuteCommand();
  21236. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  21237. {
  21238. Id = x.id,
  21239. Details = x.details,
  21240. ParentId = x.parentId,
  21241. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21242. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  21243. {
  21244. Details = x.Details,
  21245. ParentId = x.ParentId,
  21246. Time = x.Time
  21247. }).ExecuteCommand();
  21248. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  21249. {
  21250. Id = x.id,
  21251. Date = x.date,
  21252. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  21253. {
  21254. Date = x.Date
  21255. }).ExecuteCommand();
  21256. _sqlSugar.CommitTran();
  21257. jw = JsonView(true, "保存成功!");
  21258. }
  21259. catch (Exception ex)
  21260. {
  21261. _sqlSugar.RollbackTran();
  21262. jw = JsonView(false, "保存失败!" + ex.Message);
  21263. }
  21264. return Ok(jw);
  21265. }
  21266. /// <summary>
  21267. /// 报批行程生成
  21268. /// </summary>
  21269. /// <param name="dto"></param>
  21270. /// <returns></returns>
  21271. [HttpPost]
  21272. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  21273. {
  21274. var jw = JsonView(false);
  21275. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21276. if (group == null)
  21277. {
  21278. jw.Msg = "暂无该团组!";
  21279. return Ok(jw);
  21280. }
  21281. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  21282. //黑屏代码数据
  21283. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  21284. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21285. {
  21286. jw.Msg = "黑屏代码有误!";
  21287. return Ok(jw);
  21288. }
  21289. foreach (DataRow row in dtBlack.Rows)
  21290. {
  21291. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21292. {
  21293. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  21294. return Ok(jw);
  21295. }
  21296. }
  21297. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  21298. var resultArr = new ArrayList();
  21299. //if (officialActivitiesArr.Count == 0)
  21300. //{
  21301. // jw.Msg = "暂无公务出访信息!";
  21302. // return Ok(jw);
  21303. //}
  21304. try
  21305. {
  21306. _sqlSugar.BeginTran();
  21307. DeleteApprovalJourney(new
  21308. Domain.Dtos.Groups.DeleteApprovalJourney
  21309. {
  21310. Diid = dto.Diid,
  21311. uesrId = dto.Userid
  21312. });
  21313. var stay = "-";
  21314. var cityPath = "-";
  21315. var arriveCountry = string.Empty;
  21316. //添加城市路径以及住宿地
  21317. //黑屏代码获取时间区间
  21318. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21319. var empty = "【未收入该三字码!请机票同事录入】";
  21320. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21321. #region 配置公务活动时间
  21322. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21323. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21324. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21325. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21326. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21327. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21328. {
  21329. 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" }),
  21330. 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"}),
  21331. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21332. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21333. };
  21334. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21335. {
  21336. 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" }),
  21337. 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"}),
  21338. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21339. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21340. };
  21341. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21342. {
  21343. 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" }),
  21344. 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"}),
  21345. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21346. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21347. };
  21348. #endregion
  21349. var nextDayNum = 0;
  21350. for (int i = 0; i < timeArr.Count; i++)
  21351. {
  21352. stay = "-";
  21353. cityPath = "-";
  21354. var chiarr = new List<Grp_ApprovalTravelDetails>();
  21355. DateTime NewData = DateTime.Parse(timeArr[i]);
  21356. //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();
  21357. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21358. if (nextDayNum > 0)
  21359. {
  21360. nextDayNum--;
  21361. }
  21362. if (tbSelect.Length > 0)
  21363. {
  21364. List<string> threeCodeStr = new List<string>();
  21365. bool isTrade = false;
  21366. string trip = string.Empty;
  21367. foreach (var item in tbSelect)
  21368. {
  21369. if (nextDayNum == 0)
  21370. {
  21371. nextDayNum = Convert.ToInt32(item["Sign"]);
  21372. }
  21373. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21374. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21375. var takeOffTime = DateTime.Parse(timeArr[i]);
  21376. var fallToTime = DateTime.Parse(timeArr[i]);
  21377. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21378. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21379. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21380. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21381. if (nextDayNum > 0)
  21382. {
  21383. fallToTime = fallToTime.AddDays(nextDayNum);
  21384. }
  21385. trip = string.Empty;
  21386. var start = string.Empty;
  21387. var end = string.Empty;
  21388. var threeCode = item["Three"].ToString() ?? "";
  21389. if (threeCode.Length == 6)
  21390. {
  21391. start = threeCode.Substring(0, 3);
  21392. end = threeCode.Substring(3, 3);
  21393. if (threeCodeStr.Count == 0)
  21394. {
  21395. threeCodeStr.Add(start);
  21396. threeCodeStr.Add(end);
  21397. }
  21398. else
  21399. {
  21400. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21401. {
  21402. threeCodeStr.Add(end);
  21403. }
  21404. else
  21405. {
  21406. threeCodeStr.Add(start);
  21407. threeCodeStr.Add(end);
  21408. }
  21409. }
  21410. }
  21411. //处理机票信息
  21412. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  21413. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  21414. if (start_Object == null)
  21415. {
  21416. start_Object = new Res_ThreeCode()
  21417. {
  21418. AirPort = empty,
  21419. AirPort_En = empty,
  21420. City = empty,
  21421. Country = empty,
  21422. Four = empty,
  21423. Three = empty,
  21424. };
  21425. }
  21426. if (end_Object == null)
  21427. {
  21428. end_Object = new Res_ThreeCode()
  21429. {
  21430. AirPort = empty,
  21431. AirPort_En = empty,
  21432. City = empty,
  21433. Country = empty,
  21434. Four = empty,
  21435. Three = empty,
  21436. };
  21437. }
  21438. //机型判断
  21439. string airModel = item["AirModel"].ToString();
  21440. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21441. string flightTime = item["FlightTime"].ToString();
  21442. flightTime = ParseBlackTime(flightTime);
  21443. //航班号
  21444. string flightcode = item["Fliagtcode"].ToString();
  21445. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21446. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21447. if (aircompany == null)
  21448. {
  21449. aircompany = new Res_AirCompany
  21450. {
  21451. CnName = hsEmpty,
  21452. EnName = hsEmpty,
  21453. ShortCode = hsEmpty,
  21454. };
  21455. }
  21456. //航班前公务安排
  21457. if (tbSelect.First().Equals(item) && i != 0)
  21458. {
  21459. foreach (var takeoff in takeoffTimes)
  21460. {
  21461. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21462. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21463. {
  21464. foreach (var addTime in takeoff.Item2)
  21465. {
  21466. chiarr.Add(new Grp_ApprovalTravelDetails
  21467. {
  21468. Time = addTime,
  21469. CreateTime = DateTime.Now,
  21470. CreateUserId = dto.Userid,
  21471. ParentId = 0,
  21472. Details = "公务活动"
  21473. });
  21474. }
  21475. break;
  21476. }
  21477. }
  21478. }
  21479. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21480. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21481. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21482. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  21483. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21484. if (isTrade)
  21485. {
  21486. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  21487. trip += "(转机不出机场)。";
  21488. }
  21489. //else
  21490. //{
  21491. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  21492. //}
  21493. chiarr.Add(new Grp_ApprovalTravelDetails
  21494. {
  21495. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  21496. CreateTime = DateTime.Now,
  21497. CreateUserId = dto.Userid,
  21498. ParentId = 0,
  21499. Details = trip
  21500. });
  21501. //最后一条到达的时间安排公务
  21502. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  21503. {
  21504. bool isCheckCountry = false;
  21505. if (end_Object.Country != arriveCountry)
  21506. {
  21507. arriveCountry = end_Object.Country;
  21508. isCheckCountry = true;
  21509. }
  21510. if (nextDayNum == 0)
  21511. {
  21512. //需要入境的情况
  21513. if (isCheckCountry)
  21514. {
  21515. foreach (var fallTime in fallTimesCheckCountry)
  21516. {
  21517. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21518. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21519. {
  21520. foreach (var addTime in fallTime.Item2)
  21521. {
  21522. chiarr.Add(new Grp_ApprovalTravelDetails
  21523. {
  21524. Time = addTime,
  21525. CreateTime = DateTime.Now,
  21526. CreateUserId = dto.Userid,
  21527. ParentId = 0,
  21528. Details = "公务活动"
  21529. });
  21530. }
  21531. break;
  21532. }
  21533. }
  21534. }
  21535. else
  21536. {
  21537. foreach (var fallTime in fallTimesNotCheckCountry)
  21538. {
  21539. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21540. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21541. {
  21542. foreach (var addTime in fallTime.Item2)
  21543. {
  21544. chiarr.Add(new Grp_ApprovalTravelDetails
  21545. {
  21546. Time = addTime,
  21547. CreateTime = DateTime.Now,
  21548. CreateUserId = dto.Userid,
  21549. ParentId = 0,
  21550. Details = "公务活动"
  21551. });
  21552. }
  21553. break;
  21554. }
  21555. }
  21556. }
  21557. }
  21558. }
  21559. }
  21560. //添加乘车语句
  21561. //chiarr.Add(new Grp_ApprovalTravelDetails
  21562. //{
  21563. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21564. // CreateTime = DateTime.Now,
  21565. // CreateUserId = dto.Userid,
  21566. // ParentId = 0,
  21567. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21568. //});
  21569. //if (i != timeArr.Count - 1)
  21570. //{
  21571. // fallToTime = fallToTime.AddHours(2.5);
  21572. // foreach (var item in Times)
  21573. // {
  21574. // //排列公务时间
  21575. // if (fallToTime.Hour < item.Item1)
  21576. // {
  21577. // chiarr.Add(new Grp_ApprovalTravelDetails
  21578. // {
  21579. // Time = $"{item.Item2} - {item.Item3}",
  21580. // CreateTime = DateTime.Now,
  21581. // CreateUserId = dto.Userid,
  21582. // ParentId = 0,
  21583. // Details = "公务活动"
  21584. // });
  21585. // }
  21586. // }
  21587. //}
  21588. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21589. var last = threeCodeStr.Last();
  21590. foreach (var item in threeCodeStr)
  21591. {
  21592. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21593. if (item.Equals(last))
  21594. {
  21595. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21596. }
  21597. }
  21598. cityPath = cityPath.Trim('-');
  21599. }
  21600. else
  21601. {
  21602. foreach (var item in Times)
  21603. {
  21604. chiarr.Add(new Grp_ApprovalTravelDetails
  21605. {
  21606. Time = $"{item.Item2} - {item.Item3}",
  21607. CreateTime = DateTime.Now,
  21608. CreateUserId = dto.Userid,
  21609. ParentId = 0,
  21610. Details = "公务活动"
  21611. });
  21612. }
  21613. }
  21614. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21615. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21616. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21617. appro.Diid = dto.Diid;
  21618. appro.CreateUserId = dto.Userid;
  21619. appro.CreateTime = DateTime.Now;
  21620. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21621. appro.Id = thisId;
  21622. //foreach (var item in gwinfo)
  21623. //{
  21624. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21625. // chi.Details = "拜访" + item.Client;
  21626. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21627. // {
  21628. // chi.Details += "," + item.ReqSample;
  21629. // }
  21630. // chi.ParentId = thisId;
  21631. // chi.Time = item.Time;
  21632. // chiarr.Add(chi);
  21633. //}
  21634. if (chiarr.Count < 6)
  21635. {
  21636. for (int j = chiarr.Count; j < 6; j++)
  21637. {
  21638. chiarr.Add(new
  21639. Grp_ApprovalTravelDetails());
  21640. }
  21641. }
  21642. resultArr.Add(new
  21643. {
  21644. appro.Id,
  21645. appro.Date,
  21646. appro.Diid,
  21647. chiList = chiarr.Select(x1 => new
  21648. {
  21649. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21650. x1.Details,
  21651. x1.ParentId,
  21652. x1.Id
  21653. })
  21654. });
  21655. }
  21656. _sqlSugar.CommitTran();
  21657. jw = JsonView(true, "生成成功!", resultArr);
  21658. }
  21659. catch (Exception ex)
  21660. {
  21661. jw.Code = 400;
  21662. jw.Msg = "生成失败!" + ex.Message;
  21663. }
  21664. return Ok(jw);
  21665. }
  21666. /// <summary>
  21667. /// 报批行程word导出
  21668. /// </summary>
  21669. /// <param name="dto"></param>
  21670. /// <returns></returns>
  21671. [HttpPost]
  21672. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21673. {
  21674. var jw = JsonView(false);
  21675. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21676. if (group == null)
  21677. {
  21678. jw.Msg = "暂无该团组!";
  21679. return Ok(jw);
  21680. }
  21681. //模板路径
  21682. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21683. var fileName = string.Empty;
  21684. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21685. bool bold = false;
  21686. if (dto.FileIndex == 1)
  21687. {
  21688. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21689. }
  21690. else if (dto.FileIndex == 2)
  21691. {
  21692. fileName = "省外办-报批.docx";
  21693. bold = false;
  21694. titleFont = "方正黑体简体";
  21695. timeFont = "Times New Roman";
  21696. contentFont = "方正仿宋_GBK";
  21697. }
  21698. else if (dto.FileIndex == 3)
  21699. {
  21700. fileName = "市外办-报批.docx";
  21701. titleFont = "方正黑体简体";
  21702. timeFont = "Times New Roman";
  21703. contentFont = "方正仿宋简体";
  21704. }
  21705. tempPath = tempPath + fileName;
  21706. //载入模板
  21707. Document doc = new Document(tempPath);
  21708. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21709. //获取所填表格的序数
  21710. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21711. Aspose.Words.Tables.Row titleRowClone = null;
  21712. Aspose.Words.Tables.Row CenterRowClone = null;
  21713. int index = 0;
  21714. int indexChi = 0;
  21715. int SetIndex = 0;
  21716. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21717. //获取数据,放到datatable
  21718. foreach (var item in ApprovalTravelArr)
  21719. {
  21720. if (index > 0)
  21721. {
  21722. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21723. tableOne.AppendChild(titleRowClone);
  21724. }
  21725. var textTime = item.Date;
  21726. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21727. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21728. SetIndex++;
  21729. if (ChiRep.Count > 0)
  21730. {
  21731. foreach (var itemChi in ChiRep)
  21732. {
  21733. var txtTime = itemChi.Time;
  21734. var txtDetail = itemChi.Details;
  21735. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21736. {
  21737. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21738. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21739. //indexChi++;
  21740. //SetIndex++;
  21741. break;
  21742. }
  21743. if (indexChi > 0)
  21744. {
  21745. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21746. tableOne.AppendChild(CenterRowClone);
  21747. }
  21748. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21749. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21750. indexChi++;
  21751. SetIndex++;
  21752. }
  21753. }
  21754. //else
  21755. //{
  21756. // if (indexChi > 0)
  21757. // {
  21758. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21759. // tableOne.AppendChild(CenterRowClone);
  21760. // }
  21761. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21762. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21763. // indexChi++;
  21764. // SetIndex++;
  21765. //}
  21766. index++;
  21767. }
  21768. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21769. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21770. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21771. jw.Code = 200;
  21772. jw.Msg = "";
  21773. return Ok(jw);
  21774. }
  21775. private string ParseBlackTime(string time)
  21776. {
  21777. // 匹配可能只有分钟的情况
  21778. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21779. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21780. if (match.Success)
  21781. {
  21782. string hours = match.Groups[1].Value;
  21783. string minutes = match.Groups[2].Value;
  21784. // 如果小时部分为空,则只显示分钟
  21785. if (string.IsNullOrEmpty(hours))
  21786. {
  21787. return $"{minutes}分钟";
  21788. }
  21789. // 如果分钟部分为空,则只显示小时
  21790. else if (string.IsNullOrEmpty(minutes))
  21791. {
  21792. return $"{hours}小时";
  21793. }
  21794. // 否则显示完整格式
  21795. else
  21796. {
  21797. return $"{hours}小时{minutes}分钟";
  21798. }
  21799. }
  21800. else
  21801. {
  21802. return "未知时长";
  21803. }
  21804. }
  21805. private string intToString(int numberVal)
  21806. {
  21807. string numberval = numberVal.ToString();
  21808. Dictionary<char, string> Number = new Dictionary<char, string>();
  21809. Number.Add('1', "一");
  21810. Number.Add('2', "二");
  21811. Number.Add('3', "三");
  21812. Number.Add('4', "四");
  21813. Number.Add('5', "五");
  21814. Number.Add('6', "六");
  21815. Number.Add('7', "七");
  21816. Number.Add('8', "八");
  21817. Number.Add('9', "九");
  21818. string stringNumberVal = string.Empty;
  21819. for (int i = 0; i < numberval.Length; i++)
  21820. {
  21821. if (i == 0)
  21822. {
  21823. stringNumberVal += Number[numberval[i]];
  21824. }
  21825. else if (i >= 1)
  21826. {
  21827. if (numberval[i] == '0')
  21828. {
  21829. stringNumberVal = "十";
  21830. }
  21831. else
  21832. {
  21833. stringNumberVal += "十" + Number[numberval[i]];
  21834. }
  21835. }
  21836. }
  21837. return stringNumberVal;
  21838. }
  21839. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  21840. {
  21841. //获取table中的某个单元格,从0开始
  21842. Cell lshCell = table.Rows[rows].Cells[cells];
  21843. //将单元格中段落移除
  21844. foreach (Paragraph item in lshCell.Paragraphs)
  21845. {
  21846. lshCell.Paragraphs.Remove(item);
  21847. }
  21848. if (val.Contains("\r\n"))
  21849. {
  21850. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  21851. foreach (var item in spArr)
  21852. {
  21853. //新建一个段落
  21854. Paragraph p = new Paragraph(doc);
  21855. var r = new Run(doc, item);
  21856. //设置字体
  21857. if (!string.IsNullOrEmpty(font))
  21858. {
  21859. r.Font.Name = font;
  21860. }
  21861. r.Font.Bold = bold;
  21862. //把设置的值赋给之前新建的段落
  21863. p.AppendChild(r);
  21864. //将此段落加到单元格内
  21865. lshCell.AppendChild(p);
  21866. }
  21867. }
  21868. else
  21869. {
  21870. //新建一个段落
  21871. Paragraph p = new Paragraph(doc);
  21872. var r = new Run(doc, val);
  21873. //设置字体
  21874. if (!string.IsNullOrEmpty(font))
  21875. {
  21876. r.Font.Name = font;
  21877. }
  21878. r.Font.Bold = bold;
  21879. //把设置的值赋给之前新建的段落
  21880. p.AppendChild(r);
  21881. //将此段落加到单元格内
  21882. lshCell.AppendChild(p);
  21883. }
  21884. }
  21885. /// <summary>
  21886. /// 报批行程AI续写
  21887. /// </summary>
  21888. /// <returns></returns>
  21889. [HttpPost]
  21890. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  21891. {
  21892. var jw = JsonView(false);
  21893. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  21894. {
  21895. jw.Msg = "参数有误!";
  21896. return Ok(jw);
  21897. }
  21898. KiMiApiClient kiMi = new KiMiApiClient();
  21899. List<SeedMessages> messages = new List<SeedMessages>() {
  21900. new SeedMessages
  21901. {
  21902. Role = KimiRole.system,
  21903. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  21904. },
  21905. new SeedMessages
  21906. {
  21907. Role = KimiRole.user,
  21908. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  21909. }
  21910. };
  21911. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  21912. string data = kimi_result.Choices[0]?.Message.Content;
  21913. if (string.IsNullOrWhiteSpace(data))
  21914. {
  21915. jw.Data = "Ai续写失败!";
  21916. }
  21917. else
  21918. {
  21919. jw = JsonView(true, "success!", data);
  21920. }
  21921. return Ok(jw);
  21922. }
  21923. #endregion
  21924. #region 团组接待意见调查
  21925. /// <summary>
  21926. /// 团组接待意见调查 - 信息管理
  21927. /// 基础数据(团组)
  21928. /// </summary>
  21929. /// <returns></returns>
  21930. [HttpGet]
  21931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21932. public async Task<IActionResult> OpinionaireInit()
  21933. {
  21934. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  21935. .Select(x => new
  21936. {
  21937. x.Id,
  21938. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  21939. })
  21940. .OrderByDescending(x => x.Id)
  21941. .ToListAsync();
  21942. return Ok(JsonView(groupData, groupData.Count));
  21943. }
  21944. /// <summary>
  21945. /// 团组接待意见调查 - 信息管理
  21946. /// 列表
  21947. /// </summary>
  21948. /// <param name="groupId"></param>
  21949. /// <returns></returns>
  21950. [HttpGet("{groupId}")]
  21951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21952. public async Task<IActionResult> OpinionaireManageList(int groupId)
  21953. {
  21954. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21955. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  21956. .Select(x => new
  21957. {
  21958. x.Id,
  21959. x.TourGuideName,
  21960. x.CityName,
  21961. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  21962. x.CreateTime
  21963. })
  21964. .OrderBy(x => x.Id)
  21965. .ToListAsync();
  21966. return Ok(JsonView(data));
  21967. }
  21968. /// <summary>
  21969. /// 团组接待意见调查 - 信息管理
  21970. /// 保存
  21971. /// </summary>
  21972. /// <param name="dto"></param>
  21973. /// <returns></returns>
  21974. [HttpPost]
  21975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21976. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  21977. {
  21978. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21979. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21980. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21981. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  21982. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  21983. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  21984. _opinionaireRep.BeginTran();
  21985. if (addData != null && addData.Count > 0)
  21986. {
  21987. foreach (var item in addData)
  21988. {
  21989. item.CreateUserId = currUserInfo.UserId;
  21990. item.DiId = dto.DiId;
  21991. }
  21992. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  21993. }
  21994. if (updData != null && updData.Count > 0)
  21995. {
  21996. var upd = await _opinionaireRep._sqlSugar
  21997. .Updateable(updData)
  21998. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  21999. .WhereColumns(x => new { x.Id })
  22000. .ExecuteCommandAsync();
  22001. }
  22002. _opinionaireRep.CommitTran();
  22003. return Ok(JsonView("操作成功!"));
  22004. }
  22005. /// <summary>
  22006. /// 团组接待意见调查 - 信息管理
  22007. /// 删除
  22008. /// </summary>
  22009. /// <param name="id"></param>
  22010. /// <returns></returns>
  22011. [HttpDelete("{id}")]
  22012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22013. public async Task<IActionResult> OpinionaireManageDel(int id)
  22014. {
  22015. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22016. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22017. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22018. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22019. if (!del) return Ok(JsonView("操作失败!"));
  22020. return Ok(JsonView("操作成功!"));
  22021. }
  22022. /// <summary>
  22023. /// 团组接待意见调查 - 用户
  22024. /// 列表
  22025. /// </summary>
  22026. /// <param name="diId"></param>
  22027. /// <returns></returns>
  22028. [HttpGet("{diId}")]
  22029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22030. public async Task<IActionResult> OpinionaireUserList(int diId)
  22031. {
  22032. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22033. var sql = string.Format(@"
  22034. SELECT
  22035. o.Id,
  22036. o.DiId,
  22037. di.TeamName AS 'GroupName',
  22038. di.VisitPNumber AS 'PeopleNumber',
  22039. di.ClientName AS 'LeadGroup',
  22040. di.VisitCountry AS 'Travel',
  22041. di.VisitDays AS 'Days',
  22042. o.CityName,
  22043. o.TourGuideName,
  22044. o.Catering,
  22045. o.CateringReason,
  22046. o.Stay,
  22047. o.StayReason,
  22048. o.[Route],
  22049. o.RouteReason,
  22050. o.OfficialActivity,
  22051. o.OfficialActivityReason,
  22052. o.TourGuide,
  22053. o.TourGuideReason,
  22054. o.[Translate],
  22055. o.TranslateReason,
  22056. o.Trip,
  22057. o.TripReason,
  22058. o.ESFileName,
  22059. o.SignatureDate,
  22060. o.Remark
  22061. FROM
  22062. Grp_Opinionaire o
  22063. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22064. WHERE
  22065. o.IsDel = 0
  22066. AND o.DiId = {0}
  22067. ORDER BY
  22068. o.Id ASC", diId);
  22069. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22070. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22071. return Ok(JsonView(data));
  22072. }
  22073. /// <summary>
  22074. /// 团组接待意见调查 - 用户
  22075. /// 保存
  22076. /// </summary>
  22077. /// <param name="dto"></param>
  22078. /// <returns></returns>
  22079. [HttpPost]
  22080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22081. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22082. {
  22083. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22084. foreach (var item in dto)
  22085. {
  22086. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22087. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22088. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22089. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22090. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22091. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22092. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22093. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22094. }
  22095. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22096. if (!Directory.Exists(filePathBase))
  22097. {
  22098. Directory.CreateDirectory(filePathBase);
  22099. }
  22100. #region 上传文件
  22101. var filePaths = new List<string>();
  22102. foreach (var item in dto)
  22103. {
  22104. var file = item.File;
  22105. // 将文件保存到指定位置
  22106. var filePath = Path.Combine(filePathBase, file.FileName);
  22107. using (var stream = new FileStream(filePath, FileMode.Create))
  22108. {
  22109. await file.CopyToAsync(stream);
  22110. }
  22111. //验证文件是否上传成功
  22112. if (!System.IO.File.Exists(filePath))
  22113. {
  22114. foreach (var filePathStr in filePaths)
  22115. {
  22116. System.IO.File.Delete(filePathStr);
  22117. }
  22118. return Ok(JsonView(false, "文件上传失败!"));
  22119. }
  22120. item.ESFileName = file.FileName;
  22121. }
  22122. #endregion
  22123. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22124. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22125. .UpdateColumns(x => new
  22126. {
  22127. x.Catering,
  22128. x.CateringReason,
  22129. x.Stay,
  22130. x.StayReason,
  22131. x.Route,
  22132. x.RouteReason,
  22133. x.OfficialActivity,
  22134. x.OfficialActivityReason,
  22135. x.TourGuide,
  22136. x.TourGuideReason,
  22137. x.Translate,
  22138. x.TranslateReason,
  22139. x.Trip,
  22140. x.TripReason,
  22141. x.ESFileName,
  22142. x.SignatureDate,
  22143. x.Remark
  22144. })
  22145. .WhereColumns(x => new { x.Id })
  22146. .ExecuteCommandAsync();
  22147. if (upd < 1)
  22148. {
  22149. foreach (var filePathStr in filePaths)
  22150. {
  22151. System.IO.File.Delete(filePathStr);
  22152. }
  22153. return Ok(JsonView(false));
  22154. }
  22155. return Ok(JsonView(true));
  22156. }
  22157. #endregion
  22158. #region 团组餐厅相关信息
  22159. /// <summary>
  22160. /// 团组相关餐厅信息
  22161. /// 基础数据(团组)
  22162. /// </summary>
  22163. /// <returns></returns>
  22164. [HttpGet]
  22165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22166. public async Task<IActionResult> RestaurantInit()
  22167. {
  22168. return Ok(await _restaurantRep.InitAsync());
  22169. }
  22170. /// <summary>
  22171. /// 团组相关餐厅信息
  22172. /// Item
  22173. /// </summary>
  22174. /// <param name="dto"></param>
  22175. /// <returns></returns>
  22176. [HttpPost]
  22177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22178. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22179. {
  22180. int portType = dto.PortType,
  22181. groupId = dto.GroupId;
  22182. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22183. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22184. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22185. }
  22186. /// <summary>
  22187. /// 团组相关餐厅信息
  22188. /// List
  22189. /// </summary>
  22190. /// <param name="dto"></param>
  22191. /// <returns></returns>
  22192. [HttpPost]
  22193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22194. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22195. {
  22196. int portType = dto.PortType,
  22197. groupId = dto.GroupId;
  22198. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22199. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22200. var sql = string.Format(@" SELECT
  22201. ri.Id,
  22202. ri.GroupId,
  22203. ri.Date,
  22204. ri.StartTime,
  22205. ri.EndTime,
  22206. CASE WHEN ri.Type = 1 THEN '早餐'
  22207. WHEN ri.Type = 2 THEN '午餐'
  22208. WHEN ri.Type = 3 THEN '晚餐'
  22209. ELSE '其他'
  22210. END AS 'Type',
  22211. ri.Name,
  22212. ri.Address,
  22213. ri.Tel,
  22214. ri.Remark,
  22215. ri.CreateTime,
  22216. u.CnName AS CreateUserName
  22217. FROM
  22218. Grp_RestaurantInfo ri
  22219. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22220. WHERE
  22221. ri.IsDel = 0
  22222. AND ri.GroupId = {0}
  22223. ORDER BY
  22224. ri.Date ASC
  22225. ", groupId);
  22226. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22227. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22228. return Ok(JsonView(infos));
  22229. }
  22230. /// <summary>
  22231. /// 团组相关餐厅信息
  22232. /// Info
  22233. /// </summary>
  22234. /// <param name="dto"></param>
  22235. /// <returns></returns>
  22236. [HttpPost]
  22237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22238. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  22239. {
  22240. int portType = dto.PortType,
  22241. id = dto.Id;
  22242. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22243. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22244. return Ok(await _restaurantRep.InfoAsync(portType, id));
  22245. }
  22246. /// <summary>
  22247. /// 团组相关餐厅信息
  22248. /// Op
  22249. /// </summary>
  22250. /// <param name="dto"></param>
  22251. /// <returns></returns>
  22252. [HttpPost]
  22253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22254. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  22255. {
  22256. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22257. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22258. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22259. return Ok(await _restaurantRep.OpAsync(dto));
  22260. }
  22261. /// <summary>
  22262. /// 团组相关餐厅信息
  22263. /// Del
  22264. /// </summary>
  22265. /// <param name="dto"></param>
  22266. /// <returns></returns>
  22267. [HttpPost]
  22268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22269. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22270. {
  22271. int userId = dto.DeleteUserId;
  22272. var id = dto.Id;
  22273. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22274. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22275. return Ok(await _restaurantRep.DelAsync(dto));
  22276. }
  22277. #endregion
  22278. /// <summary>
  22279. /// 123132123
  22280. /// </summary>
  22281. /// <param name="_dto"></param>
  22282. /// <returns></returns>
  22283. [HttpPost]
  22284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22285. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22286. {
  22287. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22288. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  22289. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  22290. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22291. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  22292. dicDetail.Add(789, 1034);
  22293. dicDetail.Add(790, 1035);
  22294. dicDetail.Add(791, 1036);
  22295. dicDetail.Add(792, 1037);
  22296. dicDetail.Add(793, 1038);
  22297. dicDetail.Add(794, 1039);
  22298. dicDetail.Add(795, 1040);
  22299. dicDetail.Add(796, 1041);
  22300. dicDetail.Add(797, 1042);
  22301. dicDetail.Add(798, 1043);
  22302. dicDetail.Add(801, 1044);
  22303. dicDetail.Add(802, 1045);
  22304. dicDetail.Add(803, 1046);
  22305. Dictionary<int, int> dic = new Dictionary<int, int>();
  22306. dic.Add(806, 1027);
  22307. dic.Add(807, 1028);
  22308. dic.Add(808, 1029);
  22309. dic.Add(809, 1030);
  22310. dic.Add(810, 1031);
  22311. dic.Add(811, 1032);
  22312. dic.Add(812, 1033);
  22313. foreach (var item in list_visa)
  22314. {
  22315. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  22316. temp.Coefficient = item.coefficient;
  22317. DateTime dtCrt;
  22318. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  22319. if (b1)
  22320. {
  22321. temp.CreateTime = dtCrt;
  22322. }
  22323. else
  22324. {
  22325. temp.CreateTime = DateTime.Now;
  22326. }
  22327. temp.CreateUserId = item.Operators;
  22328. temp.DeleteTime = "";
  22329. temp.DeleteUserId = 0;
  22330. temp.DiId = int.Parse(item.DIID);
  22331. temp.FilePath = item.FilePath;
  22332. temp.IsDel = item.IsDel;
  22333. temp.Price = item.Price;
  22334. temp.PriceCount = 1;
  22335. temp.PriceCurrency = item.Currency;
  22336. int detailId = 0;
  22337. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  22338. {
  22339. detailId = dicDetail[item.PriceTypeDetail];
  22340. }
  22341. temp.PriceDetailType = detailId;
  22342. temp.PriceDt = DateTime.Now;
  22343. temp.PriceName = item.PriceName;
  22344. temp.PriceSum = item.Price;
  22345. int tid = 0;
  22346. if (dic.ContainsKey(item.PriceType))
  22347. {
  22348. tid = dic[item.PriceType];
  22349. }
  22350. temp.PriceType = tid;
  22351. temp.Remark = item.Remark;
  22352. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  22353. }
  22354. return Ok(JsonView(true, "操作成功!"));
  22355. }
  22356. [HttpPost]
  22357. public IActionResult TimeTest()
  22358. {
  22359. var jw = JsonView(false, "error");
  22360. _sqlSugar.BeginTran();
  22361. try
  22362. {
  22363. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  22364. .Select(x => new Crm_NewClientData
  22365. {
  22366. Id = x.Id,
  22367. Client = x.Client,
  22368. Contact = x.Contact,
  22369. Location = x.Location,
  22370. })
  22371. .ToList();
  22372. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  22373. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  22374. Stopwatch stopwatch = new Stopwatch();
  22375. // 开始计时
  22376. stopwatch.Start();
  22377. foreach (var item in clientList)
  22378. {
  22379. EncryptionProcessor.DecryptProperties(item);
  22380. }
  22381. stopwatch.Stop();
  22382. jw.Code = 200;
  22383. jw.Data = stopwatch.ElapsedMilliseconds;
  22384. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  22385. }
  22386. catch (Exception ex)
  22387. {
  22388. jw.Code = 400;
  22389. jw.Msg = ex.Message;
  22390. }
  22391. return Ok(jw);
  22392. }
  22393. }
  22394. }