GroupsController.cs 1.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Dm.util;
  7. using Microsoft.AspNetCore.SignalR;
  8. using NPOI.SS.UserModel;
  9. using NPOI.SS.Util;
  10. using NPOI.XSSF.UserModel;
  11. using OASystem.API.Middlewares;
  12. using OASystem.API.OAMethodLib;
  13. using OASystem.API.OAMethodLib.APNs;
  14. using OASystem.API.OAMethodLib.File;
  15. using OASystem.API.OAMethodLib.Hub.HubClients;
  16. using OASystem.API.OAMethodLib.Hub.Hubs;
  17. using OASystem.API.OAMethodLib.JuHeAPI;
  18. using OASystem.API.OAMethodLib.KiMiApi;
  19. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  20. using OASystem.Domain.AesEncryption;
  21. using OASystem.Domain.Attributes;
  22. using OASystem.Domain.Dtos.CRM;
  23. using OASystem.Domain.Dtos.FileDto;
  24. using OASystem.Domain.Dtos.Financial;
  25. using OASystem.Domain.Dtos.Groups;
  26. using OASystem.Domain.Entities.Customer;
  27. using OASystem.Domain.Entities.Financial;
  28. using OASystem.Domain.Entities.Groups;
  29. using OASystem.Domain.ViewModels.CRM;
  30. using OASystem.Domain.ViewModels.Financial;
  31. using OASystem.Domain.ViewModels.Groups;
  32. using OASystem.Domain.ViewModels.OCR;
  33. using OASystem.Infrastructure.Repositories.CRM;
  34. using OASystem.Infrastructure.Repositories.Financial;
  35. using OASystem.Infrastructure.Repositories.Groups;
  36. using Quartz.Util;
  37. using SqlSugar.Extensions;
  38. using System.Collections;
  39. using System.Data;
  40. using System.Diagnostics;
  41. using System.Globalization;
  42. using System.IO.Compression;
  43. using System.Text.Json;
  44. using System.Web;
  45. using static OASystem.API.OAMethodLib.JWTHelper;
  46. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  47. using Bookmark = Aspose.Words.Bookmark;
  48. using Cell = Aspose.Words.Tables.Cell;
  49. using Table = Aspose.Words.Tables.Table;
  50. namespace OASystem.API.Controllers
  51. {
  52. /// <summary>
  53. /// 团组相关
  54. /// </summary>
  55. //[Authorize]
  56. [Route("api/[controller]/[action]")]
  57. public class GroupsController : ControllerBase
  58. {
  59. private readonly ILogger<GroupsController> _logger;
  60. private readonly GrpScheduleRepository _grpScheduleRep;
  61. private readonly IMapper _mapper;
  62. private readonly DelegationInfoRepository _groupRepository;
  63. private readonly TaskAssignmentRepository _taskAssignmentRep;
  64. private readonly AirTicketResRepository _airTicketResRep;
  65. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  66. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  67. private readonly DelegationEnDataRepository _delegationEnDataRep;
  68. private readonly DelegationVisaRepository _delegationVisaRep;
  69. private readonly VisaPriceRepository _visaPriceRep;
  70. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  71. private readonly HotelPriceRepository _hotelPriceRep;
  72. private readonly CustomersRepository _customersRep;
  73. private readonly MessageRepository _message;
  74. private readonly SqlSugarClient _sqlSugar;
  75. private readonly TourClientListRepository _tourClientListRep;
  76. private readonly TeamRateRepository _teamRateRep;
  77. #region 成本相关
  78. private readonly CheckBoxsRepository _checkBoxs;
  79. private readonly GroupCostRepository _GroupCostRepository;
  80. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  81. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  82. #endregion
  83. private readonly SetDataRepository _setDataRep;
  84. private string url;
  85. private string path;
  86. private readonly EnterExitCostRepository _enterExitCostRep;
  87. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  88. private readonly UsersRepository _usersRep;
  89. private readonly IJuHeApiService _juHeApi;
  90. private readonly InvertedListRepository _invertedListRep;
  91. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  92. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  93. private readonly ThreeCodeRepository _threeCodeRepository;
  94. private readonly HotelInquiryRepository _hotelInquiryRep;
  95. private readonly FeeAuditRepository _feeAuditRep;
  96. private readonly VisaCommissionRepository _visaCommissionRep;
  97. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  98. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  99. private readonly List<CurrencyInfo> _currencyInit;
  100. private readonly List<int> _portTypeData;
  101. private readonly TableOperationRecordRepository _tableorRep;
  102. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  103. private readonly RestaurantRepository _restaurantRep;
  104. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  105. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  106. /// <summary>
  107. /// 构造函数
  108. /// </summary>
  109. /// <param name="logger"></param>
  110. /// <param name="mapper"></param>
  111. /// <param name="hubContext"></param>
  112. /// <param name="sqlSugar"></param>
  113. /// <param name="grpScheduleRep"></param>
  114. /// <param name="groupRepository"></param>
  115. /// <param name="taskAssignmentRep"></param>
  116. /// <param name="airTicketResRep"></param>
  117. /// <param name="decreasePaymentsRep"></param>
  118. /// <param name="InvitationOfficialActivitiesRep"></param>
  119. /// <param name="delegationEnDataRep"></param>
  120. /// <param name="enterExitCostRep"></param>
  121. /// <param name="delegationVisaRep"></param>
  122. /// <param name="message"></param>
  123. /// <param name="visaPriceRep"></param>
  124. /// <param name="carTouristGuideGroundRep"></param>
  125. /// <param name="checkBoxs"></param>
  126. /// <param name="GroupCostRepository"></param>
  127. /// <param name="CostTypeHotelNumberRepository"></param>
  128. /// <param name="GroupCostParameterRepository"></param>
  129. /// <param name="hotelPriceRep"></param>
  130. /// <param name="customersRep"></param>
  131. /// <param name="setDataRep"></param>
  132. /// <param name="tourClientListRep"></param>
  133. /// <param name="teamRateRep"></param>
  134. /// <param name="usersRep"></param>
  135. /// <param name="juHeApi"></param>
  136. /// <param name="invertedListRep"></param>
  137. /// <param name="visaFeeInfoRep"></param>
  138. /// <param name="ticketBlackCodeRep"></param>
  139. /// <param name="hotelInquiryRep"></param>
  140. /// <param name="threeCodeRepository"></param>
  141. /// <param name="feeAuditRep"></param>
  142. /// <param name="visaCommissionRep"></param>
  143. /// <param name="ffrRep"></param>
  144. /// <param name="opinionaireRep"></param>
  145. /// <param name="tableorRep"></param>
  146. /// <param name="enterExitCostDraftRep"></param>
  147. /// <param name="restaurantRep"></param>
  148. /// <param name="enterExitCostQuoteRep"></param>
  149. /// <param name="grpOrderPreInfoRep"></param>
  150. public GroupsController(
  151. ILogger<GroupsController> logger,
  152. IMapper mapper,
  153. IHubContext<ChatHub, IChatClient> hubContext,
  154. SqlSugarClient sqlSugar,
  155. GrpScheduleRepository grpScheduleRep,
  156. DelegationInfoRepository groupRepository,
  157. TaskAssignmentRepository taskAssignmentRep,
  158. AirTicketResRepository airTicketResRep,
  159. DecreasePaymentsRepository decreasePaymentsRep,
  160. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  161. DelegationEnDataRepository delegationEnDataRep,
  162. EnterExitCostRepository enterExitCostRep,
  163. DelegationVisaRepository delegationVisaRep,
  164. MessageRepository message,
  165. VisaPriceRepository visaPriceRep,
  166. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  167. CheckBoxsRepository checkBoxs,
  168. GroupCostRepository GroupCostRepository,
  169. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  170. GroupCostParameterRepository GroupCostParameterRepository,
  171. HotelPriceRepository hotelPriceRep,
  172. CustomersRepository customersRep,
  173. SetDataRepository setDataRep,
  174. TourClientListRepository tourClientListRep,
  175. TeamRateRepository teamRateRep,
  176. UsersRepository usersRep,
  177. IJuHeApiService juHeApi,
  178. InvertedListRepository invertedListRep,
  179. VisaFeeInfoRepository visaFeeInfoRep,
  180. TicketBlackCodeRepository ticketBlackCodeRep,
  181. HotelInquiryRepository hotelInquiryRep,
  182. ThreeCodeRepository threeCodeRepository,
  183. FeeAuditRepository feeAuditRep,
  184. VisaCommissionRepository visaCommissionRep,
  185. ForeignReceivablesRepository ffrRep,
  186. OpinionaireRepository opinionaireRep,
  187. TableOperationRecordRepository tableorRep,
  188. EnterExitCostDraftRepository enterExitCostDraftRep,
  189. RestaurantRepository restaurantRep,
  190. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  191. GroupOrderPreInfoRepository grpOrderPreInfoRep
  192. )
  193. {
  194. _logger = logger;
  195. _mapper = mapper;
  196. _grpScheduleRep = grpScheduleRep;
  197. _groupRepository = groupRepository;
  198. _taskAssignmentRep = taskAssignmentRep;
  199. _airTicketResRep = airTicketResRep;
  200. _sqlSugar = sqlSugar;
  201. url = AppSettingsHelper.Get("ExcelBaseUrl");
  202. path = AppSettingsHelper.Get("ExcelBasePath");
  203. if (!System.IO.Directory.Exists(path))
  204. {
  205. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  206. }
  207. _decreasePaymentsRep = decreasePaymentsRep;
  208. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  209. _delegationEnDataRep = delegationEnDataRep;
  210. _enterExitCostRep = enterExitCostRep;
  211. _delegationVisaRep = delegationVisaRep;
  212. _message = message;
  213. _visaPriceRep = visaPriceRep;
  214. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  215. _checkBoxs = checkBoxs;
  216. _GroupCostRepository = GroupCostRepository;
  217. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  218. _GroupCostParameterRepository = GroupCostParameterRepository;
  219. _hotelPriceRep = hotelPriceRep;
  220. _customersRep = customersRep;
  221. _setDataRep = setDataRep;
  222. _tourClientListRep = tourClientListRep;
  223. _teamRateRep = teamRateRep;
  224. _hubContext = hubContext;
  225. _usersRep = usersRep;
  226. _juHeApi = juHeApi;
  227. _invertedListRep = invertedListRep;
  228. _visaFeeInfoRep = visaFeeInfoRep;
  229. _ticketBlackCodeRep = ticketBlackCodeRep;
  230. _hotelInquiryRep = hotelInquiryRep;
  231. _threeCodeRepository = threeCodeRepository;
  232. _feeAuditRep = feeAuditRep;
  233. _visaCommissionRep = visaCommissionRep;
  234. _ffrRep = ffrRep;
  235. _opinionaireRep = opinionaireRep;
  236. _currencyInit = new List<CurrencyInfo>()
  237. {
  238. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  239. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  240. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  241. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  242. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  243. };
  244. _portTypeData = new List<int>() { 2, 3 };
  245. _tableorRep = tableorRep;
  246. _enterExitCostDraftRep = enterExitCostDraftRep;
  247. _restaurantRep = restaurantRep;
  248. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  249. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  250. }
  251. #region 流程管控
  252. /// <summary>
  253. /// 获取团组流程管控信息
  254. /// </summary>
  255. /// <param name="_jsonDto">查询参数</param>
  256. /// <returns></returns>
  257. [HttpPost]
  258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  259. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  260. {
  261. if (string.IsNullOrEmpty(_jsonDto.Paras))
  262. {
  263. return Ok(JsonView(false, "参数为空"));
  264. }
  265. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  266. if (_ScheduleDto != null)
  267. {
  268. if (_ScheduleDto.SearchType == 2)//获取列表
  269. {
  270. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  271. return Ok(JsonView(_grpScheduleViewList));
  272. }
  273. else//获取对象
  274. {
  275. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  276. if (_grpScheduleView != null)
  277. {
  278. return Ok(JsonView(_grpScheduleView));
  279. }
  280. }
  281. }
  282. else
  283. {
  284. return Ok(JsonView(false, "参数反序列化失败"));
  285. }
  286. return Ok(JsonView(false, "暂无数据!"));
  287. }
  288. /// <summary>
  289. /// 修改团组流程管控详细表数据
  290. /// </summary>
  291. /// <param name="dto"></param>
  292. /// <returns></returns>
  293. [HttpPost]
  294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  295. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  296. {
  297. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  298. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  299. .SetColumns(it => it.Duty == _detail.Duty)
  300. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  301. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  302. .SetColumns(it => it.JobContent == _detail.JobContent)
  303. .SetColumns(it => it.Remark == _detail.Remark)
  304. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  305. .Where(s => s.Id == dto.Id)
  306. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  307. .ExecuteCommandAsync();
  308. if (result > 0)
  309. {
  310. return Ok(JsonView(true, "保存成功!"));
  311. }
  312. return Ok(JsonView(false, "保存失败!"));
  313. }
  314. /// <summary>
  315. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  316. /// </summary>
  317. /// <param name="dto"></param>
  318. /// <returns></returns>
  319. [HttpPost]
  320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  321. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  322. {
  323. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  324. _detail.IsDel = 1;
  325. _detail.DeleteUserId = dto.Duty;
  326. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  327. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  328. .SetColumns(it => it.IsDel == _detail.IsDel)
  329. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  330. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  331. .Where(it => it.Id == dto.Id)
  332. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  333. //.WhereColumns(s => s.Id == dto.Id)
  334. .ExecuteCommandAsync();
  335. if (result > 0)
  336. {
  337. return Ok(JsonView(true, "删除成功!"));
  338. }
  339. return Ok(JsonView(false, "删除失败!"));
  340. }
  341. /// <summary>
  342. /// 增加团组流程管控详细表数据
  343. /// </summary>
  344. /// <param name="dto"></param>
  345. /// <returns></returns>
  346. [HttpPost]
  347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  348. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  349. {
  350. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  351. if (DateTime.Now < _detail.ExpectBeginDt)
  352. {
  353. _detail.StepStatus = 0;
  354. }
  355. else
  356. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  357. _detail.StepStatus = 1;
  358. }
  359. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  360. if (result > 0)
  361. {
  362. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  363. return Ok(JsonView(true, "添加成功!", _result));
  364. }
  365. return Ok(JsonView(false, "添加失败!"));
  366. }
  367. #endregion
  368. #region 团组前期信息
  369. /// <summary>
  370. /// 团组前期信息H5-URL(员工对应地址)
  371. /// </summary>
  372. /// <param name="name">用户名称</param>
  373. /// <returns></returns>
  374. [HttpGet]
  375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  376. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  377. {
  378. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  379. .Where(x => x.IsDel == 0)
  380. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  381. .OrderBy(x => x.Id)
  382. .Select(x => new
  383. {
  384. name = x.CnName,
  385. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  386. })
  387. .ToListAsync();
  388. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  389. }
  390. /// <summary>
  391. /// 团组前期信息 List
  392. /// </summary>
  393. /// <returns></returns>
  394. [HttpPost]
  395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  396. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  397. {
  398. var search = dto.Search;
  399. int[] nameTempIds = new int[] { 1, 12, 28 },
  400. countryTempIds = new int[] { 2, 13, 29 },
  401. daysTempIds = new int[] { 4, 15, 31 },
  402. ppNumTempIds = new int[] { 6 };
  403. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  404. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  405. .Where((opi, u) => opi.IsDel == 0)
  406. .OrderByDescending((opi, u) => opi.CreateTime)
  407. .Select((opi, u) => new GroupOrderPreInfoListView()
  408. {
  409. Id = opi.Id,
  410. Name = opi.Name,
  411. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  412. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  413. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  414. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  415. Operator = u.CnName,
  416. OperationTime = opi.CreateTime
  417. })
  418. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  419. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  420. .ToListAsync();
  421. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  422. int total = list.Count;
  423. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  424. var listPageData1 = listPageData
  425. .Skip((dto.PageIndex - 1) * dto.PageSize)
  426. .Take(dto.PageSize)
  427. .ToList();
  428. var infoIds = listPageData1.Select(x => x.Id).ToList();
  429. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  430. .Where(x => x.IsDel == 0 && x.STid == 109)
  431. .ToArrayAsync();
  432. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  433. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  434. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  435. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  436. .ToListAsync();
  437. foreach (var item in listPageData1)
  438. {
  439. var typeDatas1 = typeDatas.Select(x => new
  440. {
  441. x.Id,
  442. x.Name,
  443. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  444. }).ToArray();
  445. item.VersionDetails = typeDatas1;
  446. }
  447. return Ok(JsonView(listPageData1, listPageData1.Count));
  448. }
  449. /// <summary>
  450. /// 团组前期信息 Init
  451. /// </summary>
  452. /// <returns></returns>
  453. [HttpGet("{userId}")]
  454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  455. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  456. {
  457. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  458. }
  459. /// <summary>
  460. /// 国家数据源
  461. /// </summary>
  462. /// <param name="pageIndex">当前页码</param>
  463. /// <param name="pageSize">每页条数</param>
  464. /// <param name="search">查询条件</param>
  465. /// <returns></returns>
  466. [HttpGet]
  467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  468. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  469. {
  470. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  471. if (pageIndex == 0 && pageSize == 0)
  472. {
  473. //所有数据
  474. return Ok(JsonView(countrys, countrys.Count));
  475. }
  476. //分页
  477. int skip = (pageIndex - 1) * pageSize;
  478. int take = pageSize;
  479. if (!string.IsNullOrEmpty(search))
  480. {
  481. IEnumerable<char> charSequence = search.Select(c => c);
  482. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  483. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  484. return Ok(JsonView(pageData, pageResult1.Count));
  485. }
  486. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  487. return Ok(JsonView(pageResult2, countrys.Count));
  488. }
  489. /// <summary>
  490. /// 城市数据源
  491. /// </summary>
  492. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  493. /// <param name="pageIndex">当前页码</param>
  494. /// <param name="pageSize">每页条数</param>
  495. /// <param name="search">查询条件</param>
  496. /// <returns></returns>
  497. [HttpGet("{countryLabel}")]
  498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  499. public async Task<IActionResult> CityByCountry(
  500. string countryLabel,
  501. [FromQuery] int pageIndex,
  502. [FromQuery] int pageSize,
  503. [FromQuery] string search)
  504. {
  505. countryLabel = HttpUtility.UrlDecode(countryLabel);
  506. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  507. var citys = Array.Empty<string?>();
  508. if (countryList.Any())
  509. {
  510. var cityDatas = await _sqlSugar
  511. .Queryable<Grp_NationalTravelFee>()
  512. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  513. .ToArrayAsync();
  514. foreach (var item in cityDatas)
  515. {
  516. if (item.City.Contains("城市"))
  517. {
  518. item.City = item.Country + "-所有城市";
  519. }
  520. }
  521. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  522. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  523. }
  524. if (pageIndex == 0 && pageSize == 0)
  525. {
  526. //所有数据
  527. return Ok(JsonView(citys, citys?.Length ?? 0));
  528. }
  529. //分页
  530. int skip = (pageIndex - 1) * pageSize;
  531. int take = pageSize;
  532. if (!string.IsNullOrEmpty(search))
  533. {
  534. IEnumerable<char> charSequence = search.Select(c => c);
  535. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  536. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  537. return Ok(JsonView(pageData, pageResult1.Count));
  538. }
  539. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  540. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  541. }
  542. /// <summary>
  543. /// 团组前期信息 Info
  544. /// </summary>
  545. /// <param name="dto">Id</param>
  546. /// <param name="portType">Id</param>
  547. /// <returns></returns>
  548. [HttpGet("{Id}/{TempId}")]
  549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  550. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto, int portType = 1)
  551. {
  552. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  553. }
  554. /// <summary>
  555. /// 团组前期信息 移动端 Info
  556. /// </summary>
  557. /// <param name="dto">Id</param>
  558. /// <returns></returns>
  559. [HttpGet("{Id}/{TempId}")]
  560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  561. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  562. {
  563. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  564. }
  565. /// <summary>
  566. /// 团组前期信息 Save
  567. /// </summary>
  568. /// <param name="dto">Id</param>
  569. /// <returns></returns>
  570. [HttpPost]
  571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  572. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  573. {
  574. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  575. }
  576. /// <summary>
  577. /// 团组前期信息 Del
  578. /// </summary>
  579. /// <param name="dto">Id</param>
  580. /// <returns></returns>
  581. [HttpPost]
  582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  583. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  584. {
  585. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  586. }
  587. /// <summary>
  588. /// 团组前期信息 文件下载
  589. /// </summary>
  590. /// <param name="dto">Id</param>
  591. /// <returns></returns>
  592. [HttpGet("{Id}/{TempId}")]
  593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  594. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  595. {
  596. int id = dto.Id, tempId = dto.TempId;
  597. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  598. var data = view.Data as GrpOrderPreInfoView;
  599. #region Excel
  600. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  601. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  602. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  603. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  604. var fileNamePrefix = string.Empty;
  605. if (tempId == 1405)
  606. {
  607. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  608. fileNamePrefix = $"{data.Name}_无商邀版";
  609. }
  610. else if (tempId == 1406)
  611. {
  612. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  613. fileNamePrefix = $"{data.Name}_有商邀版";
  614. }
  615. else
  616. {
  617. //tempId == 1404 默认下载
  618. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  619. fileNamePrefix = $"{data.Name}_单接送机";
  620. }
  621. foreach (var item in data.Items)
  622. {
  623. var obj = item.NewValue;
  624. if (obj == null) item.OriginVal = "";
  625. else if (obj.Equals("有") || obj.Equals("无"))
  626. {
  627. item.OriginVal = obj.ToString();
  628. }
  629. else if (obj is object[] objArray)
  630. {
  631. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  632. item.OriginVal = string.Join("、", stringArray);
  633. }
  634. else if (obj is string[] stringArray)
  635. {
  636. item.OriginVal = string.Join("、", stringArray);
  637. }
  638. else if (obj.Equals("-"))
  639. {
  640. item.OriginVal = "";
  641. }
  642. }
  643. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  644. fileName = CommonFun.ValidFileName(fileName);
  645. //载入模板
  646. var designer = new WorkbookDesigner
  647. {
  648. Workbook = new Workbook(tempPath)
  649. };
  650. if (tempId == 1406)
  651. {
  652. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  653. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  654. for (int i = 1; i <= view2.Length; i++)
  655. {
  656. view2[i - 1].Index = i;
  657. }
  658. designer.SetDataSource("View1", view1);
  659. designer.SetDataSource("View2", view2);
  660. }
  661. else
  662. {
  663. designer.SetDataSource("View", data.Items);
  664. }
  665. designer.Process();
  666. if (!Directory.Exists(savePath))
  667. {
  668. Directory.CreateDirectory(savePath);
  669. }
  670. string serverPath = $"{savePath}{fileName}";
  671. designer.Workbook.Save(serverPath);
  672. string rst = $"{servicePath}{ftpPath}{fileName}";
  673. #endregion
  674. return Ok(JsonView(new { url = rst }));
  675. }
  676. #endregion
  677. #region 团组基本信息
  678. /// <summary>
  679. /// 接团信息列表
  680. /// </summary>
  681. /// <param name="dto">团组列表请求dto</param>
  682. /// <returns></returns>
  683. [HttpPost]
  684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  685. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  686. {
  687. var groupData = await _groupRepository.GetGroupList(dto);
  688. if (groupData.Code != 0)
  689. {
  690. return Ok(JsonView(false, groupData.Msg));
  691. }
  692. return Ok(JsonView(groupData.Data));
  693. }
  694. /// <summary>
  695. /// 分页查询团组列表
  696. /// </summary>
  697. /// <param name="dto"></param>
  698. /// <returns></returns>
  699. [HttpPost]
  700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  701. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  702. {
  703. var watch = new Stopwatch();
  704. watch.Start();
  705. RefAsync<int> total = 0;
  706. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  707. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  708. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  709. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  710. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  711. .Distinct()
  712. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  713. watch.Stop();
  714. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  715. }
  716. /// <summary>
  717. /// 接团信息列表 Page Init
  718. /// </summary>
  719. /// <returns></returns>
  720. [HttpPost]
  721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  722. public async Task<IActionResult> PostGroupPageListInit()
  723. {
  724. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  725. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  726. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  727. var _view = new
  728. {
  729. depData = depDatas,
  730. rankData = rankDatas
  731. };
  732. return Ok(JsonView(true, "查询成功!", _view));
  733. }
  734. /// <summary>
  735. /// 接团信息列表 Page
  736. /// </summary>
  737. /// <param name="dto">团组列表请求dto</param>
  738. /// <returns></returns>
  739. [HttpPost]
  740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  741. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  742. {
  743. #region 参数验证
  744. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  745. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  746. #region 页面操作权限验证
  747. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  748. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  749. #endregion
  750. #endregion
  751. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  752. {
  753. string sqlWhere = string.Empty;
  754. if (dto.IsSure == 0) //未完成
  755. {
  756. sqlWhere += string.Format(@" And IsSure = 0");
  757. }
  758. else if (dto.IsSure == 1) //已完成
  759. {
  760. sqlWhere += string.Format(@" And IsSure = 1");
  761. }
  762. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  763. {
  764. string tj = dto.SearchCriteria;
  765. 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}%')",
  766. tj, tj, tj, tj, tj);
  767. }
  768. if (int.TryParse(dto.Rank, out int rankId))
  769. {
  770. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  771. }
  772. string sqlWhere1 = string.Empty;
  773. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  774. {
  775. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  776. }
  777. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  778. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  779. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  780. JietuanOperator,IsSure,CreateTime,IsBid
  781. From (
  782. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  783. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  784. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  785. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  786. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  787. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  788. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  789. From Grp_DelegationInfo gdi
  790. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  791. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  792. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  793. Where gdi.IsDel = 0 {0}
  794. ) temp {1}", sqlWhere, sqlWhere1);
  795. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  796. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  797. //处理 团组模块实际操作人
  798. _DelegationList.ForEach(async x => {
  799. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  800. var operatorNames = new StringBuilder();
  801. //operatorNames.AppendLine("各模块实际操作人:");
  802. if (operators.Any())
  803. {
  804. operators.ForEach(y => {
  805. string label = string.Empty;
  806. if (y.OperationUsers.Any())
  807. {
  808. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  809. label = string.Join('、', users);
  810. }
  811. else label = "暂未指定";
  812. operatorNames.AppendLine($"{y.CTableName}:{label}");
  813. operatorNames.AppendLine();
  814. });
  815. }
  816. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  817. });
  818. var _view = new
  819. {
  820. PageFuncAuth = pageFunAuthView,
  821. Data = _DelegationList
  822. };
  823. return Ok(JsonView(true, "查询成功!", _view, total));
  824. }
  825. else
  826. {
  827. return Ok(JsonView(false, "查询失败"));
  828. }
  829. }
  830. /// <summary>
  831. /// 团组列表
  832. /// </summary>
  833. /// <returns></returns>
  834. [HttpPost]
  835. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  836. {
  837. #region 参数验证
  838. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  839. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  840. #region 页面操作权限验证
  841. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  842. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  843. #endregion
  844. #endregion
  845. if (dto.PortType != 1 && dto.PortType != 2)
  846. {
  847. return Ok(JsonView(false, "查询失败!"));
  848. }
  849. string orderbyStr = "order by gdi.CreateTime Desc";
  850. string sqlWhere = string.Empty;
  851. if (dto.IsSure == 0) //未完成
  852. {
  853. sqlWhere += string.Format(@" And IsSure = 0");
  854. }
  855. else if (dto.IsSure == 1) //已完成
  856. {
  857. sqlWhere += string.Format(@" And IsSure = 1");
  858. }
  859. //团组类型
  860. if (dto.TeamDid > 0)
  861. {
  862. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  863. }
  864. //团组名称
  865. if (!string.IsNullOrEmpty(dto.TeamName))
  866. {
  867. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  868. }
  869. //客户名称
  870. if (!string.IsNullOrEmpty(dto.ClientName))
  871. {
  872. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  873. }
  874. //客户单位
  875. if (!string.IsNullOrEmpty(dto.ClientUnit))
  876. {
  877. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  878. }
  879. //出访时间
  880. if (!string.IsNullOrEmpty(dto.visitDataTime))
  881. {
  882. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  883. orderbyStr = "order by gdi.VisitDate";
  884. }
  885. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  886. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  887. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  888. JietuanOperator,IsSure,CreateTime
  889. From (
  890. Select row_number() over({0}) as Row_Number,
  891. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  892. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  893. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  894. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  895. From Grp_DelegationInfo gdi
  896. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  897. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  898. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  899. Where gdi.IsDel = 0 {1}
  900. ) temp ", orderbyStr, sqlWhere);
  901. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  902. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  903. #region 处理所属部门
  904. /*
  905. * 1.sq 和 gyy 等显示 市场部
  906. * 2.王鸽和主管及张总还有管理员号统一国交部
  907. * 2-1. 4 管理员 ,21 张海麟
  908. */
  909. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  910. var userIds1 = new List<int>() { 4, 21 };
  911. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  912. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  913. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  914. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  915. .ToList();
  916. foreach (var item in _DelegationList)
  917. {
  918. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  919. }
  920. #endregion
  921. var _view = new
  922. {
  923. PageFuncAuth = pageFunAuthView,
  924. Data = _DelegationList
  925. };
  926. return Ok(JsonView(true, "查询成功!", _view, total));
  927. }
  928. /// <summary>
  929. /// 接团信息详情
  930. /// </summary>
  931. /// <param name="dto">团组info请求dto</param>
  932. /// <returns></returns>
  933. [HttpPost]
  934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  935. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  936. {
  937. var groupData = await _groupRepository.GetGroupInfo(dto);
  938. if (groupData.Code != 0)
  939. {
  940. return Ok(JsonView(false, groupData.Msg));
  941. }
  942. return Ok(JsonView(groupData.Data));
  943. }
  944. /// <summary>
  945. /// 接团信息 编辑添加
  946. /// 基础信息数据源
  947. /// </summary>
  948. /// <param name="dto"></param>
  949. /// <returns></returns>
  950. [HttpPost]
  951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  952. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  953. {
  954. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  955. if (groupData.Code != 0)
  956. {
  957. return Ok(JsonView(false, groupData.Msg));
  958. }
  959. return Ok(JsonView(groupData.Data));
  960. }
  961. /// <summary>
  962. /// 成本修改团组信息
  963. /// </summary>
  964. /// <param name="dto"></param>
  965. /// <returns></returns>
  966. [HttpPost]
  967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  968. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  969. {
  970. var jw = JsonView(false, "操作失败");
  971. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  972. if (di == null)
  973. {
  974. jw.Msg = "参数有误!";
  975. return Ok(jw);
  976. }
  977. #region 添加出访起止时间
  978. var startTime = new DateTime();
  979. var endTime = new DateTime();
  980. if (DateTime.TryParse(dto.VisitDate, out startTime))
  981. {
  982. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  983. }
  984. else
  985. {
  986. jw.Msg = "参数有误!";
  987. return Ok(jw);
  988. }
  989. #endregion
  990. di.VisitDate = startTime;
  991. di.VisitPNumber = dto.VisitPNumber;
  992. di.VisitDays = dto.VisitDays;
  993. di.VisitStartDate = startTime;
  994. di.VisitEndDate = endTime;
  995. var count = _sqlSugar.Updateable(di)
  996. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  997. .ExecuteCommand();
  998. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  999. }
  1000. /// <summary>
  1001. /// 接团信息 编辑添加
  1002. /// 省份-城市 基础信息数据源
  1003. /// </summary>
  1004. /// <param name="dto"></param>
  1005. /// <returns></returns>
  1006. [HttpPost]
  1007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1008. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1009. {
  1010. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1011. string search = dto.Search;
  1012. var data = await _groupRepository.CityBasicSource();
  1013. int total = data.Length;
  1014. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1015. .Skip((pageIndex - 1) * pageSize)
  1016. .Take(pageSize)
  1017. .ToArray();
  1018. return Ok(JsonView(data, total));
  1019. }
  1020. /// <summary>
  1021. /// 接团信息 操作(增改)
  1022. /// </summary>
  1023. /// <param name="dto"></param>
  1024. /// <returns></returns>
  1025. [HttpPost]
  1026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1027. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1028. {
  1029. // 创建 Stopwatch 实例
  1030. Stopwatch stopwatch = Stopwatch.StartNew();
  1031. decimal ffrPrice = 0.00M;
  1032. DateTime? visitDt = null;
  1033. if (dto.Status == 2)
  1034. {
  1035. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1036. if (groupInfo != null)
  1037. {
  1038. ffrPrice = groupInfo.PaymentMoney;
  1039. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1040. }
  1041. }
  1042. var groupData = await _groupRepository.GroupOperation(dto);
  1043. if (groupData.Code != 0)
  1044. {
  1045. return Ok(JsonView(false, groupData.Msg));
  1046. }
  1047. int diId = 0;
  1048. try
  1049. {
  1050. //添加时 默认加入团组汇率
  1051. if (dto.Status == 1) //添加
  1052. {
  1053. diId = groupData.Data;
  1054. //添加默认币种
  1055. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1056. //默认分配权限
  1057. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1058. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1059. var _managerIds = new List<int>() { 22, 32, 21 };
  1060. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1061. if (userIds.Count > 0)
  1062. {
  1063. userIds.Add(208);
  1064. //创建团组管控
  1065. GroupStepForDelegation.CreateWorkStep(diId);
  1066. //发送消息
  1067. string groupName = dto.TeamName;
  1068. string createGroupUser = string.Empty;
  1069. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1070. if (userInfo != null) createGroupUser = userInfo.CnName;
  1071. string title = $"系统通知";
  1072. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1073. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1074. }
  1075. //默认创建倒推表
  1076. await _invertedListRep._Create(dto.UserId, diId);
  1077. }
  1078. else if (dto.Status == 2)
  1079. {
  1080. diId = dto.Id;
  1081. }
  1082. #region 签证人员团组时间通知
  1083. #region 计算出访起止时间
  1084. var startTime = new DateTime();
  1085. var endTime = new DateTime();
  1086. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1087. {
  1088. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1089. }
  1090. #endregion
  1091. #endregion
  1092. #region 团组操作默认添加/修改收款账单
  1093. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1094. {
  1095. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1096. .Where(x => x.IsDel == 0 &&
  1097. x.Diid == diId &&
  1098. x.Remark.Equals("预付款")
  1099. )
  1100. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1101. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1102. .FirstAsync();
  1103. ffrInfo = new Fin_ForeignReceivables()
  1104. {
  1105. Diid = diId,
  1106. PriceName = dto.ClientUnit,
  1107. Price = dto.PaymentMoney,
  1108. Count = 1,
  1109. Unit = $"元",
  1110. ItemSumPrice = dto.PaymentMoney,
  1111. Rate = 1.0000M,
  1112. Currency = 836,
  1113. AddingWay = 0,
  1114. CreateUserId = dto.UserId,
  1115. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1116. Remark = $"预付款"
  1117. };
  1118. if (ffrInfo == null) //Add
  1119. {
  1120. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1121. }
  1122. else //修改
  1123. {
  1124. await _sqlSugar.Updateable(ffrInfo)
  1125. .UpdateColumns(x => new
  1126. {
  1127. x.PriceName,
  1128. x.Price,
  1129. x.ItemSumPrice,
  1130. x.CreateTime,
  1131. x.CreateUserId
  1132. })
  1133. .WhereColumns(x => x.Id)
  1134. .ExecuteCommandAsync();
  1135. }
  1136. }
  1137. #endregion
  1138. if (diId > 0)
  1139. {
  1140. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1141. }
  1142. // 停止计时
  1143. stopwatch.Stop();
  1144. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1145. }
  1146. catch (Exception ex)
  1147. {
  1148. // 停止计时
  1149. stopwatch.Stop();
  1150. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1151. Logs(ex.Message);
  1152. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1153. }
  1154. // 停止计时
  1155. stopwatch.Stop();
  1156. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1157. }
  1158. /// <summary>
  1159. /// 接团流程操作(增改)
  1160. /// 安卓端使用 建团时添加客户名单
  1161. /// </summary>
  1162. /// <param name="dto"></param>
  1163. /// <returns></returns>
  1164. [HttpPost]
  1165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1166. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1167. {
  1168. #region 参数验证
  1169. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1170. #region 页面操作权限验证
  1171. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1172. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1173. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1174. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1175. #endregion
  1176. #endregion
  1177. try
  1178. {
  1179. //_sqlSugar.BeginTran();
  1180. decimal ffrPrice = 0.00M;
  1181. DateTime? visitDt = null;
  1182. if (dto.Status == 2)
  1183. {
  1184. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1185. if (groupInfo != null)
  1186. {
  1187. ffrPrice = groupInfo.PaymentMoney;
  1188. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1189. }
  1190. }
  1191. var _dto = new GroupOperationDto();
  1192. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1193. var groupData = await _groupRepository.GroupOperation(_dto);
  1194. if (groupData.Code != 0)
  1195. {
  1196. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1197. }
  1198. int diId = 0;
  1199. //添加时 默认加入团组汇率
  1200. if (dto.Status == 1) //添加
  1201. {
  1202. diId = groupData.Data;
  1203. //添加默认币种
  1204. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1205. //默认分配权限
  1206. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1207. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1208. var _managerIds = new List<int>() { 21, 22, 32 };
  1209. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1210. if (userIds.Count > 0)
  1211. {
  1212. userIds.Add(208);
  1213. //创建团组管控
  1214. GroupStepForDelegation.CreateWorkStep(diId);
  1215. //发送消息
  1216. string groupName = dto.TeamName;
  1217. string createGroupUser = string.Empty;
  1218. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1219. if (userInfo != null) createGroupUser = userInfo.CnName;
  1220. string title = $"系统通知";
  1221. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1222. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1223. }
  1224. #region 应用推送
  1225. try
  1226. {
  1227. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1228. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1229. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1230. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1231. {
  1232. var userList = new List<string>() { users.QiyeChatUserId };
  1233. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1234. }
  1235. }
  1236. catch (Exception ex)
  1237. {
  1238. }
  1239. #endregion
  1240. //默认创建倒推表
  1241. await _invertedListRep._Create(dto.UserId, diId);
  1242. }
  1243. if (dto.Status == 2)
  1244. {
  1245. diId = dto.Id;
  1246. if (diId == 0)
  1247. {
  1248. //_sqlSugar.RollbackTran();
  1249. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1250. }
  1251. }
  1252. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1253. if (viewData.Code != 0)
  1254. {
  1255. //_sqlSugar.RollbackTran();
  1256. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1257. }
  1258. #region 团组操作默认添加/修改收款账单
  1259. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1260. {
  1261. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1262. .Where(x => x.IsDel == 0 &&
  1263. x.Diid == diId &&
  1264. x.Remark.Equals("预付款")
  1265. )
  1266. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1267. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1268. .FirstAsync();
  1269. ffrInfo = new Fin_ForeignReceivables()
  1270. {
  1271. Diid = diId,
  1272. PriceName = dto.ClientUnit,
  1273. Price = dto.PaymentMoney,
  1274. Count = 1,
  1275. Unit = $"元",
  1276. ItemSumPrice = dto.PaymentMoney,
  1277. Rate = 1.0000M,
  1278. Currency = 836,
  1279. AddingWay = 0,
  1280. CreateUserId = dto.UserId,
  1281. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1282. Remark = $"预付款"
  1283. };
  1284. if (ffrInfo == null) //Add
  1285. {
  1286. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1287. }
  1288. else //修改
  1289. {
  1290. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1291. .UpdateColumns(x => new
  1292. {
  1293. x.PriceName,
  1294. x.Price,
  1295. x.ItemSumPrice,
  1296. x.CreateTime,
  1297. x.CreateUserId
  1298. })
  1299. .WhereColumns(x => x.Id)
  1300. .ExecuteCommandAsync();
  1301. }
  1302. }
  1303. #endregion
  1304. #region 签证人员团组时间通知
  1305. #region 计算出访起止时间
  1306. var startTime = new DateTime();
  1307. var endTime = new DateTime();
  1308. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1309. {
  1310. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1311. }
  1312. #endregion
  1313. if (diId > 0)
  1314. {
  1315. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1316. }
  1317. #endregion
  1318. //_sqlSugar.CommitTran();
  1319. return Ok(JsonView(true, "添加成功"));
  1320. }
  1321. catch (Exception ex)
  1322. {
  1323. _sqlSugar.RollbackTran();
  1324. return Ok(JsonView(false, ex.Message));
  1325. }
  1326. }
  1327. /// <summary>
  1328. /// 接团流程操作(增改)
  1329. /// 安卓端使用 建团时添加客户名单
  1330. /// </summary>
  1331. /// <param name="dto"></param>
  1332. /// <returns></returns>
  1333. [HttpPost]
  1334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1335. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1336. {
  1337. #region 参数验证
  1338. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1339. #region 页面操作权限验证
  1340. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1341. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1342. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1343. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1344. #endregion
  1345. #endregion
  1346. _sqlSugar.BeginTran();
  1347. decimal ffrPrice = 0.00M;
  1348. DateTime? visitDt = null;
  1349. if (dto.Status == 2)
  1350. {
  1351. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1352. if (groupInfo != null)
  1353. {
  1354. ffrPrice = groupInfo.PaymentMoney;
  1355. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1356. }
  1357. }
  1358. var _dto = new GroupOperationDto();
  1359. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1360. var groupData = await _groupRepository.GroupOperation(_dto);
  1361. if (groupData.Code != 0)
  1362. {
  1363. _sqlSugar.RollbackTran();
  1364. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1365. }
  1366. try
  1367. {
  1368. int diId = 0;
  1369. //添加时 默认加入团组汇率
  1370. if (dto.Status == 1) //添加
  1371. {
  1372. diId = groupData.Data;
  1373. //添加默认币种
  1374. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1375. //默认分配权限
  1376. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1377. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1378. var _managerIds = new List<int>() { 21, 22, 32 };
  1379. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1380. if (userIds.Count > 0)
  1381. {
  1382. userIds.Add(208);
  1383. //创建团组管控
  1384. GroupStepForDelegation.CreateWorkStep(diId);
  1385. //发送消息
  1386. string groupName = dto.TeamName;
  1387. string createGroupUser = string.Empty;
  1388. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1389. if (userInfo != null) createGroupUser = userInfo.CnName;
  1390. string title = $"系统通知";
  1391. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1392. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1393. }
  1394. #region 应用推送
  1395. try
  1396. {
  1397. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1398. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1399. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1400. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1401. {
  1402. var userList = new List<string>() { users.QiyeChatUserId };
  1403. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1404. }
  1405. }
  1406. catch (Exception ex)
  1407. {
  1408. _sqlSugar.CommitTran();
  1409. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1410. }
  1411. #endregion
  1412. //默认创建倒推表
  1413. await _invertedListRep._Create(dto.UserId, diId);
  1414. }
  1415. else if (dto.Status == 2)
  1416. {
  1417. diId = dto.Id;
  1418. if (diId == 0)
  1419. {
  1420. _sqlSugar.RollbackTran();
  1421. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1422. }
  1423. }
  1424. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1425. if (viewData.Code != 0)
  1426. {
  1427. _sqlSugar.RollbackTran();
  1428. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1429. }
  1430. #region 团组操作默认添加/修改收款账单
  1431. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1432. {
  1433. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1434. .Where(x => x.IsDel == 0 &&
  1435. x.Diid == diId &&
  1436. x.Remark.Equals("预付款")
  1437. )
  1438. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1439. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1440. .FirstAsync();
  1441. ffrInfo = new Fin_ForeignReceivables()
  1442. {
  1443. Diid = diId,
  1444. PriceName = dto.ClientUnit,
  1445. Price = dto.PaymentMoney,
  1446. Count = 1,
  1447. Unit = $"元",
  1448. ItemSumPrice = dto.PaymentMoney,
  1449. Rate = 1.0000M,
  1450. Currency = 836,
  1451. AddingWay = 0,
  1452. CreateUserId = dto.UserId,
  1453. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1454. Remark = $"预付款"
  1455. };
  1456. if (ffrInfo == null) //Add
  1457. {
  1458. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1459. }
  1460. else //修改
  1461. {
  1462. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1463. .UpdateColumns(x => new
  1464. {
  1465. x.PriceName,
  1466. x.Price,
  1467. x.ItemSumPrice,
  1468. x.CreateTime,
  1469. x.CreateUserId
  1470. })
  1471. .WhereColumns(x => x.Id)
  1472. .ExecuteCommandAsync();
  1473. }
  1474. }
  1475. #endregion
  1476. #region 签证人员团组时间通知
  1477. #region 计算出访起止时间
  1478. var startTime = new DateTime();
  1479. var endTime = new DateTime();
  1480. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1481. {
  1482. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1483. }
  1484. #endregion
  1485. if (diId > 0)
  1486. {
  1487. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1488. }
  1489. #endregion
  1490. _sqlSugar.CommitTran();
  1491. return Ok(JsonView(true));
  1492. }
  1493. catch (Exception ex)
  1494. {
  1495. _sqlSugar.RollbackTran();
  1496. return Ok(JsonView(false, ex.Message));
  1497. }
  1498. }
  1499. /// <summary>
  1500. /// 接团信息 操作(删除)
  1501. /// </summary>
  1502. /// <param name="dto"></param>
  1503. /// <returns></returns>
  1504. [HttpPost]
  1505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1506. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1507. {
  1508. var diId = dto.Id;
  1509. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1510. #region 删除 验证
  1511. /*
  1512. * 1、收款账单数据:0 条
  1513. * 2、收款退还数据:0 条
  1514. * 3、机票费用数据:0 条
  1515. * 4、签证费用数据:0 条
  1516. * 5、保险费用数据:0 条
  1517. * 6、酒店费用数据:0 条
  1518. * 7、公务出访数据:1 条
  1519. * 8、邀请公务活动费用数据:1 条
  1520. * 9、OP费用数据:5 条
  1521. * 10、其他费用数据:0 条
  1522. * 11、团组日付报销费用数据:0 条
  1523. *
  1524. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1525. */
  1526. //收款账单
  1527. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1528. //收款退还
  1529. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1530. //机票费用
  1531. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1532. //签证费用
  1533. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1534. //保险费用
  1535. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1536. //酒店费用
  1537. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1538. //公务出访
  1539. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1540. //邀请公务活动费用
  1541. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1542. //OP费用
  1543. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1544. //其他费用
  1545. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1546. //团组日付报销费用
  1547. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1548. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1549. if (feeCount > 0)
  1550. {
  1551. var delMsgTips = new StringBuilder();
  1552. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1553. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1554. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1555. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1556. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1557. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1558. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1559. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1560. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1561. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1562. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1563. delMsgTips.AppendLine($"");
  1564. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1565. return Ok(JsonView(false, delMsgTips.ToString()));
  1566. }
  1567. #endregion
  1568. var groupData = await _groupRepository.GroupDel(dto);
  1569. if (groupData.Code != 0)
  1570. {
  1571. return Ok(JsonView(false, groupData.Msg));
  1572. }
  1573. return Ok(JsonView(true));
  1574. }
  1575. /// <summary>
  1576. /// 获取团组销售报价号
  1577. /// 团组添加时 使用
  1578. /// </summary>
  1579. /// <returns></returns>
  1580. [HttpPost]
  1581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1582. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1583. {
  1584. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1585. if (groupData.Code != 0)
  1586. {
  1587. return Ok(JsonView(false, groupData.Msg));
  1588. }
  1589. object salesQuoteNo = new
  1590. {
  1591. SalesQuoteNo = groupData.Data
  1592. };
  1593. return Ok(JsonView(salesQuoteNo));
  1594. }
  1595. /// <summary>
  1596. /// 设置确认出团
  1597. /// </summary>
  1598. /// <param name="dto"></param>
  1599. /// <returns></returns>
  1600. [HttpPost]
  1601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1602. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1603. {
  1604. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1605. if (groupData.Code != 0)
  1606. {
  1607. return Ok(JsonView(false, groupData.Msg));
  1608. }
  1609. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1610. #region OA消息推送
  1611. try
  1612. {
  1613. string groupName = groupInfo.TeamName;
  1614. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1615. string title = $"系统通知";
  1616. string content = $"团组[{groupName}]已确认出团!";
  1617. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1618. }
  1619. catch (Exception ex)
  1620. {
  1621. }
  1622. #endregion
  1623. #region 应用推送
  1624. try
  1625. {
  1626. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1627. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1628. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1629. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1630. {
  1631. var userList = new List<string>() { users.QiyeChatUserId };
  1632. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1633. }
  1634. }
  1635. catch (Exception ex)
  1636. {
  1637. }
  1638. #endregion
  1639. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1640. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1641. }
  1642. /// <summary>
  1643. /// 获取团组名称data And 签证国别Data
  1644. /// </summary>
  1645. /// <param name="dto"></param>
  1646. /// <returns></returns>
  1647. [HttpPost]
  1648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1649. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1650. {
  1651. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1652. if (groupData.Code != 0)
  1653. {
  1654. return Ok(JsonView(false, groupData.Msg));
  1655. }
  1656. return Ok(JsonView(groupData.Data));
  1657. }
  1658. /// <summary>
  1659. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1660. /// </summary>
  1661. /// <returns></returns>
  1662. [HttpPost]
  1663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1664. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1665. {
  1666. try
  1667. {
  1668. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1669. if (groupData.Code != 0)
  1670. {
  1671. return Ok(JsonView(false, groupData.Msg));
  1672. }
  1673. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1674. }
  1675. catch (Exception ex)
  1676. {
  1677. return Ok(JsonView(false, ex.Message));
  1678. throw;
  1679. }
  1680. }
  1681. /// <summary>
  1682. /// 团组清单 Excel
  1683. /// </summary>
  1684. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1685. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1686. /// <returns></returns>
  1687. [HttpGet]
  1688. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1689. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1690. {
  1691. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1692. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1693. if (!beginBool && !endBool)
  1694. {
  1695. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1696. }
  1697. string sql = string.Format(@"
  1698. SELECT
  1699. ROW_NUMBER,
  1700. Id,
  1701. SalesQuoteNo,
  1702. TourCode,
  1703. TeamTypeId,
  1704. TeamType,
  1705. TeamLevId,
  1706. TeamLev,
  1707. TeamName,
  1708. ClientName,
  1709. ClientUnit,
  1710. VisitDate,
  1711. VisitDays,
  1712. VisitPNumber,
  1713. JietuanOperatorId,
  1714. JietuanOperator,
  1715. IsSure,
  1716. CreateUserName,
  1717. IsBid
  1718. FROM
  1719. (
  1720. SELECT
  1721. ROW_NUMBER() OVER(
  1722. ORDER BY
  1723. gdi.VisitDate Desc
  1724. ) AS ROW_NUMBER,
  1725. gdi.Id,
  1726. SalesQuoteNo,
  1727. TourCode,
  1728. ssd.Id TeamTypeId,
  1729. ssd.Name TeamType,
  1730. ssd1.Id TeamLevId,
  1731. ssd1.Name TeamLev,
  1732. TeamName,
  1733. ClientName,
  1734. ClientUnit,
  1735. VisitDate,
  1736. VisitDays,
  1737. VisitPNumber,
  1738. JietuanOperator JietuanOperatorId,
  1739. su.CnName JietuanOperator,
  1740. IsSure,
  1741. gdi.CreateTime,
  1742. su1.CnName As CreateUserName,
  1743. gdi.IsBid
  1744. FROM
  1745. Grp_DelegationInfo gdi
  1746. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1747. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1748. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1749. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1750. WHERE
  1751. gdi.IsDel = 0
  1752. AND gdi.IsBid = 0
  1753. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1754. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1755. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1756. #region 处理所属部门
  1757. /*
  1758. * 1.sq 和 gyy 等显示 市场部
  1759. * 2.王鸽和主管及张总还有管理员号统一国交部
  1760. * 2-1. 4 管理员 ,21 张海麟
  1761. */
  1762. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1763. var userIds1 = new List<int>() { 4, 21 };
  1764. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1765. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1766. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1767. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1768. .ToListAsync();
  1769. var droupIds = groupList.Select(it => it.Id).ToList();
  1770. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1771. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1772. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1773. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1774. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1775. {
  1776. DiId = tcl.DiId,
  1777. LastName = dc.LastName,
  1778. FirstName = dc.FirstName,
  1779. Sex = dc.Sex,
  1780. Birthday = dc.BirthDay,
  1781. Company = cc.CompanyFullName,
  1782. Job = dc.Job,
  1783. CreateTime = tcl.CreateTime,
  1784. })
  1785. .ToList();
  1786. foreach (var item in groupList)
  1787. {
  1788. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1789. string groupFirstName = "";
  1790. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1791. if (currDatas.Any())
  1792. {
  1793. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1794. }
  1795. item.GroupFirst = groupFirstName;
  1796. }
  1797. #endregion
  1798. #region Excel
  1799. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1800. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1801. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1802. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1803. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1804. //载入模板
  1805. var designer = new WorkbookDesigner
  1806. {
  1807. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1808. };
  1809. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1810. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1811. dt.TableName = "GroupList";
  1812. designer.SetDataSource(dt);
  1813. designer.Process();
  1814. if (!Directory.Exists(savePath))
  1815. {
  1816. Directory.CreateDirectory(savePath);
  1817. }
  1818. string serverPath = $"{savePath}{fileName}";
  1819. designer.Workbook.Save(serverPath);
  1820. string rst = $"{servicePath}{ftpPath}{fileName}";
  1821. #endregion
  1822. return Ok(JsonView(true, "操作成功!", rst));
  1823. }
  1824. /// <summary>
  1825. /// 团组合同下载(1.付款80% 2.付全款)
  1826. /// </summary>
  1827. /// <param name="dto"></param>
  1828. /// <returns></returns>
  1829. /// <exception cref="Exception"></exception>
  1830. [HttpPost]
  1831. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1832. {
  1833. var jw = JsonView(false);
  1834. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1835. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1836. if (di == null)
  1837. {
  1838. jw.Msg = "团组Id有误!";
  1839. return Ok(jw);
  1840. }
  1841. #region 权限校验
  1842. var allDownFile = new List<int>() { 21 };
  1843. try
  1844. {
  1845. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1846. .First(x => x.Id == 1418 && x.IsDel == 0);
  1847. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1848. }
  1849. catch (Exception)
  1850. { }
  1851. var guojiaoDownFile = new List<int>() { 330 };
  1852. var shichangDownFile = new List<int>() { 95 };
  1853. if (allDownFile.Contains(dto.UserId))
  1854. {
  1855. }
  1856. else if (guojiaoDownFile.Contains(dto.UserId))
  1857. {
  1858. var guojiaobuDi = new List<int>() { 4, 21 };
  1859. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1860. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1861. .Where((d, u) => u.Id == di.JietuanOperator)
  1862. .Select((d, u) => d.DepName)
  1863. .First();
  1864. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1865. {
  1866. jw.Msg = "暂无下载权限!";
  1867. return Ok(jw);
  1868. }
  1869. }
  1870. else if (shichangDownFile.Contains(dto.UserId))
  1871. {
  1872. var dic = new Dictionary<int, int[]>()
  1873. {
  1874. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1875. };
  1876. try
  1877. {
  1878. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1879. if (sqSetting != null)
  1880. {
  1881. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1882. foreach (var item in result.Keys)
  1883. {
  1884. if (dic.ContainsKey(item))
  1885. {
  1886. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1887. Array.Copy(dic[item], dilatation, dic[item].Length);
  1888. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1889. dic[item] = dilatation;
  1890. }
  1891. else
  1892. {
  1893. dic.Add(item, result[item]);
  1894. }
  1895. }
  1896. }
  1897. if (!dic[95].Contains(di.CreateUserId))
  1898. {
  1899. jw.Msg = "暂无下载权限!";
  1900. return Ok(jw);
  1901. }
  1902. }
  1903. catch (Exception)
  1904. { }
  1905. }
  1906. else if (dto.UserId == di.CreateUserId)
  1907. {
  1908. }
  1909. else
  1910. {
  1911. jw.Msg = "暂无下载权限!";
  1912. return Ok(jw);
  1913. }
  1914. #endregion
  1915. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1916. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1917. .ToListAsync();
  1918. if (!blackCodeList.Any())
  1919. {
  1920. jw.Msg = "该团无机票行程代码!";
  1921. return Ok(jw);
  1922. }
  1923. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1924. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1925. if (groupEnterExitCost == null)
  1926. {
  1927. jw.Msg = "暂无三公费用信息!";
  1928. return Ok(jw);
  1929. }
  1930. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1931. rateList ??= new List<CurrencyInfo>();
  1932. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1933. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1934. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1935. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1936. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1937. .Select((x, a, b) => new
  1938. {
  1939. x.Index,
  1940. itemName = a.Name,
  1941. CurrencyStr = b.Name,
  1942. x.Cost,
  1943. x.SubTotal,
  1944. x.Remark
  1945. })
  1946. .OrderBy((x) => x.Index)
  1947. .ToList();
  1948. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1949. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1950. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1951. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1952. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1953. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1954. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1955. decimal subJJC = 0.00M,
  1956. subGWC = 0.00M,
  1957. subTDC = 0.00M;
  1958. //经济舱
  1959. if (groupEnterExitCost.SumJJC == 1)
  1960. {
  1961. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1962. }
  1963. //公务舱
  1964. if (groupEnterExitCost.SumGWC == 1)
  1965. {
  1966. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1967. }
  1968. //头等舱
  1969. if (groupEnterExitCost.SumTDC == 1)
  1970. {
  1971. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1972. }
  1973. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1974. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1975. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1976. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1977. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1978. .Select((x, s, dc, cc) => new GroupClints
  1979. {
  1980. Id = x.Id,
  1981. Name = s.Name,
  1982. IsAccompany = x.IsAccompany,
  1983. CompanyFullName = cc.CompanyFullName
  1984. })
  1985. .ToListAsync();
  1986. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1987. //获取舱位人数
  1988. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1989. .GroupBy(x => x.Name)
  1990. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1991. .ToList();
  1992. string cityPath = string.Empty;
  1993. string startCity = string.Empty;
  1994. string endCity = string.Empty;
  1995. foreach (var item in blackCodeList)
  1996. {
  1997. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1998. cityPath += city + "\r\n";
  1999. if (item.Equals(blackCodeList.First()))
  2000. {
  2001. var sp = city.Split('-');
  2002. startCity = sp[0];
  2003. endCity = sp[^1];
  2004. }
  2005. }
  2006. var bookMarkDic = new Dictionary<string, string>
  2007. {
  2008. { "ClientUnit", di.ClientUnit },
  2009. { "VisitCountry", di.VisitCountry },
  2010. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2011. { "VisitPNumber", di.VisitPNumber.ToString() },
  2012. { "CityPath", cityPath },
  2013. { "StartCity", startCity },
  2014. { "EndCity", endCity },
  2015. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2016. };
  2017. Document doc = null;
  2018. var percentage = 0.8M;
  2019. var fileNameadd = "预付";
  2020. if (dto.FileType == 1)
  2021. {
  2022. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2023. }
  2024. else if (dto.FileType == 2)
  2025. {
  2026. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2027. percentage = 1;
  2028. fileNameadd = "全款";
  2029. }
  2030. else
  2031. {
  2032. throw new Exception("FileType有误!");
  2033. }
  2034. var builder = new DocumentBuilder(doc);
  2035. decimal totalPrice = 0.00M;
  2036. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2037. if (firstTable != null)
  2038. {
  2039. // 遍历表格的行和单元格
  2040. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2041. {
  2042. for (int i = 0; i < row.Cells.Count; i++)
  2043. {
  2044. var cell = row.Cells[i];
  2045. // 读取单元格内容
  2046. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2047. if (cellTextFirst.Contains("舱位"))
  2048. {
  2049. break;
  2050. }
  2051. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2052. {
  2053. if (i == 2)
  2054. {
  2055. if (cellTextFirst == "经济舱")
  2056. {
  2057. // 设置单元格内容
  2058. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2059. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2060. }
  2061. else
  2062. {
  2063. // 设置单元格内容
  2064. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2065. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2066. }
  2067. }
  2068. if (i == 3)
  2069. {
  2070. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2071. if (count != null)
  2072. {
  2073. // 设置单元格内容
  2074. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2075. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2076. }
  2077. }
  2078. if (i == 4)
  2079. {
  2080. var rowPrice = 0.00M;
  2081. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2082. count ??= 0;
  2083. if (cellTextFirst == "经济舱")
  2084. {
  2085. rowPrice = subJJC * (int)count;
  2086. }
  2087. else
  2088. {
  2089. rowPrice = subGWC * (int)count;
  2090. }
  2091. totalPrice += rowPrice;
  2092. // 设置单元格内容
  2093. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2094. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2095. }
  2096. }
  2097. }
  2098. }
  2099. }
  2100. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2101. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2102. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2103. //--合同表格部分
  2104. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2105. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2106. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2107. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2108. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2109. bookMarkDic.Add("CityPath1", cityPath);
  2110. bookMarkDic.Add("CityPath2", cityPath);
  2111. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2112. if (contractTable != null)
  2113. {
  2114. //数据源
  2115. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2116. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2117. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2118. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2119. .Select((it, y, s) => new
  2120. {
  2121. it.Cost,
  2122. it.SubTotal,
  2123. it.Type,
  2124. y.Id,
  2125. y.City,
  2126. s.Name,
  2127. CurrencyCodeCn = s.Remark
  2128. })
  2129. .ToList()
  2130. .Select(x => new
  2131. {
  2132. CurrencyCode = x.Name,
  2133. CityId = x.Id,
  2134. x.City,
  2135. di.VisitPNumber,
  2136. x.Type,
  2137. x.Cost,
  2138. x.SubTotal,
  2139. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2140. x.CurrencyCodeCn,
  2141. });
  2142. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2143. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2144. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2145. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2146. var tableSettings = new List<tableSetting>()
  2147. {
  2148. new(){ Index = 1 , Property = "City"},
  2149. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2150. new(){ Index = 3 , Property = "Cost"},
  2151. new(){ Index = 4 , Property = "VisitPNumber"},
  2152. //new tableSetting{ Index = 5 , Property = ""},
  2153. //new tableSetting{ Index = 6 , Property = ""},
  2154. new(){ Index = 7 , Property = "Rate"},
  2155. //new tableSetting{ Index = 8 , Property = ""},
  2156. };
  2157. //1.住宿费
  2158. int cloneRow = 8;
  2159. int startDayPrice = 8; //写入index
  2160. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2161. foreach (var dac in dac1)
  2162. {
  2163. var first = dac.First();
  2164. var dayCount = dac.Count();
  2165. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2166. for (int i = 1; i < row.Cells.Count; i++)
  2167. {
  2168. var cell = row.Cells[i];
  2169. var findProperty = tableSettings.Find(x => x.Index == i);
  2170. if (findProperty != null)
  2171. {
  2172. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2173. // 设置单元格内容
  2174. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2175. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2176. }
  2177. else
  2178. {
  2179. switch (i)
  2180. {
  2181. case 5:
  2182. cell.FirstParagraph.Runs.Clear();
  2183. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2184. break;
  2185. case 6:
  2186. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2187. cell.FirstParagraph.Runs.Clear();
  2188. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2189. break;
  2190. case 8:
  2191. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2192. cell.FirstParagraph.Runs.Clear();
  2193. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2194. ZSPriceSum += xiaojiRMB;
  2195. break;
  2196. default:
  2197. break;
  2198. }
  2199. }
  2200. }
  2201. startDayPrice++;
  2202. if (!dac1.Last().Equals(dac))
  2203. {
  2204. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2205. // 将克隆的行追加到原行后面
  2206. contractTable.Rows.Insert(startDayPrice, newRow);
  2207. }
  2208. else
  2209. {
  2210. cloneRow += dac1.Count + 1;
  2211. startDayPrice = cloneRow;
  2212. }
  2213. }
  2214. //2.伙食费
  2215. foreach (var dac in dac2)
  2216. {
  2217. var first = dac.First();
  2218. var dayCount = dac.Count();
  2219. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2220. for (int i = 1; i < row.Cells.Count; i++)
  2221. {
  2222. var cell = row.Cells[i];
  2223. var findProperty = tableSettings.Find(x => x.Index == i);
  2224. if (findProperty != null)
  2225. {
  2226. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2227. // 设置单元格内容
  2228. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2229. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2230. }
  2231. else
  2232. {
  2233. switch (i)
  2234. {
  2235. case 5:
  2236. cell.FirstParagraph.Runs.Clear();
  2237. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2238. break;
  2239. case 6:
  2240. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2241. cell.FirstParagraph.Runs.Clear();
  2242. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2243. break;
  2244. case 8:
  2245. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2246. cell.FirstParagraph.Runs.Clear();
  2247. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2248. HSPriceSum += xiaojiRMB;
  2249. break;
  2250. default:
  2251. break;
  2252. }
  2253. }
  2254. }
  2255. startDayPrice++;
  2256. if (!dac2.Last().Equals(dac))
  2257. {
  2258. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2259. // 将克隆的行追加到原行后面
  2260. contractTable.Rows.Insert(startDayPrice, newRow);
  2261. }
  2262. else
  2263. {
  2264. cloneRow += dac2.Count + 1;
  2265. startDayPrice = cloneRow;
  2266. }
  2267. }
  2268. //3.公杂费
  2269. foreach (var dac in dac3)
  2270. {
  2271. var first = dac.First();
  2272. var dayCount = dac.Count();
  2273. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2274. for (int i = 1; i < row.Cells.Count; i++)
  2275. {
  2276. var cell = row.Cells[i];
  2277. var findProperty = tableSettings.Find(x => x.Index == i);
  2278. if (findProperty != null)
  2279. {
  2280. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2281. // 设置单元格内容
  2282. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2283. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2284. }
  2285. else
  2286. {
  2287. switch (i)
  2288. {
  2289. case 5:
  2290. cell.FirstParagraph.Runs.Clear();
  2291. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2292. break;
  2293. case 6:
  2294. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2295. cell.FirstParagraph.Runs.Clear();
  2296. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2297. break;
  2298. case 8:
  2299. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2300. cell.FirstParagraph.Runs.Clear();
  2301. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2302. GZPriceSum += xiaojiRMB;
  2303. break;
  2304. default:
  2305. break;
  2306. }
  2307. }
  2308. }
  2309. startDayPrice++;
  2310. if (!dac3.Last().Equals(dac))
  2311. {
  2312. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2313. // 将克隆的行追加到原行后面
  2314. contractTable.Rows.Insert(startDayPrice, newRow);
  2315. }
  2316. else
  2317. {
  2318. cloneRow += dac3.Count + 1;
  2319. startDayPrice = cloneRow;
  2320. }
  2321. }
  2322. //合并单元格
  2323. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2324. {
  2325. var currentRow = contractTable.Rows[i];
  2326. var nextRow = contractTable.Rows[i + 1];
  2327. // 获取当前行和下一行的第一个单元格
  2328. Cell currentCell = currentRow.Cells[0];
  2329. Cell nextCell = nextRow.Cells[0];
  2330. // 检查单元格内容是否一致(去除尾部的换行符)
  2331. string currentText = currentCell.GetText().Trim();
  2332. string nextText = nextCell.GetText().Trim();
  2333. if (currentText == nextText)
  2334. {
  2335. // 如果当前单元格已经被合并,找到合并的起始单元格
  2336. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2337. {
  2338. // 找到合并的起始单元格
  2339. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2340. // 将下一行的单元格设置为合并的后续单元格
  2341. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2342. }
  2343. else
  2344. {
  2345. // 如果当前单元格是合并的起始单元格
  2346. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2347. // 将下一行的单元格设置为合并的后续单元格
  2348. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2349. }
  2350. }
  2351. else
  2352. {
  2353. // 如果内容不一致,重置当前单元格的合并属性
  2354. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2355. {
  2356. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2357. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2358. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2359. }
  2360. else
  2361. {
  2362. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2363. }
  2364. }
  2365. }
  2366. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2367. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2368. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2369. }
  2370. foreach (var bookmarkName in bookMarkDic.Keys)
  2371. {
  2372. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2373. if (bookmark != null)
  2374. {
  2375. if (bookmarkName == "ClientUnit")
  2376. {
  2377. // 移动到书签位置
  2378. builder.MoveTo(bookmark.BookmarkStart);
  2379. // 设置字体样式为下划线
  2380. builder.Font.Underline = Aspose.Words.Underline.Single;
  2381. // 插入书签值
  2382. builder.Write(bookMarkDic[bookmarkName]);
  2383. // 清除字体格式,避免影响后续文本
  2384. builder.Font.ClearFormatting();
  2385. }
  2386. else
  2387. {
  2388. builder.MoveToBookmark(bookmarkName);
  2389. builder.Write(bookMarkDic[bookmarkName]);
  2390. }
  2391. }
  2392. }
  2393. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2394. doc.Save(savePaht);
  2395. jw.Msg = "生成成功!";
  2396. jw.Code = 200;
  2397. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2398. return Ok(jw);
  2399. }
  2400. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2401. {
  2402. int index = rowIndex;
  2403. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2404. {
  2405. index--;
  2406. }
  2407. return index;
  2408. }
  2409. #endregion
  2410. #region 团组&签证
  2411. #region 团组&签证 New
  2412. /// <summary>
  2413. /// 团组&签证 New
  2414. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2415. /// </summary>
  2416. /// <param name="file">请求dto</param>
  2417. /// <returns></returns>
  2418. [HttpPost]
  2419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2420. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile file,int fileTypeId)
  2421. {
  2422. //文件验证
  2423. if (file.Length < 1) return Ok(JsonView(false,"请选择文件!"));
  2424. var visaFiles = new VisaUploadFileTypeView();
  2425. var filetypes = visaFiles.GetVisaUploadFileTypeViewItemInit();
  2426. if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2427. //服务器存储文件
  2428. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2429. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2430. var filePath = Path.Combine(fileServerPath, file.FileName);
  2431. using (var stream = new FileStream(filePath, FileMode.Create))
  2432. {
  2433. await file.CopyToAsync(stream);
  2434. }
  2435. //日志记录-上传文件
  2436. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, file.FileName);
  2437. //kimi AI 识别文档返回json结果
  2438. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2439. var KiMiApi = new KiMiApiClient();
  2440. var files = new List<IFormFile>() { file };
  2441. var seedConter = await KiMiApi.UploadFilesAsync(files);
  2442. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2443. var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2444. var messages = new List<SeedMessages>
  2445. {
  2446. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2447. new() { Role = KimiRole.user, Content = seedMessage }
  2448. };
  2449. messages.InsertRange(1, seedConter);
  2450. string jsonString = string.Empty;
  2451. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2452. while (!isJson)
  2453. {
  2454. kimiAI_API_Index++;
  2455. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2456. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2457. jsonString += kimiApiResult_JObject["content"].ToString();
  2458. string startStr = "```json", endStr = "```";
  2459. // 判断并清除开头部分
  2460. if (jsonString.StartsWith(startStr))
  2461. {
  2462. jsonString = jsonString.Remove(0, startStr.Length);
  2463. }
  2464. // 判断并清除结尾部分
  2465. if (jsonString.EndsWith(endStr))
  2466. {
  2467. jsonString = jsonString.Replace(endStr, "");
  2468. }
  2469. //验证json格式是否正确
  2470. try
  2471. {
  2472. JsonDocument.Parse(jsonString);
  2473. isJson = true; // 如果解析成功,则是json格式
  2474. }
  2475. catch (Exception)
  2476. {
  2477. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2478. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2479. }
  2480. }
  2481. var clientInfo = new Crm_DeleClient(); //客户资料表
  2482. var clientFamily = new Crm_VisaCustomerFamily(); //客户家庭表
  2483. var clientCompany = new Crm_CustomerCompany(); //客户公司表
  2484. var clientCert = new Crm_CustomerCert(); //客户证件表
  2485. var clientSchool = new Crm_VisaCustomerSchool(); //客户学历表
  2486. //按照表格类型分别进行参数处理
  2487. switch (fileTypeId) {
  2488. //澳新签证个人申请表
  2489. case 1:
  2490. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2491. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2492. break;
  2493. default:
  2494. break;
  2495. }
  2496. return Ok(JsonView(true, jsonString));
  2497. }
  2498. #endregion
  2499. /// <summary>
  2500. /// 根据团组Id获取签证客户信息List
  2501. /// </summary>
  2502. /// <param name="dto">请求dto</param>
  2503. /// <returns></returns>
  2504. [HttpPost]
  2505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2506. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2507. {
  2508. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2509. if (groupData.Code != 0)
  2510. {
  2511. return Ok(JsonView(false, groupData.Msg));
  2512. }
  2513. return Ok(JsonView(groupData.Data));
  2514. }
  2515. /// <summary>
  2516. /// IOS获取团组签证拍照上传进度01(团组列表)
  2517. /// </summary>
  2518. /// <param name="dto">请求dto</param>
  2519. /// <returns></returns>
  2520. [HttpPost]
  2521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2522. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2523. {
  2524. if (dto == null)
  2525. {
  2526. return Ok(JsonView(false, "参数为空"));
  2527. }
  2528. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2529. return Ok(JsonView(visaList));
  2530. }
  2531. /// <summary>
  2532. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2533. /// </summary>
  2534. /// <returns></returns>
  2535. [HttpPost]
  2536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2537. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2538. {
  2539. if (dto == null)
  2540. {
  2541. return Ok(JsonView(false, "请求错误:"));
  2542. }
  2543. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2544. return Ok(JsonView(list));
  2545. }
  2546. /// <summary>
  2547. /// IOS获取团组签证拍照上传进度03(相册)
  2548. /// </summary>
  2549. /// <returns></returns>
  2550. [HttpPost]
  2551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2552. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2553. {
  2554. if (dto == null)
  2555. {
  2556. return Ok(JsonView(false, "请求错误:"));
  2557. }
  2558. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2559. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2560. list.ForEach(s => s.url = url);
  2561. return Ok(JsonView(list));
  2562. }
  2563. /// <summary>
  2564. /// IOS获取团组签证拍照上传进度04(图片上传)
  2565. /// </summary>
  2566. /// <param name="dto"></param>
  2567. /// <returns></returns>
  2568. [HttpPost]
  2569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2570. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2571. {
  2572. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2573. //if (!string.IsNullOrEmpty(result))
  2574. //{
  2575. //}
  2576. //else {
  2577. // return Ok(JsonView(false, "上传失败"));
  2578. //}
  2579. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2580. int sucNum = 0;
  2581. try
  2582. {
  2583. foreach (var item in dto.base64DataList)
  2584. {
  2585. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2586. string result = DecodeBase64ToImage(item, imageName);
  2587. if (!string.IsNullOrEmpty(result))
  2588. {
  2589. var pic = new Grp_VisaProgressCustomerPicture
  2590. {
  2591. CreateUserId = dto.CreateUserId,
  2592. PicName = imageName,
  2593. PicPath = result,
  2594. VisaProgressCustomerId = dto.visaProgressCustomerId
  2595. };
  2596. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2597. if (insertResult > 0)
  2598. {
  2599. sucNum++;
  2600. }
  2601. }
  2602. }
  2603. }
  2604. catch (Exception ex)
  2605. {
  2606. return Ok(JsonView(false, ex.Message));
  2607. }
  2608. string msg = string.Format(@"成功上传{0}张", sucNum);
  2609. return Ok(JsonView(true, msg));
  2610. }
  2611. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2612. {
  2613. string filename = "";//声明一个string类型的相对路径
  2614. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2615. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2616. try//会有异常抛出,try,catch一下
  2617. {
  2618. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2619. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2620. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2621. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2622. //文件名称
  2623. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2624. //上传的文件的路径
  2625. string filePath = "";
  2626. if (!Directory.Exists(fileDir))
  2627. {
  2628. Directory.CreateDirectory(fileDir);
  2629. }
  2630. //上传的文件的路径
  2631. filePath = fileDir + filename;
  2632. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2633. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2634. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2635. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2636. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2637. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2638. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2639. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2640. bitmap.Dispose();
  2641. }
  2642. catch (Exception e)
  2643. {
  2644. string massage = e.Message;
  2645. Logs("IOS图片上传Error:" + massage);
  2646. //filename = e.Message;
  2647. }
  2648. return filename;//返回相对路径
  2649. }
  2650. /// <summary>
  2651. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2652. /// </summary>
  2653. /// <param name="dto"></param>
  2654. /// <returns></returns>
  2655. [HttpPost]
  2656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2657. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2658. {
  2659. if (dto == null)
  2660. {
  2661. return Ok(JsonView(false, "请求错误:"));
  2662. }
  2663. string msg = "参数错误";
  2664. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2665. {
  2666. try
  2667. {
  2668. //_delegationVisaRep.BeginTran();
  2669. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2670. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2671. .Where(s => s.Id == dto.visaProgressCustomerId)
  2672. .ExecuteCommandAsync();
  2673. if (updCount > 0 && dto.publishCode == 1)
  2674. {
  2675. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2676. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2677. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2678. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2679. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2680. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2681. if (groupData == null)
  2682. {
  2683. _delegationVisaRep.RollbackTran();
  2684. }
  2685. string title = string.Format(@"[签证进度更新]");
  2686. string content = string.Format(@"测试文本");
  2687. bool rst = await _message.AddMsg(new MessageDto()
  2688. {
  2689. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2690. IssuerId = dto.publisher,
  2691. Title = title,
  2692. Content = content,
  2693. ReleaseTime = DateTime.Now,
  2694. UIdList = new List<int> {
  2695. 234
  2696. }
  2697. });
  2698. if (rst)
  2699. {
  2700. return Ok(JsonView(true, "发送通知成功"));
  2701. }
  2702. }
  2703. //_delegationVisaRep.CommitTran();
  2704. }
  2705. catch (Exception)
  2706. {
  2707. //_delegationVisaRep.RollbackTran();
  2708. }
  2709. }
  2710. return Ok(JsonView(true, msg));
  2711. }
  2712. #endregion
  2713. #region 团组任务分配
  2714. /// <summary>
  2715. /// 团组任务分配初始化
  2716. /// </summary>
  2717. /// <returns></returns>
  2718. [HttpPost]
  2719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2720. public async Task<IActionResult> GetTaskAssignmen()
  2721. {
  2722. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2723. if (groupData.Code != 0)
  2724. {
  2725. return Ok(JsonView(false, groupData.Msg));
  2726. }
  2727. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2728. }
  2729. /// <summary>
  2730. /// 团组任务分配查询
  2731. /// </summary>
  2732. /// <param name="dto"></param>
  2733. /// <returns></returns>
  2734. [HttpPost]
  2735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2736. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2737. {
  2738. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2739. if (groupData.Code != 0)
  2740. {
  2741. return Ok(JsonView(false, groupData.Msg));
  2742. }
  2743. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2744. }
  2745. /// <summary>
  2746. /// 团组任务分配操作
  2747. /// </summary>
  2748. /// <param name="dto"></param>
  2749. /// <returns></returns>
  2750. [HttpPost]
  2751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2752. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2753. {
  2754. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2755. if (groupData.Code != 0)
  2756. {
  2757. return Ok(JsonView(false, groupData.Msg));
  2758. }
  2759. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2760. }
  2761. /// <summary>
  2762. /// 团组任务分配
  2763. /// 批量分配
  2764. /// 查询团组
  2765. /// </summary>
  2766. /// <param name="dto"></param>
  2767. /// <returns></returns>
  2768. [HttpPost]
  2769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2770. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2771. {
  2772. //参数验证
  2773. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2774. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2775. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2776. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2777. }
  2778. /// <summary>
  2779. /// 团组任务分配
  2780. /// 批量分配
  2781. /// </summary>
  2782. /// <param name="dto"></param>
  2783. /// <returns></returns>
  2784. [HttpPost]
  2785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2786. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2787. {
  2788. //参数验证
  2789. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2790. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2791. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2792. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2793. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2794. }
  2795. #endregion
  2796. #region 团组费用审核
  2797. /// <summary>
  2798. /// 费用审核
  2799. /// 团组列表 Page
  2800. /// </summary>
  2801. /// <param name="_dto">团组列表请求dto</param>
  2802. /// <returns></returns>
  2803. [HttpPost]
  2804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2805. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2806. {
  2807. #region 参数验证
  2808. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2809. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2810. #region 页面操作权限验证
  2811. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2812. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2813. #endregion
  2814. #endregion
  2815. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2816. {
  2817. string sqlWhere = string.Empty;
  2818. if (_dto.IsSure == 0) //未完成
  2819. {
  2820. sqlWhere += string.Format(@" And IsSure = 0");
  2821. }
  2822. else if (_dto.IsSure == 1) //已完成
  2823. {
  2824. sqlWhere += string.Format(@" And IsSure = 1");
  2825. }
  2826. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2827. {
  2828. string tj = _dto.SearchCriteria;
  2829. 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}%')",
  2830. tj, tj, tj, tj, tj);
  2831. }
  2832. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2833. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2834. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2835. From (
  2836. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2837. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2838. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2839. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2840. From Grp_DelegationInfo gdi
  2841. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2842. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2843. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2844. Where gdi.IsDel = 0 {0}
  2845. ) temp ", sqlWhere);
  2846. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2847. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2848. var _view = new
  2849. {
  2850. PageFuncAuth = pageFunAuthView,
  2851. Data = _DelegationList
  2852. };
  2853. return Ok(JsonView(true, "查询成功!", _view, total));
  2854. }
  2855. else
  2856. {
  2857. return Ok(JsonView(false, "查询失败"));
  2858. }
  2859. }
  2860. /// <summary>
  2861. /// 获取团组费用审核
  2862. /// </summary>
  2863. /// <param name="_dto"></param>
  2864. /// <returns></returns>
  2865. [HttpPost]
  2866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2867. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2868. {
  2869. try
  2870. {
  2871. #region 参数验证
  2872. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2873. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2874. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2875. #region 页面操作权限验证
  2876. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2877. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2878. #endregion
  2879. #endregion
  2880. var _view = new Grp_CreditCardPaymentView();
  2881. var clientNameList = GetSimplClientList(_dto.DiId);
  2882. #region 费用清单
  2883. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2884. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2885. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2886. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2887. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2888. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2889. /*
  2890. * 76://酒店预订
  2891. */
  2892. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2893. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2894. /*
  2895. * 79://车/导游地接
  2896. */
  2897. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2898. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2899. /*
  2900. * 80: //签证
  2901. */
  2902. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2903. /*
  2904. *81: //邀请/公务活动
  2905. */
  2906. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2907. /*
  2908. * 82: //团组客户保险
  2909. */
  2910. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2911. /*
  2912. * Lable = 85 机票预订
  2913. */
  2914. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2915. /*
  2916. * 85 机票预定
  2917. */
  2918. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2919. /*
  2920. * 98 其他款项
  2921. */
  2922. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2923. /*
  2924. * 285:收款退还
  2925. */
  2926. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2927. /*
  2928. * 1015: //超支费用
  2929. */
  2930. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2931. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2932. /*
  2933. * 币种信息
  2934. */
  2935. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2936. /*
  2937. * 车/导游地接 费用类型
  2938. */
  2939. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2940. /*
  2941. * 车/导游地接 费用类型
  2942. */
  2943. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2944. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2945. /*
  2946. * 用户信息
  2947. */
  2948. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2949. /*
  2950. * 费用模块
  2951. */
  2952. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2953. string priceModule = string.Empty;
  2954. if (sdPriceName != null)
  2955. {
  2956. priceModule = sdPriceName.Name;
  2957. }
  2958. /*
  2959. * 成本信息
  2960. */
  2961. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2962. decimal _groupRate = 0.0000M;
  2963. string _groupCurrencyCode = "-";
  2964. if (groupCost != null)
  2965. {
  2966. _groupRate = groupCost.Rate;
  2967. if (int.TryParse(groupCost.Currency, out int _currency))
  2968. {
  2969. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2970. }
  2971. else _groupCurrencyCode = groupCost.Currency;
  2972. }
  2973. string costContentSql = $"Select * From Grp_GroupCost";
  2974. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2975. //处理日期为空的天数
  2976. for (int i = 0; i < groupCostDetails.Count; i++)
  2977. if (i != 0)
  2978. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2979. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2980. /*
  2981. * 处理详情数据
  2982. */
  2983. foreach (var entity in entityList)
  2984. {
  2985. var _detail = new Grp_CreditCardPaymentDetailView
  2986. {
  2987. Id = entity.Id,
  2988. PriceName = priceModule,
  2989. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  2990. };
  2991. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2992. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2993. //处理金额
  2994. if (entity.CTable == 1015)
  2995. {
  2996. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2997. if (czInfo != null)
  2998. {
  2999. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3000. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3001. }
  3002. }
  3003. /*
  3004. * 应付款金额
  3005. */
  3006. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3007. string PaymentCurrency_WaitPay = "Unknown";
  3008. string hotelCurrncyCode = "Unknown";
  3009. string hotelCurrncyName = "Unknown";
  3010. if (sdPaymentCurrency_WaitPay != null)
  3011. {
  3012. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3013. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3014. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3015. if (hotelCurrncyCode.Equals("CNY"))
  3016. {
  3017. entity.DayRate = 1.0000M;
  3018. }
  3019. }
  3020. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3021. /*
  3022. * 此次付款金额
  3023. */
  3024. decimal CurrPayStr = 0.00M,
  3025. OriginalCurrPay = 0.00M;
  3026. if (entity.PayPercentage == 0)
  3027. {
  3028. if (entity.PayThenMoney != 0)
  3029. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3030. }
  3031. else
  3032. {
  3033. if (entity.PayMoney != 0)
  3034. {
  3035. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3036. }
  3037. }
  3038. //if (_dto.Label == 79)
  3039. //{
  3040. // string original = string.Empty;
  3041. // if (hotelCurrncyCode.Equals("CNY"))
  3042. // {
  3043. // OriginalCurrPay = CurrPayStr;
  3044. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3045. // }
  3046. // else
  3047. // {
  3048. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3049. // //760 EUR(7600.00 CNY)
  3050. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3051. // }
  3052. //}
  3053. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3054. string original = string.Empty;
  3055. if (hotelCurrncyCode.Equals("CNY"))
  3056. {
  3057. OriginalCurrPay = CurrPayStr;
  3058. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3059. }
  3060. else
  3061. {
  3062. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3063. //760 EUR(7600.00 CNY)
  3064. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3065. }
  3066. /*
  3067. * 剩余尾款
  3068. */
  3069. decimal BalanceStr = 0;
  3070. if (CurrPayStr != 0)
  3071. {
  3072. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3073. BalanceStr = 0;
  3074. else
  3075. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3076. }
  3077. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3078. /*
  3079. * Bus名称
  3080. */
  3081. _detail.BusName = "待增加";
  3082. /*
  3083. *费用所属
  3084. */
  3085. switch (entity.CTable)
  3086. {
  3087. case 76://酒店预订
  3088. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3089. if (hotelReservations != null)
  3090. {
  3091. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3092. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3093. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3094. string roomFeeStr = "", roomFeestr1 = "";
  3095. //是否比较房型价格
  3096. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3097. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3098. roomFeeStr += $"<br/>";
  3099. var roomTotal = 0.00M;
  3100. if (hotelReservations.SingleRoomPrice > 0)
  3101. {
  3102. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3103. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3104. //__isSingle = true;
  3105. roomTotal += fee;
  3106. }
  3107. if (hotelReservations.DoubleRoomPrice > 0)
  3108. {
  3109. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3110. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3111. // __isDouble = true;
  3112. roomTotal += fee;
  3113. }
  3114. if (hotelReservations.SuiteRoomPrice > 0)
  3115. {
  3116. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3117. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3118. //__isSuite = true;
  3119. roomTotal += fee;
  3120. }
  3121. if (hotelReservations.OtherRoomPrice > 0)
  3122. {
  3123. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3124. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3125. //__isOther = true;
  3126. roomTotal += fee;
  3127. }
  3128. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3129. else roomFeeStr += " 0.00 * 0";
  3130. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3131. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3132. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3133. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3134. /*
  3135. * 费用类型
  3136. * 1:房费
  3137. * 2:早餐
  3138. * 3:地税
  3139. * 4:城市税
  3140. * </summary>
  3141. */
  3142. //地税
  3143. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3144. if (governmentRentData != null)
  3145. {
  3146. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3147. governmentRentFee = governmentRentData.Price;
  3148. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3149. if (governmentRentCurrData != null)
  3150. {
  3151. governmentRentCode = governmentRentCurrData.Name;
  3152. governmentRentName = $"({governmentRentCurrData.Remark})";
  3153. }
  3154. }
  3155. //城市税
  3156. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3157. if (cityTaxData != null)
  3158. {
  3159. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3160. cityTaxFee = cityTaxData.Price;
  3161. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3162. if (cityTaxCurrData != null)
  3163. {
  3164. cityTaxCode = cityTaxCurrData.Name;
  3165. cityTaxName = $"({cityTaxCurrData.Remark})";
  3166. }
  3167. }
  3168. //酒店早餐
  3169. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3170. if (breakfastData != null)
  3171. {
  3172. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3173. breakfastFee = breakfastData.Price;
  3174. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3175. if (breakfastCurrData != null)
  3176. {
  3177. breakfastCode = breakfastCurrData.Name;
  3178. breakfastName = $"({breakfastCurrData.Remark})";
  3179. }
  3180. }
  3181. //房间费用
  3182. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3183. if (roomData != null)
  3184. {
  3185. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3186. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3187. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3188. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3189. roomFee = roomData.Price;
  3190. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3191. if (roomCurrData != null)
  3192. {
  3193. roomCode = roomCurrData.Name;
  3194. roomName = $"({roomCurrData.Remark})";
  3195. }
  3196. }
  3197. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3198. string hotelCostStr = "";
  3199. decimal hotelCsotTotal = 0.00M;
  3200. if (groupCost != null)
  3201. {
  3202. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3203. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3204. }
  3205. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3206. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3207. string hotelCost_day = "";
  3208. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3209. foreach (var item in hotelCostDetails1)
  3210. {
  3211. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3212. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3213. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3214. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3215. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3216. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3217. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3218. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3219. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3220. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3221. hotelCost_day += @$"<br/>";
  3222. }
  3223. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3224. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3225. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3226. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3227. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3228. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3229. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3230. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3231. $"房间说明: {hotelReservations.Remark} <br/>" +
  3232. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3233. $"{hotelBreakfastStr}" +
  3234. $"{hotelGovernmentRentStr}" +
  3235. $"{hotelCityTaxStr}";
  3236. _detail.PriceNameContent = hotelReservations.HotelName;
  3237. }
  3238. break;
  3239. case 79://车/导游地接
  3240. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3241. if (touristGuideGroundReservations != null)
  3242. {
  3243. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3244. {
  3245. _detail.BusName = touristGuideGroundReservations.BusName;
  3246. }
  3247. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3248. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3249. //if (isInt)
  3250. //{
  3251. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3252. // if (cityInfo != null)
  3253. // {
  3254. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3255. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3256. // if (carFeeItem != null)
  3257. // {
  3258. // nameContent += $@"({carFeeItem.Name})";
  3259. // }
  3260. // _detail.PriceNameContent = nameContent;
  3261. // }
  3262. //}
  3263. //else
  3264. //{
  3265. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3266. //}
  3267. var touristGuideGroundReservationsContents =
  3268. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3269. var opContent_sb = new StringBuilder();
  3270. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3271. opContent_sb.AppendLine(contetTitle);
  3272. foreach (var item in touristGuideGroundReservationsContents)
  3273. {
  3274. string typeName = "Unknown";
  3275. string carCurrencyCode = "Unknown";
  3276. string carCurrencyName = "Unknown";
  3277. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3278. if (carTypeData != null) typeName = carTypeData.Name;
  3279. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3280. if (currencyData != null)
  3281. {
  3282. carCurrencyCode = currencyData.Name;
  3283. carCurrencyName = currencyData.Remark;
  3284. }
  3285. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3286. bool IsCurrencyAgreement = false;
  3287. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3288. string opCostStr = string.Empty;
  3289. decimal opCostTypePrice = 0.00M;
  3290. #region 处理成本各项费用
  3291. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3292. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3293. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3294. costOPFeeCNY = 0.00M, //团组成本 op费用
  3295. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3296. if (opCost.Count > 0)
  3297. {
  3298. switch (item.SId)
  3299. {
  3300. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3301. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3302. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3303. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3304. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3305. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3306. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3307. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3308. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3309. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3310. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3311. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3312. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3313. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3314. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3315. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3316. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3317. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3318. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3319. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3320. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3321. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3322. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3323. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3324. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3325. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3326. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3327. }
  3328. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3329. costOPFeeCNY = opCostTypePrice * _groupRate;
  3330. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3331. }
  3332. #endregion
  3333. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3334. aduitOPFeeCNY = item.Price * entity.DayRate;
  3335. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3336. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3337. $"{opTypeStr} {opCostStr}<br/>" +
  3338. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3339. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3340. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3341. {
  3342. if (IsCurrencyAgreement)
  3343. {
  3344. if (item.Price > opCostTypePrice)
  3345. {
  3346. opContent_sb.Append("<span style='color:red;'>");
  3347. opContent_sb.Append(opContent);
  3348. opContent_sb.Append("</span>");
  3349. opContent_sb.AppendLine();
  3350. }
  3351. else
  3352. {
  3353. opContent_sb.Append(opContent);
  3354. opContent_sb.AppendLine();
  3355. }
  3356. }
  3357. else
  3358. {
  3359. //验证是否超成本 按付款比例计算
  3360. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3361. {
  3362. opContent_sb.Append("<span style='color:red;'>");
  3363. opContent_sb.Append(opContent);
  3364. opContent_sb.Append("</span>");
  3365. opContent_sb.AppendLine();
  3366. }
  3367. else
  3368. {
  3369. opContent_sb.Append(opContent);
  3370. opContent_sb.AppendLine();
  3371. }
  3372. }
  3373. }
  3374. else
  3375. {
  3376. opContent_sb.Append(opContent);
  3377. opContent_sb.AppendLine();
  3378. }
  3379. }
  3380. _detail.PriceMsgContent = opContent_sb.ToString();
  3381. }
  3382. break;
  3383. case 80: //签证
  3384. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3385. if (visaInfo != null)
  3386. {
  3387. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  3388. _detail.PriceNameContent = visaInfo.VisaDescription;
  3389. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3390. }
  3391. break;
  3392. case 81: //邀请/公务活动
  3393. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3394. if (_ioa != null)
  3395. {
  3396. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3397. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3398. sendCurrName = "Unknown", //快递费用币种 Name
  3399. sendCurrCode = "Unknown", //快递费用币种 Code
  3400. eventsCurrName = "Unknown", //公务活动费币种 Name
  3401. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3402. translateCurrName = "Unknown", //公务翻译费 Name
  3403. translateCurrCode = "Unknown"; //公务翻译费 Code
  3404. #region 处理费用币种
  3405. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3406. if (inviteCurrData != null)
  3407. {
  3408. inviteCurrName = inviteCurrData.Remark;
  3409. inviteCurrCode = inviteCurrData.Name;
  3410. }
  3411. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3412. if (sendCurrData != null)
  3413. {
  3414. sendCurrName = sendCurrData.Remark;
  3415. sendCurrCode = sendCurrData.Name;
  3416. }
  3417. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3418. if (eventsCurrData != null)
  3419. {
  3420. eventsCurrName = eventsCurrData.Remark;
  3421. eventsCurrCode = eventsCurrData.Name;
  3422. }
  3423. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3424. if (translateCurrData != null)
  3425. {
  3426. translateCurrName = translateCurrData.Remark;
  3427. translateCurrCode = translateCurrData.Name;
  3428. }
  3429. #endregion
  3430. _detail.PriceNameContent = _ioa.InviterArea;
  3431. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3432. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3433. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3434. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3435. $@"备注:" + _ioa.Remark + "<br/>";
  3436. }
  3437. break;
  3438. case 82: //团组客户保险
  3439. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3440. if (customers != null)
  3441. {
  3442. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3443. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3444. }
  3445. break;
  3446. case 85: //机票预订
  3447. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3448. if (jpRes != null)
  3449. {
  3450. string FlightsDescription = jpRes.FlightsDescription;
  3451. string PriceDescription = jpRes.PriceDescription;
  3452. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3453. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3454. }
  3455. break;
  3456. case 98://其他款项
  3457. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3458. if (gdpRes != null)
  3459. {
  3460. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3461. _detail.PriceNameContent = gdpRes.PriceName;
  3462. }
  3463. break;
  3464. case 285://收款退还
  3465. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3466. if (refundAndOtherMoney != null)
  3467. {
  3468. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3469. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3470. }
  3471. break;
  3472. case 751://酒店早餐
  3473. break;
  3474. case 1015://超支费用
  3475. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3476. if (groupExtraCost != null)
  3477. {
  3478. _detail.PriceNameContent = groupExtraCost.PriceName;
  3479. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3480. }
  3481. break;
  3482. default:
  3483. break;
  3484. }
  3485. /*
  3486. * 申请人
  3487. */
  3488. string operatorName = " - ";
  3489. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3490. if (_opUser != null)
  3491. {
  3492. operatorName = _opUser.CnName;
  3493. }
  3494. _detail.OperatorName = operatorName;
  3495. /*
  3496. * 审核人
  3497. */
  3498. string auditOperatorName = " - ";
  3499. if (entity.IsAuditGM != 0)
  3500. {
  3501. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3502. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3503. else
  3504. {
  3505. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3506. if (_adUser != null)
  3507. {
  3508. auditOperatorName = _adUser.CnName;
  3509. }
  3510. }
  3511. }
  3512. _detail.AuditOperatorName = auditOperatorName;
  3513. /*
  3514. * 超预算比例
  3515. */
  3516. string overBudgetStr = "";
  3517. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3518. else if (entity.ExceedBudget == 0)
  3519. {
  3520. if (entity.CTable == 76 || entity.CTable == 79)
  3521. {
  3522. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3523. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3524. }
  3525. else
  3526. {
  3527. overBudgetStr = "未超预算";
  3528. }
  3529. }
  3530. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3531. _detail.OverBudget = overBudgetStr;
  3532. decimal auditFee = 0.00M; //已审核金额 人名币
  3533. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3534. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3535. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3536. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3537. {
  3538. auditedFeeOriginal = entity.PayMoney;
  3539. auditFee = CurrPayStr;
  3540. }
  3541. else if (entity.IsAuditGM == 0)
  3542. {
  3543. unAuditFeeCNY = CurrPayStr;
  3544. unAuditFeeOriginal = OriginalCurrPay;
  3545. OriginalCurrPay = 0.00M;
  3546. }
  3547. /*
  3548. * 费用总计
  3549. */
  3550. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3551. {
  3552. CurrencyId = entity.PaymentCurrency,
  3553. CurrencyName = PaymentCurrency_WaitPay,
  3554. AmountPayable = entity.PayMoney,
  3555. ThisPayment = OriginalCurrPay,
  3556. BalancePayment = BalanceStr,
  3557. AuditedFunds = auditFee,
  3558. AuditedFundsOriginal = auditedFeeOriginal,
  3559. UnAuditFundsCNY = unAuditFeeCNY,
  3560. UnAuditFundsOriginal = unAuditFeeOriginal
  3561. });
  3562. _detail.IsAuditGM = entity.IsAuditGM;
  3563. detailList.Add(_detail);
  3564. }
  3565. #endregion
  3566. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3567. /*
  3568. * 下方描述处理
  3569. */
  3570. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3571. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3572. if (ccpCurrencyPrice != null)
  3573. {
  3574. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3575. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3576. }
  3577. else
  3578. {
  3579. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3580. }
  3581. string amountPayableStr = string.Format(@"应付款总金额: ");
  3582. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3583. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3584. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3585. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3586. foreach (var item in nonDuplicat)
  3587. {
  3588. var currencyName = item.CurrencyName;
  3589. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3590. if (strs.Count > 0)
  3591. {
  3592. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3593. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3594. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3595. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3596. //单独处理此次付款金额
  3597. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3598. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3599. //单独处理已审核费用
  3600. //if (item.CurrencyId == 836) //人民币
  3601. //{
  3602. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3603. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3604. //}
  3605. //else
  3606. //{
  3607. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3608. //}
  3609. if (currencyName.Equals("CNY"))
  3610. {
  3611. //已审核费用
  3612. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3613. //未审核费用
  3614. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3615. }
  3616. else
  3617. {
  3618. //已审核费用
  3619. 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"));
  3620. //未审核费用
  3621. 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"));
  3622. }
  3623. }
  3624. }
  3625. _view.TotalStr1 = amountPayableStr[..^1];
  3626. _view.TotalStr2 = thisPaymentStr[..^1];
  3627. _view.TotalStr3 = balancePaymentStr[..^1];
  3628. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3629. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3630. var _view1 = new
  3631. {
  3632. PageFuncAuth = pageFunAuthView,
  3633. Data = _view
  3634. };
  3635. return Ok(JsonView(_view1));
  3636. }
  3637. catch (Exception ex)
  3638. {
  3639. return Ok(JsonView(false, ex.Message));
  3640. }
  3641. }
  3642. /// <summary>
  3643. /// 费用审核
  3644. /// 修改团组费用审核状态
  3645. /// </summary>
  3646. /// <param name="_dto">参数Json字符串</param>
  3647. /// <returns></returns>
  3648. [HttpPost]
  3649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3650. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3651. {
  3652. #region 参数验证
  3653. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3654. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3655. #endregion
  3656. #region 页面操作权限验证
  3657. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3658. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3659. #endregion
  3660. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3661. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3662. DateTime dtNow = DateTime.Now;
  3663. _groupRepository.BeginTran();
  3664. int rst = 0;
  3665. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3666. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3667. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3668. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3669. var msgDatas = new List<dynamic>();
  3670. var dic_ccp_user = new Dictionary<int, int>() { };
  3671. foreach (var item in idList)
  3672. {
  3673. int CreditId = int.Parse(item);
  3674. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3675. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3676. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3677. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3678. .Where(s => s.Id == CreditId)
  3679. .ExecuteCommandAsync();
  3680. if (result < 1)
  3681. {
  3682. rst = -1;
  3683. _groupRepository.RollbackTran();
  3684. return Ok(JsonView(false, "操作失败并回滚!"));
  3685. }
  3686. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3687. if (creditData != null)
  3688. {
  3689. #region 应用通知配置
  3690. try
  3691. {
  3692. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3693. }
  3694. catch (Exception ex)
  3695. {
  3696. }
  3697. #endregion
  3698. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3699. string groupNameStr = string.Empty;
  3700. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3701. if (groupData != null) groupNameStr = groupData.TeamName;
  3702. string creditTypeStr = string.Empty;
  3703. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3704. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3705. string creditCurrency = string.Empty;
  3706. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3707. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3708. if (creditCurrency.Equals("CNY"))
  3709. {
  3710. creditData.DayRate = 1.0000M;
  3711. }
  3712. if (creditData.PayPercentage == 0.00M)
  3713. {
  3714. creditData.PayPercentage = 100M;
  3715. }
  3716. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3717. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3718. string msgContent = "";
  3719. if (creditCurrency.Equals("CNY"))
  3720. {
  3721. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3722. }
  3723. else
  3724. {
  3725. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3726. }
  3727. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3728. }
  3729. }
  3730. if (rst == 0)
  3731. {
  3732. _groupRepository.CommitTran();
  3733. foreach (var item in msgDatas)
  3734. {
  3735. //发送消息
  3736. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3737. }
  3738. #region 应用推送
  3739. try
  3740. {
  3741. foreach (var ccpId in dic_ccp_user.Keys)
  3742. {
  3743. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3744. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3745. }
  3746. }
  3747. catch (Exception)
  3748. {
  3749. }
  3750. #endregion
  3751. return Ok(JsonView(true, "操作成功!"));
  3752. }
  3753. return Ok(JsonView(false, "操作失败!"));
  3754. }
  3755. #endregion
  3756. #region 机票费用录入
  3757. /// <summary>
  3758. /// 机票录入当前登录人可操作团组
  3759. /// </summary>
  3760. /// <param name="dto"></param>
  3761. /// <returns></returns>
  3762. [HttpPost]
  3763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3764. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3765. {
  3766. try
  3767. {
  3768. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3769. if (groupData.Code != 0)
  3770. {
  3771. return Ok(JsonView(false, groupData.Msg));
  3772. }
  3773. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3774. }
  3775. catch (Exception ex)
  3776. {
  3777. return Ok(JsonView(false, ex.Message));
  3778. }
  3779. }
  3780. /// <summary>
  3781. /// 机票费用录入列表
  3782. /// </summary>
  3783. /// <param name="dto"></param>
  3784. /// <returns></returns>
  3785. [HttpPost]
  3786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3787. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3788. {
  3789. try
  3790. {
  3791. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3792. if (groupData.Code != 0)
  3793. {
  3794. return Ok(JsonView(false, groupData.Msg));
  3795. }
  3796. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3797. }
  3798. catch (Exception ex)
  3799. {
  3800. return Ok(JsonView(false, ex.Message));
  3801. throw;
  3802. }
  3803. }
  3804. /// <summary>
  3805. /// 根据id查询费用录入信息
  3806. /// </summary>
  3807. /// <param name="dto"></param>
  3808. /// <returns></returns>
  3809. [HttpPost]
  3810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3811. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3812. {
  3813. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3814. if (groupData.Code != 0)
  3815. {
  3816. return Ok(JsonView(false, groupData.Msg));
  3817. }
  3818. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3819. }
  3820. /// <summary>
  3821. /// 机票费用录入操作(Status:1.新增,2.修改)
  3822. /// </summary>
  3823. /// <param name="dto"></param>
  3824. /// <returns></returns>
  3825. [HttpPost]
  3826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3827. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3828. {
  3829. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3830. if (groupData.Code != 0)
  3831. {
  3832. return Ok(JsonView(false, groupData.Msg));
  3833. }
  3834. #region 应用推送
  3835. try
  3836. {
  3837. var diId = dto.AirTicketResOpData.DiId;
  3838. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3839. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3840. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3841. //自动审核
  3842. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  3843. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  3844. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  3845. $"GroupId:{diId};airId:{dataId};",
  3846. status,
  3847. auditMsg);
  3848. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3849. //2024-10-21 新增LZ UID
  3850. var userIds = new List<int>() { 21 };
  3851. string title = $"系统通知";
  3852. string content = "";
  3853. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3854. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3855. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3856. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3857. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3858. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3859. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3860. }
  3861. catch (Exception ex)
  3862. {
  3863. }
  3864. #endregion
  3865. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3866. }
  3867. /// <summary>
  3868. /// 机票费用自动审核 AI识别方式
  3869. /// </summary>
  3870. /// <returns></returns>
  3871. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  3872. {
  3873. var ecoTypeIds = new List<int>() {
  3874. 459, //超经舱
  3875. 460, //经济舱
  3876. 1430, //公务舱(实际经济舱)
  3877. 1432, //头等舱(实际经济舱)
  3878. };
  3879. var bizTypeIds = new List<int>() {
  3880. 457, //头等舱
  3881. 458, //公务舱
  3882. 1431, //头等舱(实际公务舱)
  3883. };
  3884. var auditFeeTypeIds = new List<int>() { };
  3885. auditFeeTypeIds.AddRange(ecoTypeIds);
  3886. auditFeeTypeIds.AddRange(bizTypeIds);
  3887. int currModule = 85;
  3888. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  3889. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  3890. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  3891. .Select((x, y) => new
  3892. {
  3893. x.Id,
  3894. CcpId = y.Id,
  3895. x.FlightsDate,
  3896. x.PrePrice,
  3897. x.CType,
  3898. x.ClientNum,
  3899. x.DIId
  3900. })
  3901. .FirstAsync();
  3902. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  3903. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  3904. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  3905. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  3906. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  3907. var groupCostContents = await _sqlSugar
  3908. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  3909. .Where(x => x.IsDel == 0 && x.Diid == diId)
  3910. .ToListAsync();
  3911. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  3912. //处理 成本详细信息日期为空 填装费用信息
  3913. var airFeeLabel = new StringBuilder();
  3914. airFeeLabel.AppendLine("费用成本:");
  3915. for (int i = 0; i < groupCostContents.Count; i++)
  3916. {
  3917. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  3918. {
  3919. int index = i - 1;
  3920. if (index >= 0)
  3921. {
  3922. groupCostContents[i].Date = groupCostContents[index].Date;
  3923. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3924. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3925. }
  3926. }
  3927. else
  3928. {
  3929. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3930. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3931. }
  3932. var item = groupCostContents[i];
  3933. airFeeLabel.AppendLine($"{item.Date}");
  3934. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  3935. }
  3936. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  3937. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  3938. //访问Kimi AI 返回价格结果
  3939. var msgs = new List<SeedMessages>()
  3940. {
  3941. new ()
  3942. {
  3943. Role = KimiRole.user,
  3944. Content = airFeeLabel.ToString()
  3945. }
  3946. };
  3947. var client = new KiMiApiClient();
  3948. var kimiApiResult = await client.SeedMessage(msgs);
  3949. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3950. string clients = kimiApiResult_JObject["content"].ToString();
  3951. decimal ecoPri_kimiAI = 0.00M,
  3952. bizPri_kimiAI = 0.00M;
  3953. //单个价格: 经济舱价格
  3954. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  3955. //价格文本包含/:/前经济舱价格 /后公务舱价格
  3956. if (clients.Contains('/'))
  3957. {
  3958. var priArray = clients.Split('/');
  3959. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  3960. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  3961. }
  3962. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  3963. var isAutoAudit = false;
  3964. //价格验证处理
  3965. //经济舱
  3966. if (ecoTypeIds.Contains(airInfo.CType))
  3967. {
  3968. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  3969. }
  3970. //公务舱
  3971. else if (bizTypeIds.Contains(airInfo.CType))
  3972. {
  3973. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  3974. }
  3975. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  3976. //是否执行自动审核
  3977. if (isAutoAudit)
  3978. {
  3979. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3980. .SetColumns(x => x.IsAuditGM == 3)
  3981. .SetColumns(x => x.AuditGMOperate == 4)
  3982. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  3983. .Where(x => x.Id == airInfo.CcpId)
  3984. .ExecuteCommandAsync();
  3985. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  3986. }
  3987. return (false, "当前费用超过成本费用,不可自动审核!");
  3988. }
  3989. /// <summary>
  3990. /// 机票费用录入
  3991. /// 自动审核测试 - AI 识别
  3992. /// </summary>
  3993. /// <param name="groupId"></param>
  3994. /// <param name="Id"></param>
  3995. /// <returns></returns>
  3996. [HttpPost]
  3997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3998. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  3999. {
  4000. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4001. return Ok(JsonView(status, msg));
  4002. }
  4003. /// <summary>
  4004. /// 根据舱位类型查询接团客户名单信息
  4005. /// </summary>
  4006. /// <param name="dto"></param>
  4007. /// <returns></returns>
  4008. [HttpPost]
  4009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4010. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4011. {
  4012. try
  4013. {
  4014. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4015. if (crm_Groups.Count != 0)
  4016. {
  4017. var Customer = new List<dynamic>();
  4018. foreach (var item in crm_Groups)
  4019. {
  4020. var data = new
  4021. {
  4022. item.Id,
  4023. item.Pinyin,
  4024. Name = item.LastName + item.FirstName
  4025. };
  4026. Customer.Add(data);
  4027. }
  4028. return Ok(JsonView(true, "查询成功!", Customer));
  4029. }
  4030. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4031. }
  4032. catch (Exception ex)
  4033. {
  4034. return Ok(JsonView(false, "程序错误!"));
  4035. throw;
  4036. }
  4037. }
  4038. /// <summary>
  4039. /// 根据团号获取客户信息
  4040. /// </summary>
  4041. /// <param name="dto"></param>
  4042. /// <returns></returns>
  4043. [HttpPost]
  4044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4045. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4046. {
  4047. var jw = JsonView(false);
  4048. if (dto.DIID < 1)
  4049. {
  4050. jw.Msg += "请输入正确的diid";
  4051. return Ok(jw);
  4052. }
  4053. var arr = GetSimplClientList(dto.DIID);
  4054. jw = JsonView(true, "获取成功!", arr);
  4055. return Ok(jw);
  4056. }
  4057. private List<SimplClientInfo> GetSimplClientList(int diId)
  4058. {
  4059. 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);
  4060. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4061. foreach (var item in arr)
  4062. {
  4063. EncryptionProcessor.DecryptProperties(item);
  4064. }
  4065. return arr;
  4066. }
  4067. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4068. {
  4069. string result = origin;
  4070. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4071. {
  4072. string[] temparr = origin.Split(',');
  4073. string fistrStr = temparr[0];
  4074. int count = temparr.Length;
  4075. bool success = int.TryParse(fistrStr, out int tempId);
  4076. if (success)
  4077. {
  4078. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4079. if (tempInfo != null)
  4080. {
  4081. if (count > 1)
  4082. {
  4083. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4084. }
  4085. else
  4086. {
  4087. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4088. }
  4089. }
  4090. }
  4091. }
  4092. return result;
  4093. }
  4094. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4095. {
  4096. string result = origin;
  4097. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4098. {
  4099. string[] temparr = origin.Split(',');
  4100. result = "";
  4101. foreach (var item in temparr)
  4102. {
  4103. bool success = int.TryParse(item, out int tempId);
  4104. if (success)
  4105. {
  4106. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4107. if (tempInfo != null)
  4108. {
  4109. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4110. }
  4111. }
  4112. }
  4113. }
  4114. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4115. return result;
  4116. }
  4117. /// <summary>
  4118. /// 机票费用录入,删除
  4119. /// </summary>
  4120. /// <param name="dto"></param>
  4121. /// <returns></returns>
  4122. [HttpPost]
  4123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4124. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4125. {
  4126. try
  4127. {
  4128. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4129. if (res)
  4130. {
  4131. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4132. {
  4133. IsDel = 1,
  4134. DeleteUserId = dto.DeleteUserId,
  4135. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4136. }).ExecuteCommandAsync();
  4137. return Ok(JsonView(true, "删除成功!"));
  4138. }
  4139. return Ok(JsonView(false, "删除失败!"));
  4140. }
  4141. catch (Exception ex)
  4142. {
  4143. return Ok(JsonView(false, "程序错误!"));
  4144. throw;
  4145. }
  4146. }
  4147. /// <summary>
  4148. /// 导出机票录入报表
  4149. /// </summary>
  4150. /// <param name="dto"></param>
  4151. /// <returns></returns>
  4152. [HttpPost]
  4153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4154. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4155. {
  4156. try
  4157. {
  4158. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4159. if (groupData.Code != 0)
  4160. {
  4161. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4162. }
  4163. else
  4164. {
  4165. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4166. if (AirTicketReservations.Count != 0)
  4167. {
  4168. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4169. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4170. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4171. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4172. var designer = new WorkbookDesigner
  4173. {
  4174. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4175. };
  4176. decimal countCost = 0;
  4177. foreach (var item in AirTicketReservations)
  4178. {
  4179. #region 处理客人姓名
  4180. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4181. item.ClientName = clientNames;
  4182. #endregion
  4183. if (item.BankType == "其他")
  4184. {
  4185. item.BankNo = "--";
  4186. }
  4187. else
  4188. {
  4189. if (!string.IsNullOrEmpty(item.BankType))
  4190. {
  4191. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  4192. }
  4193. }
  4194. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4195. item.Price = System.Decimal.Round(item.Price, 2);
  4196. countCost += Convert.ToDecimal(item.Price);
  4197. }
  4198. designer.SetDataSource("Export", AirTicketReservations);
  4199. designer.SetDataSource("ExportDiCode", diCode);
  4200. designer.SetDataSource("ExportDiName", diName);
  4201. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4202. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4203. designer.Process();
  4204. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4205. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4206. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4207. return Ok(JsonView(true, "成功", url = rst));
  4208. }
  4209. else
  4210. {
  4211. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4212. }
  4213. }
  4214. }
  4215. catch (Exception ex)
  4216. {
  4217. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4218. throw;
  4219. }
  4220. }
  4221. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4222. /// <summary>
  4223. /// 行程单导出
  4224. /// </summary>
  4225. /// <param name="dto"></param>
  4226. /// <returns></returns>
  4227. [HttpPost]
  4228. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4229. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4230. {
  4231. try
  4232. {
  4233. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4234. if (groupData.Code != 0)
  4235. {
  4236. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4237. }
  4238. else
  4239. {
  4240. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4241. if (dto.Language == "CN")
  4242. {
  4243. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4244. var builder = new DocumentBuilder(doc);
  4245. int tableIndex = 0;//表格索引
  4246. //得到文档中的第一个表格
  4247. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4248. foreach (var item in _AirTicketReservations)
  4249. {
  4250. #region 处理固定数据
  4251. string[] FlightsCode = item.FlightsCode.Split('/');
  4252. if (FlightsCode.Length != 0)
  4253. {
  4254. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4255. if (_AirCompany != null)
  4256. {
  4257. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4258. }
  4259. else
  4260. {
  4261. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4262. }
  4263. }
  4264. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4265. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4266. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4267. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4268. string name = "";
  4269. foreach (string clientName in nameArray)
  4270. {
  4271. if (!name.Contains(clientName))
  4272. {
  4273. name += clientName + ",";
  4274. }
  4275. }
  4276. if (!string.IsNullOrWhiteSpace(name))
  4277. {
  4278. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4279. }
  4280. else
  4281. {
  4282. table.Range.Bookmarks["ClientName"].Text = "--";
  4283. }
  4284. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4285. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4286. table.Range.Bookmarks["JointTicket"].Text = "--";
  4287. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4288. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4289. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4290. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4291. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4292. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4293. #endregion
  4294. #region 循环数据处理
  4295. var airs = new List<AirInfo>();
  4296. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4297. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4298. for (int i = 0; i < FlightsCode.Length; i++)
  4299. {
  4300. var air = new AirInfo();
  4301. string[] tempstr = DayArray[i]
  4302. .Replace("\r\n", string.Empty)
  4303. .Replace("\\r\\n", string.Empty)
  4304. .TrimStart().TrimEnd()
  4305. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4306. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4307. string starCity = "";
  4308. if (star_Three != null)
  4309. {
  4310. starCity = star_Three.AirPort;
  4311. }
  4312. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4313. string EndCity = "";
  4314. if (End_Three != null)
  4315. {
  4316. EndCity = End_Three.AirPort;
  4317. }
  4318. air.Destination = starCity + "/" + EndCity;
  4319. air.Flight = FlightsCode[i];
  4320. air.SeatingClass = item.CTypeName;
  4321. string dateTime = tempstr[2];
  4322. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4323. air.FlightDate = DateTemp;
  4324. air.DepartureTime = tempstr[5];
  4325. air.LandingTime = tempstr[6];
  4326. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4327. air.TicketStatus = "--";
  4328. air.Luggage = "--";
  4329. air.DepartureTerminal = "--";
  4330. air.LandingTerminal = "--";
  4331. airs.Add(air);
  4332. }
  4333. int row = 13;
  4334. for (int i = 0; i < airs.Count; i++)
  4335. {
  4336. if (airs.Count > 2)
  4337. {
  4338. for (int j = 0; j < airs.Count - 2; j++)
  4339. {
  4340. var CopyRow = table.Rows[12].Clone(true);
  4341. table.Rows.Add(CopyRow);
  4342. }
  4343. }
  4344. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4345. int index = 0;
  4346. foreach (PropertyInfo property in properties)
  4347. {
  4348. string value = property.GetValue(airs[i]).ToString();
  4349. Cell ishcel0 = table.Rows[row].Cells[index];
  4350. var p = new Paragraph(doc);
  4351. string s = value;
  4352. p.AppendChild(new Run(doc, s));
  4353. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4354. ishcel0.AppendChild(p);
  4355. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4356. index++;
  4357. }
  4358. row++;
  4359. }
  4360. #endregion
  4361. var lastParagraph = new Paragraph(doc);
  4362. //第一个表格末尾加段落
  4363. table.ParentNode.InsertAfter(lastParagraph, table);
  4364. //复制第一个表格
  4365. Table cloneTable = (Table)table.Clone(true);
  4366. //在文档末尾段落后面加入复制的表格
  4367. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4368. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4369. {
  4370. int rownewsIndex = 13;
  4371. for (int i = 0; i < 2; i++)
  4372. {
  4373. var CopyRow = table.Rows[12].Clone(true);
  4374. table.Rows.RemoveAt(13);
  4375. table.Rows.Add(CopyRow);
  4376. rownewsIndex++;
  4377. }
  4378. }
  4379. else
  4380. {
  4381. table.Rows.RemoveAt(12);
  4382. }
  4383. cloneTable.Rows.RemoveAt(12);
  4384. }
  4385. if (_AirTicketReservations.Count != 0)
  4386. {
  4387. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4388. if (FlightsCode.Length != 0)
  4389. {
  4390. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4391. if (_AirCompany != null)
  4392. {
  4393. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4394. }
  4395. else
  4396. {
  4397. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4398. }
  4399. }
  4400. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4401. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4402. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4403. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4404. string name = "";
  4405. foreach (string clientName in nameArray)
  4406. {
  4407. if (!name.Contains(clientName))
  4408. {
  4409. name += clientName + ",";
  4410. }
  4411. }
  4412. if (!string.IsNullOrWhiteSpace(name))
  4413. {
  4414. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4415. }
  4416. else
  4417. {
  4418. table.Range.Bookmarks["ClientName"].Text = "--";
  4419. }
  4420. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4421. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4422. table.Range.Bookmarks["JointTicket"].Text = "--";
  4423. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4424. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4425. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4426. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4427. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4428. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4429. }
  4430. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4431. //保存合并后的文档
  4432. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4433. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4434. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4435. return Ok(JsonView(true, "成功!", rst));
  4436. }
  4437. else
  4438. {
  4439. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4440. var builder = new DocumentBuilder(doc);
  4441. int tableIndex = 0;//表格索引
  4442. //得到文档中的第一个表格
  4443. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4444. var texts = new List<string>();
  4445. foreach (var item in _AirTicketReservations)
  4446. {
  4447. string[] FlightsCode = item.FlightsCode.Split('/');
  4448. if (FlightsCode.Length != 0)
  4449. {
  4450. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4451. if (_AirCompany != null)
  4452. {
  4453. if (!transDic.ContainsKey(_AirCompany.CnName))
  4454. {
  4455. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4456. }
  4457. }
  4458. else
  4459. {
  4460. if (!transDic.ContainsKey("--"))
  4461. {
  4462. transDic.Add("--", "--");
  4463. }
  4464. }
  4465. }
  4466. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4467. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4468. string name = "";
  4469. foreach (string clientName in nameArray)
  4470. {
  4471. name += clientName + ",";
  4472. }
  4473. if (!texts.Contains(name))
  4474. {
  4475. texts.Add(name);
  4476. }
  4477. var airs = new List<AirInfo>();
  4478. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4479. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4480. for (int i = 0; i < FlightsCode.Length; i++)
  4481. {
  4482. var air = new AirInfo();
  4483. string[] tempstr = DayArray[i]
  4484. .Replace("\r\n", string.Empty)
  4485. .Replace("\\r\\n", string.Empty)
  4486. .TrimStart().TrimEnd()
  4487. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4488. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4489. if (star_Three != null)
  4490. {
  4491. if (!transDic.ContainsKey(star_Three.AirPort))
  4492. {
  4493. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4494. }
  4495. }
  4496. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4497. if (End_Three != null)
  4498. {
  4499. if (!transDic.ContainsKey(End_Three.AirPort))
  4500. {
  4501. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4502. }
  4503. }
  4504. if (!texts.Contains(item.CTypeName))
  4505. {
  4506. texts.Add(item.CTypeName);
  4507. }
  4508. }
  4509. }
  4510. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4511. if (transData.Count > 0)
  4512. {
  4513. foreach (TranslateResult item in transData)
  4514. {
  4515. if (!transDic.ContainsKey(item.Query))
  4516. {
  4517. transDic.Add(item.Query, item.Translation);
  4518. }
  4519. }
  4520. }
  4521. foreach (var item in _AirTicketReservations)
  4522. {
  4523. #region 处理固定数据
  4524. string[] FlightsCode = item.FlightsCode.Split('/');
  4525. if (FlightsCode.Length != 0)
  4526. {
  4527. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4528. if (_AirCompany != null)
  4529. {
  4530. string str = "--";
  4531. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4532. if (!string.IsNullOrEmpty(translateResult))
  4533. {
  4534. str = translateResult;
  4535. str = _airTicketResRep.Processing(str);
  4536. }
  4537. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4538. }
  4539. else
  4540. {
  4541. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4542. }
  4543. }
  4544. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4545. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4546. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4547. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4548. string names = "";
  4549. foreach (string clientName in nameArray)
  4550. {
  4551. names += clientName + ",";
  4552. }
  4553. if (!string.IsNullOrWhiteSpace(names))
  4554. {
  4555. string str = "--";
  4556. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4557. if (!string.IsNullOrEmpty(translateResult))
  4558. {
  4559. str = translateResult;
  4560. str = _airTicketResRep.Processing(str);
  4561. }
  4562. table.Range.Bookmarks["ClientName"].Text = str;
  4563. }
  4564. else
  4565. {
  4566. table.Range.Bookmarks["ClientName"].Text = "--";
  4567. }
  4568. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4569. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4570. table.Range.Bookmarks["JointTicket"].Text = "--";
  4571. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4572. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4573. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4574. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4575. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4576. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4577. #endregion
  4578. #region 循环数据处理
  4579. var airs = new List<AirInfo>();
  4580. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4581. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4582. for (int i = 0; i < FlightsCode.Length; i++)
  4583. {
  4584. var air = new AirInfo();
  4585. string[] tempstr = DayArray[i]
  4586. .Replace("\r\n", string.Empty)
  4587. .Replace("\\r\\n", string.Empty)
  4588. .TrimStart().TrimEnd()
  4589. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4590. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4591. string starCity = "";
  4592. if (star_Three != null)
  4593. {
  4594. string str2 = "--";
  4595. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4596. if (!string.IsNullOrEmpty(translateResult2))
  4597. {
  4598. str2 = translateResult2;
  4599. str2 = _airTicketResRep.Processing(str2);
  4600. }
  4601. starCity = str2;
  4602. }
  4603. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4604. string EndCity = "";
  4605. if (End_Three != null)
  4606. {
  4607. string str1 = "--";
  4608. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4609. if (!string.IsNullOrEmpty(translateResult1))
  4610. {
  4611. str1 = translateResult1;
  4612. str1 = _airTicketResRep.Processing(str1);
  4613. }
  4614. EndCity = str1;
  4615. }
  4616. air.Destination = starCity + "/" + EndCity;
  4617. air.Flight = FlightsCode[i];
  4618. string str = "--";
  4619. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4620. if (!string.IsNullOrEmpty(translateResult))
  4621. {
  4622. str = translateResult;
  4623. str = _airTicketResRep.Processing(str);
  4624. }
  4625. air.SeatingClass = str;
  4626. string dateTime = tempstr[2];
  4627. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4628. air.FlightDate = DateTemp;
  4629. air.DepartureTime = tempstr[5];
  4630. air.LandingTime = tempstr[6];
  4631. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4632. air.TicketStatus = "--";
  4633. air.Luggage = "--";
  4634. air.DepartureTerminal = "--";
  4635. air.LandingTerminal = "--";
  4636. airs.Add(air);
  4637. }
  4638. int row = 13;
  4639. for (int i = 0; i < airs.Count; i++)
  4640. {
  4641. if (airs.Count > 2)
  4642. {
  4643. for (int j = 0; j < airs.Count - 2; j++)
  4644. {
  4645. var CopyRow = table.Rows[12].Clone(true);
  4646. table.Rows.Add(CopyRow);
  4647. }
  4648. }
  4649. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4650. int index = 0;
  4651. foreach (PropertyInfo property in properties)
  4652. {
  4653. string value = property.GetValue(airs[i]).ToString();
  4654. Cell ishcel0 = table.Rows[row].Cells[index];
  4655. var p = new Paragraph(doc);
  4656. string s = value;
  4657. p.AppendChild(new Run(doc, s));
  4658. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4659. ishcel0.AppendChild(p);
  4660. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4661. //ishcel0.CellFormat.VerticalAlignment=
  4662. index++;
  4663. }
  4664. row++;
  4665. }
  4666. #endregion
  4667. var lastParagraph = new Paragraph(doc);
  4668. //第一个表格末尾加段落
  4669. table.ParentNode.InsertAfter(lastParagraph, table);
  4670. //复制第一个表格
  4671. Table cloneTable = (Table)table.Clone(true);
  4672. //在文档末尾段落后面加入复制的表格
  4673. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4674. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4675. {
  4676. int rownewsIndex = 13;
  4677. for (int i = 0; i < 2; i++)
  4678. {
  4679. var CopyRow = table.Rows[12].Clone(true);
  4680. table.Rows.RemoveAt(13);
  4681. table.Rows.Add(CopyRow);
  4682. rownewsIndex++;
  4683. }
  4684. }
  4685. else
  4686. {
  4687. table.Rows.RemoveAt(12);
  4688. }
  4689. cloneTable.Rows.RemoveAt(12);
  4690. }
  4691. if (_AirTicketReservations.Count != 0)
  4692. {
  4693. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4694. if (FlightsCode.Length != 0)
  4695. {
  4696. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4697. if (_AirCompany != null)
  4698. {
  4699. string str = "--";
  4700. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4701. if (!string.IsNullOrEmpty(translateResult))
  4702. {
  4703. str = translateResult;
  4704. str = _airTicketResRep.Processing(str);
  4705. }
  4706. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4707. }
  4708. else
  4709. {
  4710. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4711. }
  4712. }
  4713. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4714. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4715. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4716. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4717. string names = "";
  4718. foreach (string clientName in nameArray)
  4719. {
  4720. names += clientName + ",";
  4721. }
  4722. if (!string.IsNullOrWhiteSpace(names))
  4723. {
  4724. string str = "--";
  4725. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4726. if (!string.IsNullOrEmpty(translateResult))
  4727. {
  4728. str = translateResult;
  4729. str = _airTicketResRep.Processing(str);
  4730. }
  4731. table.Range.Bookmarks["ClientName"].Text = str;
  4732. }
  4733. else
  4734. {
  4735. table.Range.Bookmarks["ClientName"].Text = "--";
  4736. }
  4737. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4738. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4739. table.Range.Bookmarks["JointTicket"].Text = "--";
  4740. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4741. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4742. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4743. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4744. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4745. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4746. }
  4747. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4748. //保存合并后的文档
  4749. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4750. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4751. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4752. return Ok(JsonView(true, "成功!", rst));
  4753. }
  4754. }
  4755. }
  4756. catch (Exception ex)
  4757. {
  4758. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4759. throw;
  4760. }
  4761. }
  4762. #endregion
  4763. #region 团组增减款项 --> 其他款项
  4764. /// <summary>
  4765. /// 团组增减款项下拉框绑定
  4766. /// </summary>
  4767. /// <param name="dto"></param>
  4768. /// <returns></returns>
  4769. [HttpPost]
  4770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4771. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4772. {
  4773. #region 参数验证
  4774. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4775. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4776. #endregion
  4777. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4778. }
  4779. /// <summary>
  4780. /// 根据团组Id查询团组增减款项
  4781. /// </summary>
  4782. /// <param name="dto"></param>
  4783. /// <returns></returns>
  4784. [HttpPost]
  4785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4786. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4787. {
  4788. #region 参数验证
  4789. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4790. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4791. #endregion
  4792. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4793. }
  4794. /// <summary>
  4795. /// 团组增减款项操作(Status:1.新增,2.修改)
  4796. /// </summary>
  4797. /// <param name="dto"></param>
  4798. /// <returns></returns>
  4799. [HttpPost]
  4800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4801. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4802. {
  4803. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4804. if (groupData.Code != 200)
  4805. {
  4806. return Ok(JsonView(false, groupData.Msg));
  4807. }
  4808. #region 应用推送
  4809. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4810. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4811. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4812. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4813. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4814. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4815. //自动审核
  4816. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4817. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4818. //2024-10-21 新增LZ UID
  4819. var userIds = new List<int>() { 21 };
  4820. string title = $"系统通知";
  4821. string content = "";
  4822. var diId = dto.DiId;
  4823. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4824. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4825. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4826. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4827. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4828. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4829. #endregion
  4830. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4831. }
  4832. /// <summary>
  4833. /// 团组增减款项操作 删除
  4834. /// </summary>
  4835. /// <param name="dto"></param>
  4836. /// <returns></returns>
  4837. [HttpPost]
  4838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4839. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4840. {
  4841. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4842. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4843. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4844. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  4845. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  4846. }
  4847. /// <summary>
  4848. /// 根据团组增减款项Id查询
  4849. /// </summary>
  4850. /// <param name="dto"></param>
  4851. /// <returns></returns>
  4852. [HttpPost]
  4853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4854. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4855. {
  4856. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4857. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4858. }
  4859. /// <summary>
  4860. /// 查询供应商名称
  4861. /// </summary>
  4862. /// <param name="dto"></param>
  4863. /// <returns></returns>
  4864. [HttpPost]
  4865. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4866. {
  4867. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4868. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4869. ?? new List<Grp_DecreasePayments>();
  4870. dbResult = dbResult.Distinct(new
  4871. ProductComparer()).ToList();
  4872. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4873. {
  4874. x.Id,
  4875. x.SupplierAddress,
  4876. x.SupplierArea,
  4877. x.SupplierContact,
  4878. x.SupplierContactNumber,
  4879. x.SupplierEmail,
  4880. x.SupplierName,
  4881. x.SupplierSocialAccount,
  4882. x.SupplierTypeId,
  4883. }).ToList());
  4884. return Ok(jw);
  4885. }
  4886. /// <summary>
  4887. /// 团组增减款项 OTA匹配
  4888. /// </summary>
  4889. /// <param name="file"></param>
  4890. /// <returns></returns>
  4891. [HttpPost]
  4892. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4893. {
  4894. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4895. string fileName = file.FileName;
  4896. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4897. {
  4898. return Ok(JsonView(false, "请上传Excel文件!"));
  4899. }
  4900. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4901. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4902. if (!Directory.Exists(path))
  4903. {
  4904. Directory.CreateDirectory(path);
  4905. }
  4906. var filePath = @$"{path}/{fileName}";
  4907. //保存文件
  4908. using (FileStream fs = System.IO.File.Create(filePath))
  4909. {
  4910. file.CopyTo(fs);
  4911. fs.Flush();
  4912. }
  4913. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4914. //读取ExcelFile
  4915. DataTable dt = ConvertExcelToDataTable(filePath);
  4916. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4917. dt.TableName = "TB";
  4918. //修改table列名
  4919. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4920. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4921. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4922. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4923. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4924. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4925. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4926. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4927. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4928. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4929. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4930. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4931. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4932. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4933. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4934. var otaOrderNos = new List<string>();
  4935. foreach (DataRow item in dt.Rows)
  4936. {
  4937. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4938. }
  4939. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4940. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4941. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4942. .Select((dp, di) => new
  4943. {
  4944. dp.PriceName,
  4945. dp.OTAOrderNo,
  4946. dp.FeeTotal,
  4947. di.TeamName,
  4948. })
  4949. .ToListAsync();
  4950. foreach (DataRow item in dt.Rows)
  4951. {
  4952. var otaOrderNo = item["OTAOrderNo"].ToString();
  4953. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4954. if (oaData == null) continue;
  4955. item["GroupName"] = oaData.TeamName;
  4956. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4957. }
  4958. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  4959. var pairs = new Dictionary<string, object>();
  4960. var datas = new List<DataTable>
  4961. {
  4962. dt
  4963. };
  4964. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4965. return Ok(JsonView(true, "操作成功", new { url }));
  4966. }
  4967. #region
  4968. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  4969. {
  4970. // 创建Workbook对象
  4971. var workbook = new Workbook(excelFilePath);
  4972. // 获取第一个工作表
  4973. var worksheet = workbook.Worksheets[0];
  4974. // 将工作表转换为DataTable
  4975. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4976. return dataTable;
  4977. }
  4978. #endregion
  4979. /// <summary>
  4980. /// 世运会数据
  4981. /// </summary>
  4982. /// <returns></returns>
  4983. [HttpGet]
  4984. public IActionResult WorldGamesData()
  4985. {
  4986. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  4987. var groupMenu = setData.GroupBy(x => x.T0);
  4988. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  4989. foreach (var item in groupMenu)
  4990. {
  4991. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  4992. {
  4993. Data = new SetDataView
  4994. {
  4995. Name = item.Key
  4996. },
  4997. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  4998. });
  4999. }
  5000. return Ok(JsonView(true, "success", resultArr));
  5001. }
  5002. #endregion
  5003. #region 文件上传、删除
  5004. /// <summary>
  5005. /// region 文件上传 可以带参数
  5006. /// </summary>
  5007. /// <param name="file"></param>
  5008. /// <returns></returns>
  5009. [HttpPost]
  5010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5011. public async Task<IActionResult> UploadProject(IFormFile file)
  5012. {
  5013. //var TypeName = Request.Headers["TypeName"].ToString();
  5014. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5015. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5016. ////文件名称
  5017. //string projectFileName = file.FileName;
  5018. ////上传的文件的路径
  5019. //string filePath = $"{fileDir}/{projectFileName}";
  5020. //if (TypeName == "A")//A代表团组增减款项
  5021. //{
  5022. // filePath = fileDir + $@"\团组增减款项相关文件";
  5023. // if (!Directory.Exists(filePath))
  5024. // {
  5025. // Directory.CreateDirectory(filePath);
  5026. // }
  5027. // //上传的文件的路径
  5028. // filePath += $@"\{projectFileName}";
  5029. //}
  5030. //else if (TypeName == "B")//B代表商邀相关文件
  5031. //{
  5032. // //上传的文件的路径
  5033. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5034. // if (!Directory.Exists(filePath))
  5035. // {
  5036. // Directory.CreateDirectory(filePath);
  5037. // }
  5038. // //上传的文件的路径
  5039. // filePath = $@"\{projectFileName}";
  5040. //}
  5041. //try
  5042. //{
  5043. // using (FileStream fs = System.IO.File.Create(filePath))
  5044. // {
  5045. // file.CopyTo(fs);
  5046. // fs.Flush();
  5047. // }
  5048. //}
  5049. //catch (Exception ex)
  5050. //{
  5051. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5052. //}
  5053. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5054. try
  5055. {
  5056. var TypeName = Request.Headers["TypeName"].ToString();
  5057. if (file != null)
  5058. {
  5059. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5060. //文件名称
  5061. string projectFileName = file.FileName;
  5062. //上传的文件的路径
  5063. string filePath = $"{fileDir}/{projectFileName}";
  5064. if (TypeName == "A")//A代表团组增减款项
  5065. {
  5066. if (!Directory.Exists(fileDir))
  5067. {
  5068. Directory.CreateDirectory(fileDir);
  5069. }
  5070. //上传的文件的路径
  5071. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5072. }
  5073. else if (TypeName == "B")//B代表商邀相关文件
  5074. {
  5075. if (!Directory.Exists(fileDir))
  5076. {
  5077. Directory.CreateDirectory(fileDir);
  5078. }
  5079. //上传的文件的路径
  5080. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5081. }
  5082. using (FileStream fs = System.IO.File.Create(filePath))
  5083. {
  5084. file.CopyTo(fs);
  5085. fs.Flush();
  5086. }
  5087. return Ok(JsonView(true, "上传成功!", projectFileName));
  5088. }
  5089. else
  5090. {
  5091. return Ok(JsonView(false, "上传失败!"));
  5092. }
  5093. }
  5094. catch (Exception ex)
  5095. {
  5096. return Ok(JsonView(false, ex.Message));
  5097. }
  5098. }
  5099. /// <summary>
  5100. /// 删除指定文件
  5101. /// </summary>
  5102. /// <param name="dto"></param>
  5103. /// <returns></returns>
  5104. [HttpPost]
  5105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5106. public async Task<IActionResult> DelFile(DelFileDto dto)
  5107. {
  5108. try
  5109. {
  5110. var TypeName = Request.Headers["TypeName"].ToString();
  5111. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5112. string filePath = "";
  5113. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5114. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5115. int id = 0;
  5116. if (TypeName == "A")
  5117. {
  5118. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5119. // 删除该文件
  5120. System.IO.File.Delete(filePath);
  5121. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5122. .Where(a => a.Id == dto.Id)
  5123. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5124. .ExecuteCommandAsync();
  5125. }
  5126. else if (TypeName == "B")
  5127. {
  5128. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5129. // 删除该文件
  5130. System.IO.File.Delete(filePath);
  5131. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5132. if (info != null)
  5133. {
  5134. string[] files = Array.Empty<string>();
  5135. if (!string.IsNullOrEmpty(info.Attachment))
  5136. {
  5137. try
  5138. {
  5139. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5140. }
  5141. catch (Exception)
  5142. {
  5143. files = new List<string>() { info.Attachment }.ToArray();
  5144. }
  5145. }
  5146. if (files.Length > 0)
  5147. {
  5148. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5149. string filePath2 = string.Empty;
  5150. if (files1.Length > 0)
  5151. {
  5152. filePath2 = JsonConvert.SerializeObject(files1);
  5153. }
  5154. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5155. .Where(a => a.Id == dto.Id)
  5156. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5157. .ExecuteCommandAsync();
  5158. }
  5159. }
  5160. }
  5161. if (id != 0)
  5162. {
  5163. return Ok(JsonView(true, "成功!"));
  5164. }
  5165. else
  5166. {
  5167. return Ok(JsonView(false, "失败!"));
  5168. }
  5169. }
  5170. catch (Exception ex)
  5171. {
  5172. return Ok(JsonView(false, "程序错误!"));
  5173. throw;
  5174. }
  5175. }
  5176. /// <summary>
  5177. /// 文件上传多个文件 可以带参数
  5178. /// </summary>
  5179. /// <param name="files"></param>
  5180. /// <returns></returns>
  5181. [HttpPost]
  5182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5183. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5184. {
  5185. try
  5186. {
  5187. var TypeName = Request.Headers["TypeName"].ToString();
  5188. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5189. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5190. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5191. var filePahts = new List<string>();
  5192. foreach (var file in files)
  5193. {
  5194. //文件名称
  5195. string projectFileName = file.FileName;
  5196. //上传的文件的路径
  5197. string filePath = $"{fileDir}/{projectFileName}";
  5198. if (TypeName == "A")//A代表团组增减款项
  5199. {
  5200. if (!Directory.Exists(fileDir))
  5201. {
  5202. Directory.CreateDirectory(fileDir);
  5203. }
  5204. //上传的文件的路径
  5205. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5206. }
  5207. else if (TypeName == "B")//B代表商邀相关文件
  5208. {
  5209. if (!Directory.Exists(fileDir))
  5210. {
  5211. Directory.CreateDirectory(fileDir);
  5212. }
  5213. //上传的文件的路径
  5214. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5215. }
  5216. using (FileStream fs = System.IO.File.Create(filePath))
  5217. {
  5218. file.CopyTo(fs);
  5219. fs.Flush();
  5220. }
  5221. filePahts.Add(projectFileName);
  5222. }
  5223. return Ok(JsonView(true, "上传成功!", filePahts));
  5224. }
  5225. catch (Exception ex)
  5226. {
  5227. return Ok(JsonView(false, ex.Message));
  5228. }
  5229. }
  5230. #endregion
  5231. #region 商邀费用录入
  5232. /// <summary>
  5233. /// 根据团组Id查询商邀费用列表
  5234. /// </summary>
  5235. /// <param name="dto"></param>
  5236. /// <returns></returns>
  5237. [HttpPost]
  5238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5239. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5240. {
  5241. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5242. if (groupData.Code != 0)
  5243. {
  5244. return Ok(JsonView(false, groupData.Msg));
  5245. }
  5246. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5247. }
  5248. /// <summary>
  5249. /// 商邀费用列表
  5250. /// 下载文件
  5251. /// </summary>
  5252. /// <param name="id"></param>
  5253. /// <returns></returns>
  5254. [HttpGet("{id}")]
  5255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5256. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5257. {
  5258. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5259. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5260. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5261. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5262. var filePaths = new List<string>();
  5263. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5264. try
  5265. {
  5266. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5267. }
  5268. catch (Exception ex)
  5269. {
  5270. filePaths.Add(info.Attachment);
  5271. }
  5272. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5273. for (int i = 0; i < filePaths.Count; i++)
  5274. {
  5275. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5276. }
  5277. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5278. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5279. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5280. {
  5281. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5282. {
  5283. foreach (string filePath in filePaths)
  5284. {
  5285. if (System.IO.File.Exists(filePath))
  5286. {
  5287. // 获取文件名
  5288. string fileName = Path.GetFileName(filePath);
  5289. // 将文件添加到ZIP归档中
  5290. zipArchive.CreateEntryFromFile(filePath, fileName);
  5291. }
  5292. }
  5293. }
  5294. }
  5295. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5296. }
  5297. /// <summary>
  5298. /// 商邀费用 Info Page 基础数据源
  5299. /// </summary>
  5300. /// <returns></returns>
  5301. [HttpPost]
  5302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5303. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5304. {
  5305. try
  5306. {
  5307. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5308. if (groupData.Code != 0)
  5309. {
  5310. return Ok(JsonView(false, groupData.Msg));
  5311. }
  5312. return Ok(JsonView(true, "操作成功", groupData.Data));
  5313. }
  5314. catch (Exception ex)
  5315. {
  5316. return Ok(JsonView(false, ex.Message));
  5317. throw;
  5318. }
  5319. }
  5320. /// <summary>
  5321. /// 根据商邀费用ID查询C表和商邀费用数据
  5322. /// </summary>
  5323. /// <param name="dto"></param>
  5324. /// <returns></returns>
  5325. [HttpPost]
  5326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5327. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5328. {
  5329. try
  5330. {
  5331. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5332. if (groupData.Code != 0)
  5333. {
  5334. return Ok(JsonView(false, groupData.Msg));
  5335. }
  5336. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5337. }
  5338. catch (Exception ex)
  5339. {
  5340. return Ok(JsonView(false, ex.Message));
  5341. throw;
  5342. }
  5343. }
  5344. /// <summary>
  5345. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5346. /// </summary>
  5347. /// <param name="dto"></param>
  5348. /// <returns></returns>
  5349. [HttpPost]
  5350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5351. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5352. {
  5353. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5354. if (groupData.Code != 0)
  5355. {
  5356. return Ok(JsonView(false, groupData.Msg));
  5357. }
  5358. #region 应用推送
  5359. try
  5360. {
  5361. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5362. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5363. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5364. //2024-10-21 新增LZ UID
  5365. var userIds = new List<int>() { 21 };
  5366. string title = $"系统通知";
  5367. string content = "";
  5368. var diId = dto.DiId;
  5369. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5370. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5371. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5372. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5373. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5374. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5375. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5376. }
  5377. catch (Exception ex)
  5378. {
  5379. }
  5380. #endregion
  5381. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5382. }
  5383. /// <summary>
  5384. /// 商邀删除
  5385. /// </summary>
  5386. /// <param name="dto"></param>
  5387. /// <returns></returns>
  5388. [HttpPost]
  5389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5390. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5391. {
  5392. try
  5393. {
  5394. _sqlSugar.BeginTran();
  5395. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5396. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5397. {
  5398. IsDel = 1,
  5399. DeleteUserId = dto.DeleteUserId,
  5400. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5401. })
  5402. .Where(it => it.Id == dto.Id)
  5403. .ExecuteCommand();
  5404. if (res1 > 0)
  5405. {
  5406. int _diId = 0;
  5407. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5408. if (_ioaInfo != null)
  5409. {
  5410. _diId = _ioaInfo.DiId;
  5411. }
  5412. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5413. .SetColumns(a => new Grp_CreditCardPayment()
  5414. {
  5415. IsDel = 1,
  5416. DeleteUserId = dto.DeleteUserId,
  5417. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5418. })
  5419. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5420. .ExecuteCommand();
  5421. if (res2 > 0)
  5422. {
  5423. _sqlSugar.CommitTran();
  5424. return Ok(JsonView(true, "删除成功!"));
  5425. }
  5426. }
  5427. _sqlSugar.RollbackTran();
  5428. return Ok(JsonView(false, "删除失败"));
  5429. }
  5430. catch (Exception ex)
  5431. {
  5432. _sqlSugar.RollbackTran();
  5433. return Ok(JsonView(false, ex.Message));
  5434. }
  5435. }
  5436. #endregion
  5437. #region 票据上传
  5438. /// <summary>
  5439. /// 团组模块文件上传
  5440. /// </summary>
  5441. /// <param name="dto"></param>
  5442. /// <returns></returns>
  5443. [HttpPost]
  5444. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5445. {
  5446. var jw = JsonView(false);
  5447. long M = 1024 * 1024;
  5448. if (dto.Files == null || dto.Files.Count == 0)
  5449. {
  5450. jw.Msg = "无文件信息!";
  5451. return Ok(jw);
  5452. }
  5453. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5454. {
  5455. jw.Msg = "文件大小超过20M!";
  5456. return Ok(jw);
  5457. }
  5458. //var nameSp = dto.File.FileName.Split(".");
  5459. //if (nameSp.Length < 2)
  5460. //{
  5461. // jw.Msg = "拓展名称有误!";
  5462. // return Ok(jw);
  5463. //}
  5464. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5465. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5466. //{
  5467. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5468. // return Ok(jw);
  5469. //}
  5470. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5471. if (Ctable == null)
  5472. {
  5473. jw.Msg = "Ctable指向有误!";
  5474. return Ok(jw);
  5475. }
  5476. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5477. if (groupInfo == null)
  5478. {
  5479. jw.Msg = "团组信息不存在!";
  5480. return Ok(jw);
  5481. }
  5482. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5483. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5484. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5485. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5486. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5487. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5488. try
  5489. {
  5490. if (!Directory.Exists(fileBase))
  5491. {
  5492. Directory.CreateDirectory(fileBase);
  5493. }
  5494. var saveArr = new List<Grp_GroupModelFile>();
  5495. foreach (var fileStream in dto.Files)
  5496. {
  5497. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5498. var file = new Grp_GroupModelFile()
  5499. {
  5500. Cid = dto.Cid,
  5501. CreateTime = DateTime.Now,
  5502. CreateUserId = dto.Userid,
  5503. Ctable = dto.Ctable,
  5504. Diid = dto.Diid,
  5505. IsDel = 0,
  5506. FilePath = saveFilePath,
  5507. FileName = fileStream.FileName
  5508. };
  5509. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5510. {
  5511. fileStream.CopyTo(fs);
  5512. fs.Flush();
  5513. }
  5514. saveArr.Add(file);
  5515. }
  5516. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5517. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5518. jw = JsonView(true, "保存成功!", new
  5519. {
  5520. count = addResult,
  5521. filesName = saveArr.Select(x => x.FileName)
  5522. });
  5523. }
  5524. catch (Exception ex)
  5525. {
  5526. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5527. {
  5528. count = 0,
  5529. filesName = Array.Empty<string>(),
  5530. });
  5531. }
  5532. return Ok(jw);
  5533. }
  5534. /// <summary>
  5535. /// 查询各模块已保存文件
  5536. /// </summary>
  5537. /// <param name="dto"></param>
  5538. /// <returns></returns>
  5539. [HttpPost]
  5540. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5541. {
  5542. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5543. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5544. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5545. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5546. {
  5547. expression = Expressionable.Create<Grp_GroupModelFile>()
  5548. .And(x => visaIds.Contains(x.CreateUserId));
  5549. }
  5550. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5551. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5552. .Where(expression.ToExpression())
  5553. .ToList();
  5554. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5555. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5556. {
  5557. x.FileName,
  5558. x.Id,
  5559. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5560. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5561. })));
  5562. }
  5563. /// <summary>
  5564. /// 下载该团组下的所有文件
  5565. /// </summary>
  5566. /// <param name="dto"></param>
  5567. /// <returns></returns>
  5568. [HttpPost]
  5569. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5570. {
  5571. var jw = JsonView(false);
  5572. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5573. if (groupInfo == null)
  5574. {
  5575. jw.Msg = "团组信息不存在!";
  5576. return Ok(jw);
  5577. }
  5578. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5579. var isModule = Convert.ToBoolean(dto.isModule);
  5580. var Zips = new Dictionary<string, Stream>();
  5581. var io = new IOOperatorHelper();
  5582. if (isModule)
  5583. {
  5584. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5585. foreach (var moduleArr in moduleGroup)
  5586. {
  5587. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5588. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5589. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5590. var chiZips = new Dictionary<string, Stream>();
  5591. foreach (var item in moduleArr)
  5592. {
  5593. if (System.IO.File.Exists(item.FilePath))
  5594. {
  5595. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5596. {
  5597. byte[] bytes = new byte[fileStream.Length];
  5598. fileStream.Read(bytes, 0, bytes.Length);
  5599. fileStream.Close();
  5600. Stream stream = new MemoryStream(bytes);
  5601. chiZips.Add(item.FileName, stream);
  5602. }
  5603. }
  5604. }
  5605. if (chiZips.Count > 0)
  5606. {
  5607. var byts = io.ConvertZipStream(chiZips);
  5608. Stream stream = new MemoryStream(byts);
  5609. Zips.Add(key.Name + "_.zip", stream);
  5610. }
  5611. }
  5612. }
  5613. else
  5614. {
  5615. foreach (var item in dbQuery)
  5616. {
  5617. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5618. {
  5619. byte[] bytes = new byte[fileStream.Length];
  5620. fileStream.Read(bytes, 0, bytes.Length);
  5621. fileStream.Close();
  5622. var stream = new MemoryStream(bytes);
  5623. while (Zips.ContainsKey(item.FileName))
  5624. {
  5625. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5626. }
  5627. Zips.Add(item.FileName, stream);
  5628. }
  5629. }
  5630. }
  5631. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5632. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5633. if (Zips.Count > 0)
  5634. {
  5635. var byts = io.ConvertZipStream(Zips);
  5636. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5637. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5638. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5639. }
  5640. else
  5641. {
  5642. jw.Msg = "暂无生成文件!";
  5643. }
  5644. return Ok(jw);
  5645. }
  5646. /// <summary>
  5647. /// 下载该团组下此模块的所有文件
  5648. /// </summary>
  5649. /// <param name="dto"></param>
  5650. /// <returns></returns>
  5651. [HttpPost]
  5652. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5653. {
  5654. var jw = JsonView(false);
  5655. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5656. if (groupInfo == null)
  5657. {
  5658. jw.Msg = "团组信息不存在!";
  5659. return Ok(jw);
  5660. }
  5661. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5662. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5663. && x.IsDel == 0);
  5664. if (key == null)
  5665. {
  5666. jw.Msg = "Ctable指向错误!";
  5667. return Ok(jw);
  5668. }
  5669. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5670. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5671. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5672. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5673. var io = new IOOperatorHelper();
  5674. var Zips = new Dictionary<string, Stream>();
  5675. foreach (var item in dbQuery)
  5676. {
  5677. if (System.IO.File.Exists(item.FilePath))
  5678. {
  5679. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5680. {
  5681. byte[] bytes = new byte[fileStream.Length];
  5682. fileStream.Read(bytes, 0, bytes.Length);
  5683. fileStream.Close();
  5684. var stream = new MemoryStream(bytes);
  5685. while (Zips.ContainsKey(item.FileName))
  5686. {
  5687. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5688. }
  5689. Zips.Add(item.FileName, stream);
  5690. }
  5691. }
  5692. }
  5693. if (Zips.Count > 0)
  5694. {
  5695. var byts = io.ConvertZipStream(Zips);
  5696. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5697. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5698. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5699. }
  5700. else
  5701. {
  5702. jw.Msg = "暂无生成文件!";
  5703. }
  5704. return Ok(jw);
  5705. }
  5706. /// <summary>
  5707. /// 删除该团组下的指定文件
  5708. /// </summary>
  5709. /// <param name="dto"></param>
  5710. /// <returns></returns>
  5711. [HttpPost]
  5712. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5713. {
  5714. var jw = JsonView(false);
  5715. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5716. if (sing == null)
  5717. {
  5718. jw.Msg = "暂无";
  5719. return Ok(jw);
  5720. }
  5721. if (System.IO.File.Exists(sing.FilePath))
  5722. {
  5723. try
  5724. {
  5725. System.IO.File.Delete(sing.FilePath);
  5726. }
  5727. catch (Exception ex)
  5728. {
  5729. jw.Msg = "删除失败!" + ex.Message;
  5730. return Ok(jw);
  5731. }
  5732. }
  5733. sing.IsDel = 1;
  5734. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5735. sing.DeleteUserId = dto.UserId;
  5736. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5737. jw = JsonView(true, "删除成功!");
  5738. return Ok(jw);
  5739. }
  5740. #endregion
  5741. #region 共享文件上传
  5742. /// <summary>
  5743. /// 共享文件数据初始化
  5744. /// </summary>
  5745. /// <returns></returns>
  5746. [HttpGet]
  5747. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5748. {
  5749. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5750. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5751. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5752. .Select(x => x.Id)
  5753. .ToList()
  5754. .Contains(userid);
  5755. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5756. .Where(x => x.STid == 111 && x.IsDel == 0)
  5757. .Select(x => new
  5758. {
  5759. x.Name,
  5760. x.Id,
  5761. }).ToList();
  5762. if (isMarketingDepartment)
  5763. {
  5764. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5765. }
  5766. if (portType == 1)
  5767. {
  5768. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5769. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5770. .Where(x => x.IsDel == 0)
  5771. .OrderByDescending(x => x.VisitDate)
  5772. .Select(x => new
  5773. {
  5774. x.TeamName,
  5775. x.Id,
  5776. x.CityId,
  5777. })
  5778. .ToList()
  5779. .Select(x =>
  5780. {
  5781. var provinceId = x.CityId;
  5782. var isDefualtVal = true;
  5783. if (provinceId > 0)
  5784. {
  5785. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5786. if (parentId != null)
  5787. {
  5788. isDefualtVal = false;
  5789. provinceId = (int)parentId;
  5790. }
  5791. }
  5792. if (isDefualtVal)
  5793. {
  5794. provinceId = 122; //默认四川
  5795. }
  5796. return new
  5797. {
  5798. x.TeamName,
  5799. x.Id,
  5800. provinceId,
  5801. };
  5802. })
  5803. .ToList();
  5804. return Ok(JsonView(true, "SUCCESS!", new
  5805. {
  5806. dropDownType,
  5807. dropDownGroupList,
  5808. isMarketingDepartment
  5809. }));
  5810. }
  5811. else if (portType == 2 || portType == 3)
  5812. {
  5813. return Ok(JsonView(true, "SUCCESS!", new
  5814. {
  5815. dropDownType,
  5816. isMarketingDepartment
  5817. }));
  5818. }
  5819. else
  5820. {
  5821. return Ok(JsonView(false, "portType有误!"));
  5822. }
  5823. }
  5824. /// <summary>
  5825. /// 共享文件上传
  5826. /// </summary>
  5827. /// <param name="dto"></param>
  5828. /// <returns></returns>
  5829. [HttpPost]
  5830. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5831. {
  5832. var isGroup = new List<int> { 1412 };
  5833. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5834. {
  5835. return Ok(JsonView(false, "该文件需要关联团组!"));
  5836. }
  5837. if (dto.Files == null || dto.Files.Count == 0)
  5838. {
  5839. return Ok(JsonView(false, "无文件信息!"));
  5840. }
  5841. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5842. {
  5843. return Ok(JsonView(false, "文件大小超过20M!"));
  5844. }
  5845. if (dto.Userid < 1)
  5846. {
  5847. return Ok(JsonView(false, "请传入有效的Userid!"));
  5848. }
  5849. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5850. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5851. .Select((u, j) => new
  5852. {
  5853. u.CnName,
  5854. UserId = u.Id,
  5855. j.JobName,
  5856. })
  5857. .First();
  5858. if (jobInfo == null)
  5859. {
  5860. return Ok(JsonView(false, "请传入有效的Userid!"));
  5861. }
  5862. var commonFileExtensions = new List<string>
  5863. {
  5864. // 文本文件
  5865. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5866. // 图片文件
  5867. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5868. // 视频文件
  5869. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5870. // 音频文件
  5871. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5872. // 压缩文件
  5873. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5874. // 数据文件
  5875. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5876. };
  5877. try
  5878. {
  5879. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5880. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5881. commonFileExtensions.AddRange(settingExtend);
  5882. }
  5883. catch (Exception)
  5884. { }
  5885. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5886. if (setdata == null)
  5887. {
  5888. return Ok(JsonView(false, "请传入有效的FileType!"));
  5889. }
  5890. var insertList = new List<Grp_GroupShareFile>();
  5891. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5892. if (!Directory.Exists(winPath))
  5893. {
  5894. Directory.CreateDirectory(winPath);
  5895. }
  5896. foreach (var item in dto.Files)
  5897. {
  5898. var houzui = Path.GetExtension(item.FileName);
  5899. if (!commonFileExtensions.Contains(houzui))
  5900. {
  5901. return Ok(JsonView(false, "未知后缀名称!"));
  5902. }
  5903. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5904. var saveFilePath = winPath + fileName;
  5905. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5906. {
  5907. item.CopyTo(fs);
  5908. fs.Flush();
  5909. }
  5910. var fileDetail = new Grp_GroupShareFile()
  5911. {
  5912. CreateUserId = dto.Userid,
  5913. CreateTime = DateTime.Now,
  5914. UploadJob = jobInfo.JobName,
  5915. FileName = fileName,
  5916. FileType = dto.FileType,
  5917. Diid = dto.Diid,
  5918. FilePath = winPath + fileName,
  5919. };
  5920. insertList.Add(fileDetail);
  5921. }
  5922. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5923. return Ok(JsonView(true, "保存成功!"));
  5924. }
  5925. /// <summary>
  5926. /// 查询共享文件列表
  5927. /// </summary>
  5928. /// <param name="dto"></param>
  5929. /// <returns></returns>
  5930. [HttpPost]
  5931. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5932. {
  5933. var isGroup = new List<int> { 1412 };
  5934. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5935. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5936. .And(x => x.Diid == dto.Diid)
  5937. .And(x => x.FileType == dto.FileType)
  5938. .And(x => x.IsDel == 0)
  5939. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5940. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5941. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5942. int totalCount = 0;
  5943. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5944. .Where(queryExpression.ToExpression())
  5945. .OrderBy(x => x.UploadJob)
  5946. .Select(x => new
  5947. {
  5948. x.Id,
  5949. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5950. x.FileName,
  5951. x.FileType,
  5952. x.CreateTime,
  5953. })
  5954. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5955. return Ok(JsonView(true, "SUCCESS!", new
  5956. {
  5957. FileList = dbQuery,
  5958. dto.PageSize,
  5959. dto.PageIndex,
  5960. totalCount
  5961. }));
  5962. }
  5963. /// <summary>
  5964. /// 删除共享文件模块下的指定文件
  5965. /// </summary>
  5966. /// <param name="dto"></param>
  5967. /// <returns></returns>
  5968. [HttpPost]
  5969. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5970. {
  5971. var jw = JsonView(false);
  5972. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5973. if (sing == null)
  5974. {
  5975. jw.Msg = "暂无文件信息!";
  5976. return Ok(jw);
  5977. }
  5978. if (sing.CreateUserId != dto.UserId)
  5979. {
  5980. jw.Msg = "只能删除自己上传的文件!";
  5981. return Ok(jw);
  5982. }
  5983. if (System.IO.File.Exists(sing.FilePath))
  5984. {
  5985. try
  5986. {
  5987. System.IO.File.Delete(sing.FilePath);
  5988. }
  5989. catch (Exception ex)
  5990. {
  5991. jw.Msg = "删除失败!" + ex.Message;
  5992. return Ok(jw);
  5993. }
  5994. }
  5995. sing.IsDel = 1;
  5996. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5997. sing.DeleteUserId = dto.UserId;
  5998. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5999. jw = JsonView(true, "删除成功!");
  6000. return Ok(jw);
  6001. }
  6002. #endregion
  6003. #region 团组英文资料
  6004. /// <summary>
  6005. /// 查询团组英文所有资料
  6006. /// </summary>
  6007. /// <param name="dto"></param>
  6008. /// <returns></returns>
  6009. [HttpPost]
  6010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6011. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6012. {
  6013. try
  6014. {
  6015. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6016. if (groupData.Code != 0)
  6017. {
  6018. return Ok(JsonView(false, groupData.Msg));
  6019. }
  6020. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6021. }
  6022. catch (Exception ex)
  6023. {
  6024. return Ok(JsonView(false, ex.Message));
  6025. throw;
  6026. }
  6027. }
  6028. /// <summary>
  6029. /// 团组英文资料操作(Status:1.新增,2.修改)
  6030. /// </summary>
  6031. /// <param name="dto"></param>
  6032. /// <returns></returns>
  6033. [HttpPost]
  6034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6035. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6036. {
  6037. try
  6038. {
  6039. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6040. if (groupData.Code != 0)
  6041. {
  6042. return Ok(JsonView(false, groupData.Msg));
  6043. }
  6044. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6045. }
  6046. catch (Exception ex)
  6047. {
  6048. return Ok(JsonView(false, ex.Message));
  6049. throw;
  6050. }
  6051. }
  6052. /// <summary>
  6053. /// 团组英文资料Id查询数据
  6054. /// </summary>
  6055. /// <param name="dto"></param>
  6056. /// <returns></returns>
  6057. [HttpPost]
  6058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6059. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6060. {
  6061. try
  6062. {
  6063. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6064. if (_DelegationEnData != null)
  6065. {
  6066. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6067. }
  6068. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6069. }
  6070. catch (Exception ex)
  6071. {
  6072. return Ok(JsonView(false, "程序错误!"));
  6073. throw;
  6074. }
  6075. }
  6076. /// <summary>
  6077. /// 团组英文资料删除
  6078. /// </summary>
  6079. /// <param name="dto"></param>
  6080. /// <returns></returns>
  6081. [HttpPost]
  6082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6083. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6084. {
  6085. try
  6086. {
  6087. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6088. if (!res)
  6089. {
  6090. return Ok(JsonView(false, "删除失败"));
  6091. }
  6092. return Ok(JsonView(true, "删除成功!"));
  6093. }
  6094. catch (Exception ex)
  6095. {
  6096. return Ok(JsonView(false, ex.Message));
  6097. throw;
  6098. }
  6099. }
  6100. #endregion
  6101. #region 导出邀请函
  6102. /// <summary>
  6103. /// 导出邀请函页面初始化
  6104. /// </summary>
  6105. /// <param name="dto"></param>
  6106. /// <returns></returns>
  6107. [HttpPost]
  6108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6109. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6110. {
  6111. try
  6112. {
  6113. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6114. var crm_Deles = new List<Crm_DeleClient>();
  6115. if (dto.DiId == 0)
  6116. {
  6117. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6118. }
  6119. else
  6120. {
  6121. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6122. }
  6123. return Ok(JsonView(true, "查询成功!", new
  6124. {
  6125. deleClient = crm_Deles,
  6126. delegations = grp_Delegations
  6127. }));
  6128. }
  6129. catch (Exception ex)
  6130. {
  6131. return Ok(JsonView(false, "程序错误!"));
  6132. throw;
  6133. }
  6134. }
  6135. /// <summary>
  6136. /// 导出邀请函
  6137. /// </summary>
  6138. /// <param name="dto"></param>
  6139. /// <returns></returns>
  6140. [HttpPost]
  6141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6142. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6143. {
  6144. #region 参数验证
  6145. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6146. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6147. #endregion
  6148. try
  6149. {
  6150. var transDic = new Dictionary<string, string>();
  6151. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6152. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6153. From Grp_TourClientList tcl
  6154. Left Join
  6155. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6156. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6157. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6158. From Crm_DeleClient dc
  6159. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6160. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6161. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6162. Where dc.IsDel = 0) temp
  6163. On temp.DcId =tcl.ClientId
  6164. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6165. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6166. var texts = new List<string>();
  6167. if (datas.Count != 0)
  6168. {
  6169. foreach (TourClientListDetailsView item in datas)
  6170. {
  6171. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6172. {
  6173. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6174. }
  6175. else
  6176. {
  6177. string name = item.LastName + item.FirstName;
  6178. texts.Add(name);
  6179. }
  6180. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6181. {
  6182. if (!transDic.ContainsKey(item.Job))
  6183. {
  6184. texts.Add(item.Job);
  6185. }
  6186. }
  6187. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6188. {
  6189. texts.Add(item.CompanyFullName);
  6190. }
  6191. }
  6192. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6193. if (transData.Count > 0)
  6194. {
  6195. foreach (TranslateResult item in transData)
  6196. {
  6197. if (!transDic.ContainsKey(item.Query))
  6198. {
  6199. transDic.Add(item.Query, item.Translation);
  6200. }
  6201. }
  6202. }
  6203. var list = new List<GuestList>();
  6204. foreach (var dele in datas)
  6205. {
  6206. var guestList = new GuestList();
  6207. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6208. {
  6209. guestList.Name = dele.Pinyin;
  6210. }
  6211. else
  6212. {
  6213. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6214. guestList.Name = Name;
  6215. }
  6216. if (dele.Sex == 0)
  6217. {
  6218. guestList.Sex = "Male";
  6219. }
  6220. else if (dele.Sex == 1)
  6221. {
  6222. guestList.Sex = "Female";
  6223. }
  6224. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6225. if (!string.IsNullOrEmpty(dele.Job))
  6226. {
  6227. guestList.Job = dele.Job;
  6228. }
  6229. list.Add(guestList);
  6230. }
  6231. //载入模板
  6232. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6233. var builder = new DocumentBuilder(doc);
  6234. //获取word里所有表格
  6235. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6236. //获取所填表格的序数
  6237. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6238. var rowStart = tableOne.Rows[0]; //获取第1行
  6239. //循环赋值
  6240. for (int i = 0; i < list.Count; i++)
  6241. {
  6242. builder.MoveToCell(0, i + 1, 0, 0);
  6243. builder.Write(list[i].Name.ToString());
  6244. builder.MoveToCell(0, i + 1, 1, 0);
  6245. builder.Write(list[i].Sex.ToString());
  6246. builder.MoveToCell(0, i + 1, 2, 0);
  6247. builder.Write(list[i].DOB.ToString());
  6248. builder.MoveToCell(0, i + 1, 3, 0);
  6249. builder.Write(list[i].Job.ToString());
  6250. }
  6251. //删除多余行
  6252. while (tableOne.Rows.Count > list.Count + 1)
  6253. {
  6254. tableOne.Rows.RemoveAt(list.Count + 1);
  6255. }
  6256. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6257. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6258. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6259. doc.Save(filePath);
  6260. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6261. return Ok(JsonView(true, "操作成功!", Url));
  6262. }
  6263. else
  6264. {
  6265. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6266. }
  6267. }
  6268. catch (Exception ex)
  6269. {
  6270. return Ok(JsonView(false, ex.Message));
  6271. throw;
  6272. }
  6273. }
  6274. #endregion
  6275. #region 团组经理模块 出入境费用
  6276. /// <summary>
  6277. /// 团组模块 - 出入境费用 - 省份基础数据源
  6278. /// </summary>
  6279. /// <returns></returns>
  6280. [HttpGet]
  6281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6282. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6283. {
  6284. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6285. }
  6286. /// <summary>
  6287. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6288. /// </summary>
  6289. /// <param name="dto"></param>
  6290. /// <returns></returns>
  6291. [HttpPost]
  6292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6293. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6294. {
  6295. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6296. var groupNamFirst = groupNameData.FirstOrDefault();
  6297. //SetDataInfoView
  6298. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6299. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6300. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6301. //验证城市归属并给默认值
  6302. int provinceId = 122;
  6303. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6304. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6305. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6306. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6307. return Ok(JsonView(true, "查询成功!", new
  6308. {
  6309. GroupNameData = groupNameData,
  6310. CurrencyData = _CurrencyData,
  6311. WordTypeData = wordTypeData,
  6312. ExcelTypeData = excelTypeData,
  6313. CurrencyInit = _currencyInfos,
  6314. ViewPermissionData = viewPermissionData
  6315. }));
  6316. }
  6317. /// <summary>
  6318. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6319. /// </summary>
  6320. /// <returns></returns>
  6321. [HttpGet("{provinceId}")]
  6322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6323. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6324. {
  6325. //验证城市归属并给默认值
  6326. if (provinceId < 1) provinceId = 122;
  6327. /*
  6328. * 122 四川
  6329. * 108 贵州
  6330. * 103 重庆
  6331. * 132 云南
  6332. */
  6333. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6334. return Ok(JsonView(true, "查询成功!", new
  6335. {
  6336. WordTypeData = wordTypeData,
  6337. ExcelTypeData = excelTypeData,
  6338. }));
  6339. }
  6340. /// <summary>
  6341. /// 团组模块 - 出入境费用
  6342. /// 实时汇率 tips
  6343. /// 签证费用 tips
  6344. /// 机票费用 tips
  6345. /// </summary>
  6346. /// <returns></returns>
  6347. [HttpPost]
  6348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6349. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6350. {
  6351. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6352. //默认币种显示
  6353. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6354. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6355. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6356. return Ok(JsonView(true, "查询成功!", new
  6357. {
  6358. //GroupNameData = groupNameData.Data,
  6359. visaData = visaData.Data,
  6360. airData,
  6361. reteInfos
  6362. }));
  6363. }
  6364. /// <summary>
  6365. /// 团组模块 - 出入境费用 - Info
  6366. /// </summary>
  6367. /// <param name="dto"></param>
  6368. /// <returns></returns>
  6369. [HttpPost]
  6370. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6372. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6373. {
  6374. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6375. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6376. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6377. }
  6378. /// <summary>
  6379. /// 团组模块 - 出入境费用 - 设置view权限
  6380. /// </summary>
  6381. /// <returns></returns>
  6382. [HttpPost]
  6383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6384. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6385. {
  6386. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6387. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6388. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6389. var permissions = new List<Grp_EnterExitCostPermission>();
  6390. foreach (var userId in dto.UserIds)
  6391. {
  6392. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6393. }
  6394. if (permissions.Any())
  6395. {
  6396. _sqlSugar.BeginTran();
  6397. try
  6398. {
  6399. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6400. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6401. if (result < 1)
  6402. {
  6403. _sqlSugar.RollbackTran();
  6404. return Ok(JsonView(false));
  6405. }
  6406. }
  6407. catch (Exception ex)
  6408. {
  6409. _sqlSugar.RollbackTran();
  6410. return Ok(JsonView(false, ex.Message));
  6411. }
  6412. _sqlSugar.CommitTran();
  6413. return Ok(JsonView(true));
  6414. }
  6415. return Ok(JsonView(false));
  6416. }
  6417. /// <summary>
  6418. /// 团组模块 - 出入境费用 - Add And Update
  6419. /// </summary>
  6420. /// <returns></returns>
  6421. [HttpPost]
  6422. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6424. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6425. {
  6426. try
  6427. {
  6428. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6429. if (dto.DayOtherPriceData.Any())
  6430. {
  6431. var inserList = dto.DayOtherPriceData
  6432. .Where(x => x.Id == 0)
  6433. .Select(x => new Grp_DayOtherPrice
  6434. {
  6435. Cost = x.Cost,
  6436. Id = x.Id,
  6437. CreateTime = DateTime.Now,
  6438. CreateUserId = dto.UserId,
  6439. Currency = x.Currency,
  6440. Diid = x.DiId,
  6441. Index = x.Index,
  6442. IsDel = 0,
  6443. SetDataId = x.SetDataId,
  6444. SubTotal = x.SubTotal,
  6445. Remark = x.Remark
  6446. })
  6447. .ToList();
  6448. var updateList = dto.DayOtherPriceData
  6449. .Where(x => x.Id != 0)
  6450. .Select(x => new Grp_DayOtherPrice
  6451. {
  6452. Cost = x.Cost,
  6453. Id = x.Id,
  6454. CreateTime = DateTime.Now,
  6455. CreateUserId = dto.UserId,
  6456. Currency = x.Currency,
  6457. Diid = x.DiId,
  6458. Index = x.Index,
  6459. IsDel = 0,
  6460. SetDataId = x.SetDataId,
  6461. SubTotal = x.SubTotal,
  6462. Remark = x.Remark
  6463. })
  6464. .ToList();
  6465. //添加
  6466. _sqlSugar.BeginTran();
  6467. if (inserList.Any())
  6468. {
  6469. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6470. }
  6471. if (updateList.Any())
  6472. {
  6473. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6474. }
  6475. _sqlSugar.CommitTran();
  6476. }
  6477. if (data.Code != 0)
  6478. {
  6479. return Ok(JsonView(false, data.Msg));
  6480. }
  6481. //生成默认文件pdf并且通知人员
  6482. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6483. {
  6484. DiId = dto.DiId,
  6485. ExportType = 1,
  6486. SubTypeId = 1005
  6487. }, "pdf");
  6488. //发送通知
  6489. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6490. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6491. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6492. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6493. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6494. //汇率信息记录
  6495. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6496. return Ok(JsonView(true, data.Msg, data.Data));
  6497. }
  6498. catch (Exception ex)
  6499. {
  6500. return Ok(JsonView(false, ex.Message));
  6501. }
  6502. }
  6503. /// <summary>
  6504. /// 团组模块 - 出入境费用 - Confirm 费用
  6505. /// </summary>
  6506. /// <returns></returns>
  6507. [HttpPost]
  6508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6509. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6510. {
  6511. //TODO:测试完毕需把对应的用户ID更改
  6512. //1、数据表添加字段
  6513. //2、更改字段接口()
  6514. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6515. //3、确认成功 给财务发送消息
  6516. if (_view.Code == 200)
  6517. {
  6518. if (dto.Type == 1)
  6519. {
  6520. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6521. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6522. }
  6523. }
  6524. return Ok(_view);
  6525. }
  6526. /// <summary>
  6527. /// 团组模块 - 出入境费用 - File download
  6528. /// </summary>
  6529. /// <param name="dto"></param>
  6530. /// <returns></returns>
  6531. [HttpPost]
  6532. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6534. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6535. {
  6536. try
  6537. {
  6538. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6539. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6540. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6541. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6542. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6543. 3 团组成员名单 1 团组成员名单", ""));
  6544. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6545. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6546. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6547. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6548. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6549. //数据源
  6550. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6551. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6552. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6553. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6554. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6555. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6556. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6557. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6558. .Select((x, a, b) => new
  6559. {
  6560. x.Index,
  6561. itemName = a.Name,
  6562. CurrencyStr = b.Name,
  6563. x.Cost,
  6564. x.SubTotal,
  6565. x.Remark
  6566. })
  6567. .OrderBy((x) => x.Index)
  6568. .ToList(); //其他款项费用
  6569. var peiceItemCurrencys = new List<string>();
  6570. if (_DayAndCosts.Any())
  6571. {
  6572. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6573. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6574. }
  6575. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6576. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6577. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6578. {
  6579. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6580. }
  6581. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6582. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6583. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6584. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6585. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6586. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6587. .Select((tcl, dc, cc) => new ClientInfo
  6588. {
  6589. LastName = dc.LastName,
  6590. FirstName = dc.FirstName,
  6591. Sex = dc.Sex,
  6592. Birthday = dc.BirthDay,
  6593. Company = cc.CompanyFullName,
  6594. Job = dc.Job
  6595. })
  6596. .ToList();
  6597. foreach (var item in DeleClientList)
  6598. {
  6599. EncryptionProcessor.DecryptProperties(item);
  6600. }
  6601. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6602. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6603. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6604. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6605. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6606. if (dto.ExportType == 1) //明细表
  6607. {
  6608. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6609. {
  6610. //获取模板
  6611. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6612. //载入模板
  6613. var doc = new Document(tempPath);
  6614. var builder = new DocumentBuilder(doc);
  6615. var dic = new Dictionary<string, string>();
  6616. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6617. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6618. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6619. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6620. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6621. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6622. //境内费用(其他费用)
  6623. if (_EnterExitCosts.ChoiceOne == 1)
  6624. {
  6625. string row1_1 = "";
  6626. if (_EnterExitCosts.Visa > 0)
  6627. {
  6628. //insidePayTotal += _EnterExitCosts.Visa;
  6629. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 人民币/人";
  6630. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6631. //{
  6632. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6633. //}
  6634. }
  6635. string row1_2 = "";
  6636. if (_EnterExitCosts.YiMiao > 0)
  6637. {
  6638. //insidePayTotal += _EnterExitCosts.YiMiao;
  6639. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 人民币/人";
  6640. }
  6641. if (_EnterExitCosts.HeSuan > 0)
  6642. {
  6643. //insidePayTotal += _EnterExitCosts.HeSuan;
  6644. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 人民币/人";
  6645. }
  6646. if (_EnterExitCosts.Service > 0)
  6647. {
  6648. //insidePayTotal += _EnterExitCosts.Service;
  6649. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 人民币/人";
  6650. }
  6651. string row1_3 = "";
  6652. if (_EnterExitCosts.Safe > 0)
  6653. {
  6654. //insidePayTotal += _EnterExitCosts.Safe;
  6655. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 人民币/人";
  6656. }
  6657. if (_EnterExitCosts.Ticket > 0)
  6658. {
  6659. //insidePayTotal += _EnterExitCosts.Ticket;
  6660. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 人民币/人";
  6661. }
  6662. string row1 = "";
  6663. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6664. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6665. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6666. row1 += $"备注:{_EnterExitCosts.Remark}";
  6667. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6668. dic.Add("Row1Str", row1);
  6669. }
  6670. string airTotalStr = string.Empty,
  6671. airPriceStr = string.Empty;
  6672. //经济舱
  6673. if (_EnterExitCosts.SumJJC == 1)
  6674. {
  6675. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  6676. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  6677. }
  6678. //公务舱
  6679. if (_EnterExitCosts.SumGWC == 1)
  6680. {
  6681. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  6682. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  6683. }
  6684. //头等舱
  6685. if (_EnterExitCosts.SumTDC == 1)
  6686. {
  6687. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  6688. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  6689. }
  6690. //汇率描述
  6691. string rateStr = "";
  6692. if (peiceItemCurrencyInfos.Any())
  6693. {
  6694. rateStr = "\r\n汇率描述:";
  6695. foreach (var item in peiceItemCurrencyInfos)
  6696. {
  6697. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  6698. }
  6699. }
  6700. string twoItemRemark = "备注:";
  6701. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6702. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6703. dic.Add("AirTotalStr", airTotalStr);
  6704. dic.Add("AirPriceStr", airPriceStr);
  6705. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6706. dic.Add("TwoItemRemark", twoItemRemark);
  6707. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6708. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6709. int table1Row = 0,
  6710. table2Row = 0,
  6711. table3Row = 0,
  6712. table4Row = 0,
  6713. table5Row = 0;
  6714. //住宿费
  6715. if (_EnterExitCosts.ChoiceThree == 1)
  6716. {
  6717. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6718. table1Row = dac1.Count;
  6719. #region 填充word表格内容
  6720. for (int i = 0; i < dac1.Count; i++)
  6721. {
  6722. Grp_DayAndCost dac = dac1[i];
  6723. if (dac == null) continue;
  6724. builder.MoveToCell(0, i, 0, 0);
  6725. builder.Write("第" + dac.Days.ToString() + "晚:");
  6726. builder.MoveToCell(0, i, 1, 0);
  6727. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6728. //builder.Write(dac.Place == null ? "" : dac.Place);
  6729. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6730. builder.MoveToCell(0, i, 2, 0);
  6731. builder.Write("费用标准:");
  6732. string curr = "";
  6733. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6734. if (currData != null)
  6735. {
  6736. curr = currData.Name;
  6737. }
  6738. builder.MoveToCell(0, i, 3, 0);
  6739. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6740. builder.MoveToCell(0, i, 4, 0);
  6741. builder.Write("费用小计:");
  6742. builder.MoveToCell(0, i, 5, 0);
  6743. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6744. }
  6745. #endregion
  6746. }
  6747. else dic.Add("SubZS", "0.00");
  6748. //删除多余行
  6749. while (table1.Rows.Count > table1Row)
  6750. {
  6751. table1.Rows.RemoveAt(table1Row);
  6752. }
  6753. //伙食费
  6754. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6755. if (_EnterExitCosts.ChoiceFour == 1)
  6756. {
  6757. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6758. table2Row = dac2.Count;
  6759. #region 填充word表格内容
  6760. for (int i = 0; i < dac2.Count; i++)
  6761. {
  6762. Grp_DayAndCost dac = dac2[i];
  6763. if (dac == null) continue;
  6764. builder.MoveToCell(1, i, 0, 0);
  6765. builder.Write("第" + dac.Days.ToString() + "天:");
  6766. builder.MoveToCell(1, i, 1, 0);
  6767. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6768. builder.MoveToCell(1, i, 2, 0);
  6769. builder.Write("费用标准:");
  6770. string curr = "";
  6771. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6772. if (currData != null)
  6773. {
  6774. curr = currData.Name;
  6775. }
  6776. builder.MoveToCell(1, i, 3, 0);
  6777. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6778. builder.MoveToCell(1, i, 4, 0);
  6779. builder.Write("费用小计:");
  6780. builder.MoveToCell(1, i, 5, 0);
  6781. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6782. }
  6783. #endregion
  6784. }
  6785. else dic.Add("SubHS", "0.00");
  6786. //删除多余行
  6787. while (table2.Rows.Count > table2Row)
  6788. {
  6789. table2.Rows.RemoveAt(table2Row);
  6790. }
  6791. //公杂费
  6792. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6793. if (_EnterExitCosts.ChoiceFive == 1)
  6794. {
  6795. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6796. table3Row = dac3.Count;
  6797. #region 填充word表格内容
  6798. for (int i = 0; i < dac3.Count; i++)
  6799. {
  6800. Grp_DayAndCost dac = dac3[i];
  6801. if (dac == null) continue;
  6802. builder.MoveToCell(2, i, 0, 0);
  6803. builder.Write("第" + dac.Days.ToString() + "天:");
  6804. builder.MoveToCell(2, i, 1, 0);
  6805. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6806. builder.MoveToCell(2, i, 2, 0);
  6807. builder.Write("费用标准:");
  6808. string curr = "";
  6809. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6810. if (currData != null)
  6811. {
  6812. curr = currData.Name;
  6813. }
  6814. builder.MoveToCell(2, i, 3, 0);
  6815. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6816. builder.MoveToCell(2, i, 4, 0);
  6817. builder.Write("费用小计:");
  6818. builder.MoveToCell(2, i, 5, 0);
  6819. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6820. }
  6821. //删除多余行
  6822. while (table3.Rows.Count > table3Row)
  6823. {
  6824. table3.Rows.RemoveAt(table3Row);
  6825. }
  6826. #endregion
  6827. }
  6828. else dic.Add("SubGZF", "0.00");
  6829. //删除多余行
  6830. while (table3.Rows.Count > table3Row)
  6831. {
  6832. table3.Rows.RemoveAt(table3Row);
  6833. }
  6834. //培训费
  6835. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6836. if (_EnterExitCosts.ChoiceSix == 1)
  6837. {
  6838. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  6839. dic.Add("SubPX", pxStr);
  6840. table4Row = dac4.Count;
  6841. #region 填充word表格内容
  6842. for (int i = 0; i < dac4.Count; i++)
  6843. {
  6844. Grp_DayAndCost dac = dac4[i];
  6845. if (dac == null) continue;
  6846. builder.MoveToCell(3, i, 0, 0);
  6847. builder.Write("第" + dac.Days.ToString() + "天:");
  6848. builder.MoveToCell(3, i, 1, 0);
  6849. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6850. builder.MoveToCell(3, i, 2, 0);
  6851. builder.Write("费用标准:");
  6852. string curr = "";
  6853. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6854. if (currData != null)
  6855. {
  6856. curr = currData.Name;
  6857. }
  6858. builder.MoveToCell(3, i, 3, 0);
  6859. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6860. builder.MoveToCell(3, i, 4, 0);
  6861. builder.Write("费用小计:");
  6862. builder.MoveToCell(3, i, 5, 0);
  6863. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6864. }
  6865. #endregion
  6866. }
  6867. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6868. //删除多余行
  6869. while (table4.Rows.Count > table4Row)
  6870. {
  6871. table4.Rows.RemoveAt(table4Row);
  6872. }
  6873. //其他费用
  6874. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6875. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6876. {
  6877. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  6878. dic.Add("titleQi", qtStr);
  6879. table5Row = dac5.Count;
  6880. #region 填充word表格内容
  6881. for (int i = 0; i < dac5.Count; i++)
  6882. {
  6883. var dac = dac5[i];
  6884. if (dac == null) continue;
  6885. builder.MoveToCell(4, i, 0, 0);
  6886. builder.Write("第" + dac.Index.ToString() + "项:");
  6887. builder.MoveToCell(4, i, 1, 0);
  6888. builder.Write(dac.itemName);
  6889. builder.MoveToCell(4, i, 2, 0);
  6890. builder.Write("费用标准:");
  6891. builder.MoveToCell(4, i, 3, 0);
  6892. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6893. builder.MoveToCell(4, i, 4, 0);
  6894. builder.Write("费用小计:");
  6895. builder.MoveToCell(4, i, 5, 0);
  6896. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6897. builder.MoveToCell(4, i, 6, 0);
  6898. builder.Write("备注:");
  6899. builder.MoveToCell(4, i, 7, 0);
  6900. builder.Write(dac.Remark);
  6901. }
  6902. #endregion
  6903. }
  6904. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6905. //删除多余行
  6906. while (table5.Rows.Count > table5Row)
  6907. {
  6908. table5.Rows.RemoveAt(table5Row);
  6909. }
  6910. //加上其他费用
  6911. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6912. decimal subJJC = 0.00M,
  6913. subGWC = 0.00M,
  6914. subTDC = 0.00M;
  6915. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6916. string totalLabel = string.Format("全部费用总计:");
  6917. //经济舱
  6918. if (_EnterExitCosts.SumJJC == 1)
  6919. {
  6920. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6921. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  6922. }
  6923. //公务舱
  6924. if (_EnterExitCosts.SumGWC == 1)
  6925. {
  6926. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6927. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  6928. }
  6929. //头等舱
  6930. if (_EnterExitCosts.SumTDC == 1)
  6931. {
  6932. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6933. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  6934. }
  6935. //TotalLabel
  6936. dic.Add("TotalLabel", totalLabel);
  6937. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6938. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6939. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6940. #region 填充word模板书签内容
  6941. foreach (var key in dic.Keys)
  6942. {
  6943. Bookmark bookmark = doc.Range.Bookmarks[key];
  6944. if (bookmark != null)
  6945. {
  6946. builder.MoveToBookmark(key);
  6947. builder.Write(dic[key]);
  6948. }
  6949. }
  6950. #endregion
  6951. #region 设置页眉
  6952. string userLabel = string.Empty;
  6953. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6954. if (currUserInfo != null)
  6955. {
  6956. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6957. if (userInfo != null)
  6958. {
  6959. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6960. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6961. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6962. }
  6963. }
  6964. //设置页脚
  6965. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6966. #endregion
  6967. //文件名
  6968. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6969. AsposeHelper.removewatermark_v2180();
  6970. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6971. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6972. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6973. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6974. }
  6975. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6976. {
  6977. //获取模板
  6978. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6979. //载入模板
  6980. var doc = new Document(tempPath);
  6981. var builder = new DocumentBuilder(doc);
  6982. var dic = new Dictionary<string, string>();
  6983. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6984. {
  6985. var list = new List<string>();
  6986. try
  6987. {
  6988. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6989. foreach (var item in spilitArr)
  6990. {
  6991. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6992. var depCode = spDotandEmpty[2].Substring(0, 3);
  6993. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6994. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6995. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6996. list.Add(depName);
  6997. list.Add(arrName);
  6998. }
  6999. list = list.Distinct().ToList();
  7000. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7001. }
  7002. catch (Exception)
  7003. {
  7004. dic.Add("ReturnCode", "行程录入不正确!");
  7005. }
  7006. }
  7007. else
  7008. {
  7009. dic.Add("ReturnCode", "未录入行程!");
  7010. }
  7011. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7012. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7013. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7014. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7015. {
  7016. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7017. dic.Add("Day", sp.Days.ToString());
  7018. }
  7019. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7020. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7021. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7022. //dic.Add("Names", Names);
  7023. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7024. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7025. decimal dac1totalPrice = 0.00M;
  7026. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7027. foreach (var dac in dac1)
  7028. {
  7029. if (dac.SubTotal == 0.00M)
  7030. {
  7031. continue;
  7032. }
  7033. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7034. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7035. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7036. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7037. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7038. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7039. builder.Write(currency);//币种
  7040. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7041. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7042. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7043. builder.Write("");//人数
  7044. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7045. builder.Write("");//天数
  7046. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7047. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7048. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7049. decimal rate = 0.00M;
  7050. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7051. builder.Write(rate.ToString("#0.0000"));//汇率
  7052. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7053. decimal rbmPrice = dac.SubTotal;
  7054. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7055. accommodationStartIndex++;
  7056. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7057. }
  7058. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7059. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7060. {
  7061. table1.Rows.RemoveAt(i - 1);
  7062. foodandotherStartIndex--;
  7063. }
  7064. if (dac2.Count == dac3.Count)//国家 币种 金额
  7065. {
  7066. for (int i = 0; i < dac2.Count; i++)
  7067. {
  7068. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7069. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7070. }
  7071. }
  7072. decimal dac2totalPrice = 0.00M;
  7073. foreach (var dac in dac2)
  7074. {
  7075. if (dac.SubTotal == 0)
  7076. {
  7077. continue;
  7078. }
  7079. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7080. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7081. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7082. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7083. builder.Write(currency);//币种
  7084. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7085. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7086. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7087. builder.Write("");//人数
  7088. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7089. builder.Write("");//天数
  7090. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7091. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7092. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7093. decimal rate = 0.00M;
  7094. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7095. builder.Write(rate.ToString("#0.0000"));//汇率
  7096. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7097. decimal rbmPrice = dac.SubTotal;
  7098. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7099. foodandotherStartIndex++;
  7100. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7101. }
  7102. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7103. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7104. {
  7105. table1.Rows.RemoveAt(i - 1);
  7106. }
  7107. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7108. string otherFeeStr = "";
  7109. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7110. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7111. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7112. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7113. foreach (var otherInfo in dac5)
  7114. {
  7115. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7116. }
  7117. #endregion
  7118. if (otherFeeStr.Length > 0)
  7119. {
  7120. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7121. otherFeeStr = $"({otherFeeStr})";
  7122. dic.Add("OtherFeeStr", otherFeeStr);
  7123. }
  7124. //总计
  7125. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7126. //国际旅费
  7127. string outsideAir = string.Empty;
  7128. string allPriceAir = string.Empty;
  7129. if (_EnterExitCosts.SumJJC == 1)
  7130. {
  7131. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7132. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7133. }
  7134. if (_EnterExitCosts.SumGWC == 1)
  7135. {
  7136. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7137. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7138. }
  7139. if (_EnterExitCosts.SumTDC == 1)
  7140. {
  7141. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7142. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7143. }
  7144. dic.Add("InTravelPrice", $"({outsideAir})");
  7145. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7146. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7147. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7148. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7149. foreach (var key in dic.Keys)
  7150. {
  7151. builder.MoveToBookmark(key);
  7152. builder.Write(dic[key]);
  7153. }
  7154. //模板文件名
  7155. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7156. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7157. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7158. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7159. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7160. }
  7161. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7162. {
  7163. //获取模板
  7164. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7165. //载入模板
  7166. var designer = new WorkbookDesigner
  7167. {
  7168. Workbook = new Workbook(tempPath)
  7169. };
  7170. var dic = new Dictionary<string, string>();
  7171. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7172. {
  7173. var list = new List<string>();
  7174. try
  7175. {
  7176. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7177. foreach (var item in spilitArr)
  7178. {
  7179. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7180. var depCode = spDotandEmpty[2].Substring(0, 3);
  7181. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7182. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7183. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7184. list.Add(depName);
  7185. list.Add(arrName);
  7186. }
  7187. list = list.Distinct().ToList();
  7188. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7189. }
  7190. catch (Exception)
  7191. {
  7192. dic.Add("ReturnCode", "行程录入不正确!");
  7193. }
  7194. }
  7195. else
  7196. {
  7197. dic.Add("ReturnCode", "未录入行程!");
  7198. }
  7199. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7200. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7201. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7202. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7203. {
  7204. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7205. dic.Add("Day", sp.Days.ToString());
  7206. }
  7207. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7208. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7209. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7210. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7211. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7212. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7213. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7214. designer.SetDataSource("Name", Names);
  7215. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7216. designer.SetDataSource("Day", dic["Day"] + "天");
  7217. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7218. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7219. int startIndex = 10;
  7220. const int startIndexcopy = 10;
  7221. if (dac2.Count == dac3.Count)//国家 币种 金额
  7222. {
  7223. for (int i = 0; i < dac2.Count; i++)
  7224. {
  7225. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7226. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7227. }
  7228. }
  7229. var dtdac1 = new DataTable();
  7230. var place = new List<string>();
  7231. dtdac1.Columns.AddRange(new DataColumn[] {
  7232. new(){ ColumnName = "city"},
  7233. new(){ ColumnName = "curr"},
  7234. new(){ ColumnName = "criterion"},
  7235. new(){ ColumnName = "number",DataType = typeof(int)},
  7236. new(){ ColumnName = "day",DataType = typeof(int)},
  7237. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7238. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7239. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7240. });
  7241. var dtdac2 = new DataTable();
  7242. dtdac2.Columns.AddRange(new DataColumn[] {
  7243. new(){ ColumnName = "city"},
  7244. new(){ ColumnName = "curr"},
  7245. new(){ ColumnName = "criterion"},
  7246. new(){ ColumnName = "number",DataType = typeof(int)},
  7247. new(){ ColumnName = "day",DataType = typeof(int)},
  7248. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7249. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7250. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7251. });
  7252. dtdac1.TableName = "tb1";
  7253. dtdac2.TableName = "tb2";
  7254. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7255. foreach (var item in dac1)
  7256. {
  7257. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7258. if (place.Contains(item.Place))
  7259. {
  7260. continue;
  7261. }
  7262. DataRow row = dtdac1.NewRow();
  7263. row["city"] = item.Place;
  7264. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7265. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7266. row["curr"] = currency;
  7267. row["rate"] = rate.ToString("#0.0000");
  7268. row["criterion"] = item.Cost.ToString("#0.00");
  7269. row["number"] = 1;
  7270. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7271. //row["costRMB"] = rbmPrice;
  7272. dtdac1.Rows.Add(row);
  7273. place.Add(item.Place);
  7274. }
  7275. place = new List<string>();
  7276. foreach (var item in dac2)
  7277. {
  7278. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7279. if (place.Contains(item.Place))
  7280. {
  7281. continue;
  7282. }
  7283. DataRow row = dtdac2.NewRow();
  7284. row["city"] = item.Place;
  7285. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7286. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7287. row["curr"] = currency;
  7288. row["rate"] = rate.ToString("#0.0000");
  7289. row["criterion"] = item.Cost.ToString("#0.00");
  7290. row["number"] = 1;
  7291. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7292. //row["cost"] = item.SubTotal;
  7293. //row["costRMB"] = rbmPrice;
  7294. dtdac2.Rows.Add(row);
  7295. place.Add(item.Place);
  7296. //dac2totalPrice += rbmPrice;
  7297. }
  7298. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7299. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7300. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7301. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7302. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7303. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7304. string cell4Str1 = string.Empty;
  7305. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7306. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7307. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7308. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7309. string cellStr = $" 5.其他费用(";
  7310. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7311. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7312. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7313. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7314. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7315. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7316. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7317. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7318. foreach (var otherInfo in dac5)
  7319. {
  7320. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7321. }
  7322. #endregion
  7323. if (cellStr.Length > 8)
  7324. {
  7325. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7326. }
  7327. cellStr += ")";
  7328. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7329. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7330. decimal pxFee = dac4.Sum(it => it.Cost);
  7331. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7332. string celllastStr1 = "";
  7333. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7334. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7335. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7336. celllastStr1 += $",国际旅费 元";
  7337. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7338. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7339. designer.SetDataSource("cell4Str", cell4Str);
  7340. designer.SetDataSource("cellStr", cellStr);
  7341. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7342. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7343. designer.SetDataSource("celllastStr", celllastStr);
  7344. Workbook wb = designer.Workbook;
  7345. var sheet = wb.Worksheets[0];
  7346. //绑定datatable数据集
  7347. designer.SetDataSource(dtdac1);
  7348. designer.SetDataSource(dtdac2);
  7349. designer.Process();
  7350. var rowStart = dtdac1.Rows.Count;
  7351. while (rowStart > 0)
  7352. {
  7353. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7354. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7355. startIndex++;
  7356. rowStart--;
  7357. }
  7358. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7359. startIndex += 1; //总计行
  7360. rowStart = dtdac2.Rows.Count;
  7361. while (rowStart > 0)
  7362. {
  7363. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7364. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7365. startIndex++;
  7366. rowStart--;
  7367. }
  7368. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7369. wb.CalculateFormula(true);
  7370. //模板文件名
  7371. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7372. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7373. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7374. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7375. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7376. }
  7377. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7378. {
  7379. //获取模板
  7380. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7381. //载入模板
  7382. var doc = new Document(tempPath);
  7383. var builder = new DocumentBuilder(doc);
  7384. var dic = new Dictionary<string, string>
  7385. {
  7386. { "GroupName", _DelegationInfo.TeamName },
  7387. { "ClientUnit", _DelegationInfo.ClientUnit }
  7388. };
  7389. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7390. string missionLeaderJob = "";//负责人job
  7391. //int groupNumber = 0; //团人数
  7392. if (DeleClientList.Count > 0)
  7393. {
  7394. missionLeader = DeleClientList[0]?.Name ?? "";
  7395. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7396. }
  7397. dic.Add("MissionLeader", missionLeader); //团负责人
  7398. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7399. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7400. #region MyRegion
  7401. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7402. //{
  7403. // List<string> list = new List<string>();
  7404. // try
  7405. // {
  7406. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7407. // foreach (var item in spilitArr)
  7408. // {
  7409. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7410. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7411. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7412. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7413. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7414. // list.Add(depName);
  7415. // list.Add(arrName);
  7416. // }
  7417. // list = list.Distinct().ToList();
  7418. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7419. // }
  7420. // catch (Exception)
  7421. // {
  7422. // dic.Add("ReturnCode", "行程录入不正确!");
  7423. // }
  7424. //}
  7425. //else
  7426. //{
  7427. // dic.Add("ReturnCode", "未录入行程!");
  7428. //}
  7429. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7430. dic.Add("ReturnCode", string.Join("、", countrys));
  7431. #endregion
  7432. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7433. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7434. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7435. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7436. //{
  7437. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7438. // dic.Add("Day", sp.Days.ToString());
  7439. //}
  7440. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7441. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7442. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7443. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7444. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7445. //培训人员名单
  7446. int cultivateRowIndex = 7;
  7447. foreach (var item in DeleClientList)
  7448. {
  7449. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7450. builder.Write(item.Name);
  7451. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7452. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7453. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7454. string birthDay = "";
  7455. if (item.Birthday != null)
  7456. {
  7457. DateTime dt = Convert.ToDateTime(item.Birthday);
  7458. birthDay = $"{dt.Year}.{dt.Month}";
  7459. }
  7460. builder.Write(birthDay);
  7461. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7462. builder.Write(item.Company);
  7463. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7464. builder.Write(item.Job);
  7465. cultivateRowIndex++;
  7466. }
  7467. //删除多余行
  7468. //cultivateRowIndex -= 2;
  7469. int delRows = 10 + 7 - cultivateRowIndex;
  7470. if (delRows > 0)
  7471. {
  7472. for (int i = 0; i < delRows; i++)
  7473. {
  7474. table1.Rows.RemoveAt(cultivateRowIndex);
  7475. //cultivateRowIndex++;
  7476. }
  7477. }
  7478. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7479. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7480. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7481. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7482. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7483. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7484. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7485. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7486. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7487. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7488. //其他费用
  7489. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7490. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7491. //其他费用合计
  7492. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7493. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7494. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7495. //公务舱合计
  7496. //国际旅费
  7497. //string outsideJJ = "";
  7498. //string allPriceJJ = "";
  7499. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7500. {
  7501. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7502. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7503. }
  7504. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7505. {
  7506. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7507. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7508. }
  7509. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7510. {
  7511. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7512. dic.Add("AirFeeTotal", airFeeTotalStr);
  7513. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7514. dic.Add("FeeTotal", feeTotalStr);
  7515. }
  7516. foreach (var key in dic.Keys)
  7517. {
  7518. builder.MoveToBookmark(key);
  7519. builder.Write(dic[key]);
  7520. }
  7521. //模板文件名
  7522. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7523. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7524. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7525. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7526. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7527. }
  7528. }
  7529. else if (dto.ExportType == 2) //表格
  7530. {
  7531. //利用键值对存放数据
  7532. Dictionary<string, string> dic = new Dictionary<string, string>();
  7533. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7534. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7535. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7536. dic.Add("Day", sp.Days.ToString());
  7537. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7538. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7539. {
  7540. //获取模板
  7541. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7542. //载入模板
  7543. var doc = new Document(tempPath);
  7544. var builder = new DocumentBuilder(doc);
  7545. dic.Add("TeamName", _DelegationInfo.TeamName);
  7546. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7547. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7548. string missionLeaderName = "",
  7549. missionLeaderJob = "";
  7550. if (DeleClientList.Count > 0)
  7551. {
  7552. missionLeaderName = DeleClientList[0].Name;
  7553. missionLeaderJob = DeleClientList[0].Job;
  7554. }
  7555. dic.Add("MissionLeaderName", missionLeaderName);
  7556. dic.Add("MissionLeaderJob", missionLeaderJob);
  7557. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7558. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7559. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7560. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7561. int rowCount = 10;//总人数行
  7562. int startRowIndex = 7; //起始行
  7563. for (int i = 0; i < DeleClientList.Count; i++)
  7564. {
  7565. builder.MoveToCell(0, startRowIndex, 0, 0);
  7566. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7567. builder.MoveToCell(0, startRowIndex, 1, 0);
  7568. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7569. builder.Write(sex);//性别
  7570. builder.MoveToCell(0, startRowIndex, 2, 0);
  7571. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7572. builder.MoveToCell(0, startRowIndex, 3, 0);
  7573. builder.Write(DeleClientList[i].Company);//工作单位
  7574. builder.MoveToCell(0, startRowIndex, 4, 0);
  7575. builder.Write(DeleClientList[i].Job);//职务及级别
  7576. builder.MoveToCell(0, startRowIndex, 5, 0);
  7577. builder.Write("");//人员属性
  7578. builder.MoveToCell(0, startRowIndex, 6, 0);
  7579. builder.Write("");//上次出国时间
  7580. startRowIndex++;
  7581. }
  7582. int nullRow = rowCount - DeleClientList.Count;//空行
  7583. for (int i = 0; i < nullRow; i++)
  7584. {
  7585. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7586. }
  7587. foreach (var key in dic.Keys)
  7588. {
  7589. builder.MoveToBookmark(key);
  7590. builder.Write(dic[key]);
  7591. }
  7592. //模板文件名
  7593. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7594. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7595. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7596. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7597. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7598. }
  7599. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7600. {
  7601. //获取模板
  7602. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7603. //载入模板
  7604. var doc = new Document(tempPath);
  7605. var builder = new DocumentBuilder(doc);
  7606. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7607. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7608. dic.Add("Names", Names);
  7609. int accommodationRows = 12;
  7610. //int foodandotherRows = 12;
  7611. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7612. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7613. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7614. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7615. int accommodationStartIndex = 6;
  7616. decimal dac1totalPrice = 0.00M;
  7617. foreach (var dac in dac1)
  7618. {
  7619. if (dac.SubTotal == 0)
  7620. {
  7621. continue;
  7622. }
  7623. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7624. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7625. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7626. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7627. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7628. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7629. builder.Write(currency);//币种
  7630. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7631. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7632. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7633. builder.Write("");//人数
  7634. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7635. builder.Write("");//天数
  7636. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7637. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7638. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7639. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7640. builder.Write(rate.ToString("#0.0000"));//汇率
  7641. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7642. decimal rbmPrice = rate * dac.SubTotal;
  7643. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7644. accommodationStartIndex++;
  7645. dac1totalPrice += rbmPrice;
  7646. }
  7647. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7648. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7649. builder.Write("小计");
  7650. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7651. builder.Write(dac1totalPrice.ToString("#0.00"));
  7652. accommodationStartIndex++;
  7653. int nullRow = accommodationRows - dac1.Count;
  7654. //删除空行
  7655. //if (nullRow > 0)
  7656. //{
  7657. // int rowIndex = accommodationStartIndex;
  7658. // for (int i = 0; i < nullRow; i++)
  7659. // {
  7660. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7661. // row.Remove();
  7662. // rowIndex++;
  7663. // }
  7664. //}
  7665. if (dac2.Count == dac3.Count)//国家 币种 金额
  7666. {
  7667. for (int i = 0; i < dac2.Count; i++)
  7668. {
  7669. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7670. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7671. }
  7672. }
  7673. int foodandotherStartIndex = 19;//
  7674. decimal dac2totalPrice = 0.00M;
  7675. foreach (var dac in dac2)
  7676. {
  7677. if (dac.SubTotal == 0)
  7678. {
  7679. continue;
  7680. }
  7681. //foodandotherStartIndex = 12;
  7682. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7683. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7684. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7685. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7686. builder.Write(currency);//币种
  7687. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7688. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7689. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7690. builder.Write("");//人数
  7691. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7692. builder.Write("");//天数
  7693. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7694. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7695. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7696. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7697. builder.Write(rate.ToString("#0.0000"));//汇率
  7698. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7699. decimal rbmPrice = rate * dac.SubTotal;
  7700. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7701. foodandotherStartIndex++;
  7702. dac2totalPrice += rbmPrice;
  7703. }
  7704. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7705. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7706. //删除空行
  7707. //if (dac2.Count < foodandotherRows)
  7708. //{
  7709. // while (table2.Rows.Count > dac2.Count)
  7710. // {
  7711. // table2.Rows.RemoveAt(dac2.Count);
  7712. // }
  7713. //}
  7714. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7715. string otherFeeStr = "";
  7716. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7717. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7718. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7719. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7720. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7721. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7722. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7723. foreach (var otherInfo in dac5)
  7724. {
  7725. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7726. }
  7727. #endregion
  7728. if (otherFeeStr.Length > 0)
  7729. {
  7730. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7731. otherFeeStr = $"({otherFeeStr})";
  7732. dic.Add("OtherFeeStr", otherFeeStr);
  7733. }
  7734. foreach (var key in dic.Keys)
  7735. {
  7736. builder.MoveToBookmark(key);
  7737. builder.Write(dic[key]);
  7738. }
  7739. //模板文件名
  7740. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7741. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7742. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7743. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7744. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7745. }
  7746. }
  7747. else if (dto.ExportType == 3)
  7748. {
  7749. if (dto.SubTypeId == 1) //团组成员名单
  7750. {
  7751. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7752. //获取模板
  7753. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7754. //载入模板
  7755. var doc = new Document(tempPath);
  7756. var builder = new DocumentBuilder(doc);
  7757. //获取word里所有表格
  7758. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7759. //获取所填表格的序数
  7760. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7761. var rowStart = tableOne.Rows[0]; //获取第1行
  7762. //循环赋值
  7763. for (int i = 0; i < DeleClientList.Count; i++)
  7764. {
  7765. builder.MoveToCell(0, i + 1, 0, 0);
  7766. builder.Write(DeleClientList[i].Name);
  7767. builder.MoveToCell(0, i + 1, 1, 0);
  7768. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7769. builder.Write(sex);
  7770. builder.MoveToCell(0, i + 1, 2, 0);
  7771. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7772. builder.MoveToCell(0, i + 1, 3, 0);
  7773. builder.Write(DeleClientList[i].Company);
  7774. builder.MoveToCell(0, i + 1, 4, 0);
  7775. builder.Write(DeleClientList[i].Job);
  7776. }
  7777. //删除多余行
  7778. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7779. {
  7780. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7781. }
  7782. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7783. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7784. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7785. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7786. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7787. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7788. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7789. }
  7790. }
  7791. return Ok(JsonView(400, "操作失败!", ""));
  7792. }
  7793. catch (Exception ex)
  7794. {
  7795. return Ok(JsonView(400, ex.Message, ""));
  7796. }
  7797. }
  7798. /// <summary>
  7799. /// 获取三公费用标准city
  7800. /// </summary>
  7801. /// <param name="placeData"></param>
  7802. /// <param name="nationalTravelFeeId"></param>
  7803. /// <returns></returns>
  7804. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7805. {
  7806. string _city = string.Empty;
  7807. if (placeData.Count < 1) return _city;
  7808. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7809. if (data == null) return _city;
  7810. string country = data.Country;
  7811. string city = data.City;
  7812. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7813. else _city = city;
  7814. return _city;
  7815. }
  7816. ///// <summary>
  7817. ///// 团组模块 - 出入境费用 - 明细表导出
  7818. ///// </summary>
  7819. ///// <returns></returns>
  7820. //[HttpPost]
  7821. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7822. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7823. //{
  7824. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7825. // if (data.Code != 0)
  7826. // {
  7827. // return Ok(JsonView(false, data.Msg));
  7828. // }
  7829. // return Ok(JsonView(true, data.Msg, data.Data));
  7830. //}
  7831. /// <summary>
  7832. /// 团组模块 - 出入境费用 - 一键清空
  7833. /// </summary>
  7834. /// <returns></returns>
  7835. [HttpPost]
  7836. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7838. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7839. {
  7840. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7841. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7842. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7843. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7844. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7845. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7846. .SetColumns(x => new Grp_DayOtherPrice
  7847. {
  7848. IsDel = 1,
  7849. DeleteUserId = dto.UserId,
  7850. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7851. })
  7852. .ExecuteCommandAsync();
  7853. if (_view.Code == 0)
  7854. {
  7855. return Ok(JsonView(true, "操作成功"));
  7856. }
  7857. return Ok(JsonView(false, "操作失败"));
  7858. }
  7859. /// <summary>
  7860. /// 团组模块 - 出入境费用 - 子项删除
  7861. /// </summary>
  7862. /// <returns></returns>
  7863. [HttpPost]
  7864. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7866. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7867. {
  7868. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7869. if (data.Code != 0)
  7870. {
  7871. return Ok(JsonView(false, data.Msg));
  7872. }
  7873. return Ok(JsonView(true, "操作成功!", data.Data));
  7874. }
  7875. /// <summary>
  7876. /// 删除三公其他费用
  7877. /// </summary>
  7878. /// <param name="dto"></param>
  7879. /// <returns></returns>
  7880. [HttpPost]
  7881. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7882. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7883. {
  7884. var jw = JsonView(false, "删除失败!");
  7885. var data = new Grp_DayOtherPrice()
  7886. {
  7887. Id = dto.Id,
  7888. IsDel = 1,
  7889. DeleteUserId = dto.DeleteUserId,
  7890. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7891. };
  7892. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7893. if (del > 0)
  7894. {
  7895. jw.Code = 200;
  7896. jw.Msg = "删除成功!";
  7897. }
  7898. return Ok(jw);
  7899. }
  7900. /// <summary>
  7901. /// 团组模块 - 出入境国家费用标准 List
  7902. /// </summary>
  7903. /// <returns></returns>
  7904. [HttpPost]
  7905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7906. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7907. {
  7908. int provinceId = dto.ProvinceId;
  7909. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7910. var nftData = await _sqlSugar
  7911. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7912. JoinType.Left, ntf.Currency == sd1.Id,
  7913. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7914. JoinType.Left, ntf.ProvinceId == c.Id
  7915. ))
  7916. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7917. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7918. {
  7919. Id = ntf.Id,
  7920. ProvinceId = ntf.ProvinceId,
  7921. ProvinceName = c.Name_CN,
  7922. Continent = ntf.Continent,
  7923. Country = ntf.Country,
  7924. City = ntf.City,
  7925. Currency = ntf.Currency,
  7926. CurrencyCode = sd1.Name,
  7927. CurrencyName = sd1.Remark,
  7928. RoomCost = ntf.RoomCost,
  7929. FoodCost = ntf.FoodCost,
  7930. PublicCost = ntf.PublicCost,
  7931. LastUpdateUserId = ntf.LastUpdateUserId,
  7932. LastUpdateUserName = u.CnName,
  7933. LastUpdateTime = ntf.LastUpdateTime
  7934. })
  7935. .ToListAsync();
  7936. return Ok(JsonView(true, "查询成功!", nftData));
  7937. }
  7938. /// <summary>
  7939. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7940. /// </summary>
  7941. /// <returns></returns>
  7942. [HttpPost]
  7943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7944. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7945. {
  7946. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7947. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7948. List<string> countryData = new List<string>();
  7949. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7950. countryData = countryData.Distinct().ToList();
  7951. List<dynamic> dataSource = new List<dynamic>();
  7952. foreach (var item in countryData)
  7953. {
  7954. var cityData1 = new List<string>();
  7955. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7956. var countryData2 = new
  7957. {
  7958. CountryName = item,
  7959. CityData = cityData1
  7960. };
  7961. if (!dataSource.Contains(countryData2))
  7962. {
  7963. dataSource.Add(countryData2);
  7964. }
  7965. }
  7966. return Ok(JsonView(true, "查询成功!", dataSource));
  7967. }
  7968. /// <summary>
  7969. /// 团组模块 - 出入境国家费用标准 Page List
  7970. /// </summary>
  7971. /// <returns></returns>
  7972. [HttpPost]
  7973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7974. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7975. {
  7976. int portId = dto.PortType,
  7977. pageIndex = dto.PageIndex,
  7978. pageSize = dto.PageSize;
  7979. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7980. if (pageIndex == 0) pageIndex = 1;
  7981. if (pageSize == 0) pageSize = 10;
  7982. RefAsync<int> total = 0;
  7983. var nationalTravelFeeData = await _sqlSugar
  7984. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7985. JoinType.Left, ntf.Currency == sd1.Id,
  7986. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7987. JoinType.Left, ntf.ProvinceId == sd2.Id
  7988. ))
  7989. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7990. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7991. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7992. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7993. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7994. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7995. {
  7996. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7997. Id = ntf.Id,
  7998. ProvinceId = ntf.ProvinceId,
  7999. ProvinceName = sd2.Name_CN,
  8000. Continent = ntf.Continent,
  8001. Country = ntf.Country,
  8002. City = ntf.City,
  8003. Currency = ntf.Currency,
  8004. CurrencyCode = sd1.Name,
  8005. CurrencyName = sd1.Remark,
  8006. RoomCost = ntf.RoomCost,
  8007. FoodCost = ntf.FoodCost,
  8008. PublicCost = ntf.PublicCost,
  8009. LastUpdateUserId = ntf.LastUpdateUserId,
  8010. LastUpdateUserName = u.CnName,
  8011. LastUpdateTime = ntf.LastUpdateTime,
  8012. Remark = ntf.Remark
  8013. })
  8014. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8015. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8016. }
  8017. /// <summary>
  8018. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8019. /// </summary>
  8020. /// <returns></returns>
  8021. [HttpPost]
  8022. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8023. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8024. {
  8025. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8026. int portId = dto.PortType;
  8027. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8028. string whereSql = string.Empty;
  8029. if (!string.IsNullOrEmpty(dto.Country))
  8030. {
  8031. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8032. }
  8033. if (!string.IsNullOrEmpty(dto.City))
  8034. {
  8035. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8036. }
  8037. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8038. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8039. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8040. From Grp_NationalTravelFee gntf
  8041. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8042. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8043. Where gntf.Isdel = 0 {0} ", whereSql);
  8044. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8045. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8046. }
  8047. /// <summary>
  8048. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8049. /// </summary>
  8050. /// <returns></returns>
  8051. [HttpPost]
  8052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8053. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  8054. {
  8055. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  8056. }
  8057. /// <summary>
  8058. /// 团组模块 - 出入境国家费用标准 - Del
  8059. /// </summary>
  8060. /// <returns></returns>
  8061. [HttpPost]
  8062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8063. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  8064. {
  8065. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  8066. {
  8067. Id = dto.Id,
  8068. DeleteUserId = dto.DeleteUserId,
  8069. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8070. IsDel = 1
  8071. };
  8072. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  8073. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  8074. .WhereColumns(it => new { it.Id })
  8075. .ExecuteCommandAsync();
  8076. if (delStatus <= 0)
  8077. {
  8078. return Ok(JsonView(false, "删除失败!"));
  8079. }
  8080. return Ok(JsonView(true, "操作成功!"));
  8081. }
  8082. /// <summary>
  8083. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  8084. /// 注:Get 请求Headers 加 Token
  8085. /// </summary>
  8086. /// <param name="groupId"></param>
  8087. /// <returns></returns>
  8088. [HttpGet("{groupId}")]
  8089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8090. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  8091. {
  8092. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8093. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8094. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8095. data.ForEach(x =>
  8096. {
  8097. x.CreateUserId = _currUserInfo.UserId;
  8098. });
  8099. if (data.Any())
  8100. {
  8101. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8102. if (add > 0)
  8103. {
  8104. return Ok(JsonView(true, "操作成功!"));
  8105. }
  8106. }
  8107. return Ok(JsonView(false, "未操作!"));
  8108. }
  8109. #endregion
  8110. #region 团组经理模块 出入境费用-草稿
  8111. /// <summary>
  8112. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8113. /// </summary>
  8114. /// <returns></returns>
  8115. [HttpGet]
  8116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8117. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8118. {
  8119. var provData = await _groupRepository.ProvinceBasicSource();
  8120. return Ok(JsonView(true, "查询成功!", provData));
  8121. }
  8122. /// <summary>
  8123. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8124. /// </summary>
  8125. /// <returns></returns>
  8126. [HttpGet("{provinceId}")]
  8127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8128. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8129. {
  8130. //验证城市归属并给默认值
  8131. if (provinceId < 1) provinceId = 122;
  8132. /*
  8133. * 122 四川
  8134. * 108 贵州
  8135. * 103 重庆
  8136. * 132 云南
  8137. */
  8138. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8139. return Ok(JsonView(true, "查询成功!", new
  8140. {
  8141. WordTypeData = wordTypeData,
  8142. ExcelTypeData = excelTypeData,
  8143. }));
  8144. }
  8145. /// <summary>
  8146. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8147. /// </summary>
  8148. /// <returns></returns>
  8149. [HttpPost]
  8150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8151. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8152. {
  8153. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8154. .Where(x => x.IsDel == 0)
  8155. .OrderByDescending(x => x.CreateTime)
  8156. .Select(x => new { x.Id, x.DraftName })
  8157. .ToListAsync();
  8158. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8159. //SetDataInfoView
  8160. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8161. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8162. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8163. int provinceId = dto.ProvinceId;
  8164. if (provinceId < 1) provinceId = 122;
  8165. /*
  8166. * 122 四川
  8167. * 108 贵州
  8168. * 103 重庆
  8169. * 132 云南
  8170. */
  8171. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8172. //默认币种显示
  8173. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8174. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8175. return Ok(JsonView(true, "查询成功!", new
  8176. {
  8177. DraftNameDatas = draftNameDatas,
  8178. CurrencyData = _CurrencyData,
  8179. WordTypeData = wordTypeData,
  8180. ExcelTypeData = excelTypeData,
  8181. CurrencyInit = _currencyInfos,
  8182. ViewPermissionData = viewPermissionData
  8183. }));
  8184. }
  8185. /// <summary>
  8186. /// 团组模块 - 出入境费用-草稿
  8187. /// 实时汇率 tips
  8188. /// 机票费用 tips
  8189. /// </summary>
  8190. /// <returns></returns>
  8191. [HttpPost]
  8192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8193. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8194. {
  8195. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8196. return Ok(JsonView(true, "查询成功!", new
  8197. {
  8198. //GroupNameData = groupNameData.Data,
  8199. //visaData = visaData.Data,
  8200. //airData = airData.Data,
  8201. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8202. }));
  8203. }
  8204. /// <summary>
  8205. /// 团组模块 - 出入境费用-草稿
  8206. /// 签证费用 tips
  8207. /// </summary>
  8208. /// <returns></returns>
  8209. [HttpPost]
  8210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8211. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8212. {
  8213. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8214. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8215. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8216. .Select(x => x.NationalTravelFeeId)
  8217. .Distinct()
  8218. .ToListAsync();
  8219. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8220. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8221. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8222. .Select(x => x.Country)
  8223. .Distinct()
  8224. .ToArrayAsync();
  8225. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8226. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8227. return Ok(JsonView(true, "查询成功!", new
  8228. {
  8229. totalAmt = totalAmt,
  8230. remark = remark
  8231. }));
  8232. }
  8233. /// <summary>
  8234. /// 团组模块 - 出入境费用-草稿 - Info
  8235. /// </summary>
  8236. /// <returns></returns>
  8237. [HttpPost]
  8238. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8240. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8241. {
  8242. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8243. }
  8244. /// <summary>
  8245. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8246. /// </summary>
  8247. /// <returns></returns>
  8248. [HttpPost]
  8249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8250. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8251. {
  8252. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8253. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8254. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8255. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8256. foreach (var userId in dto.UserIds)
  8257. {
  8258. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8259. }
  8260. if (permissions.Any())
  8261. {
  8262. _sqlSugar.BeginTran();
  8263. try
  8264. {
  8265. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8266. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8267. if (result < 1)
  8268. {
  8269. _sqlSugar.RollbackTran();
  8270. return Ok(JsonView(false));
  8271. }
  8272. }
  8273. catch (Exception ex)
  8274. {
  8275. _sqlSugar.RollbackTran();
  8276. return Ok(JsonView(false, ex.Message));
  8277. }
  8278. _sqlSugar.CommitTran();
  8279. return Ok(JsonView(true));
  8280. }
  8281. return Ok(JsonView(false));
  8282. }
  8283. /// <summary>
  8284. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8285. /// </summary>
  8286. /// <returns></returns>
  8287. [HttpPost]
  8288. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8290. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8291. {
  8292. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8293. if (data.Code != 0)
  8294. {
  8295. return Ok(JsonView(false, data.Msg));
  8296. }
  8297. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8298. //汇率信息记录
  8299. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8300. return Ok(JsonView(true, data.Msg, data.Data));
  8301. }
  8302. /// <summary>
  8303. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8304. /// </summary>
  8305. /// <param name="dto"></param>
  8306. /// <returns></returns>
  8307. [HttpPost]
  8308. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8310. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8311. {
  8312. try
  8313. {
  8314. var id = dto.Id;
  8315. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8316. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8317. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8318. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8319. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8320. 3 团组成员名单 1 团组成员名单", ""));
  8321. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8322. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8323. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8324. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8325. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8326. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8327. //数据源
  8328. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8329. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8330. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8331. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8332. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8333. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8334. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8335. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8336. .Select((x, a, b) => new
  8337. {
  8338. x.Index,
  8339. itemName = a.Name,
  8340. CurrencyStr = b.Name,
  8341. x.Cost,
  8342. x.SubTotal,
  8343. x.Remark
  8344. })
  8345. .OrderBy((x) => x.Index)
  8346. .ToList(); //其他款项费用
  8347. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8348. var peiceItemCurrencys = new List<string>();
  8349. if (_DayAndCosts.Any())
  8350. {
  8351. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8352. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8353. }
  8354. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8355. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8356. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8357. {
  8358. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8359. }
  8360. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8361. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8362. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8363. if (dto.ExportType == 1) //明细表
  8364. {
  8365. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8366. {
  8367. //获取模板
  8368. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8369. //载入模板
  8370. Document doc = new Document(tempPath);
  8371. DocumentBuilder builder = new DocumentBuilder(doc);
  8372. //利用键值对存放数据
  8373. Dictionary<string, string> dic = new Dictionary<string, string>();
  8374. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8375. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8376. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8377. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8378. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8379. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8380. //境内费用(其他费用)
  8381. if (_EnterExitCosts.ChoiceOne == 1)
  8382. {
  8383. string row1_1 = "";
  8384. if (_EnterExitCosts.Visa > 0)
  8385. {
  8386. //insidePayTotal += _EnterExitCosts.Visa;
  8387. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8388. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8389. //{
  8390. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8391. //}
  8392. }
  8393. string row1_2 = "";
  8394. if (_EnterExitCosts.YiMiao > 0)
  8395. {
  8396. //insidePayTotal += _EnterExitCosts.YiMiao;
  8397. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8398. }
  8399. if (_EnterExitCosts.HeSuan > 0)
  8400. {
  8401. //insidePayTotal += _EnterExitCosts.HeSuan;
  8402. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8403. }
  8404. if (_EnterExitCosts.Service > 0)
  8405. {
  8406. //insidePayTotal += _EnterExitCosts.Service;
  8407. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8408. }
  8409. string row1_3 = "";
  8410. if (_EnterExitCosts.Safe > 0)
  8411. {
  8412. //insidePayTotal += _EnterExitCosts.Safe;
  8413. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8414. }
  8415. if (_EnterExitCosts.Ticket > 0)
  8416. {
  8417. //insidePayTotal += _EnterExitCosts.Ticket;
  8418. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8419. }
  8420. string row1 = "";
  8421. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8422. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8423. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8424. row1 += $"备注:{_EnterExitCosts.Remark}";
  8425. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8426. dic.Add("Row1Str", row1);
  8427. }
  8428. string airTotalStr = string.Empty,
  8429. airPriceStr = string.Empty;
  8430. //经济舱
  8431. if (_EnterExitCosts.SumJJC == 1)
  8432. {
  8433. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8434. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8435. }
  8436. //公务舱
  8437. if (_EnterExitCosts.SumGWC == 1)
  8438. {
  8439. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8440. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8441. }
  8442. //头等舱
  8443. if (_EnterExitCosts.SumTDC == 1)
  8444. {
  8445. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8446. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8447. }
  8448. //汇率描述
  8449. string rateStr = "";
  8450. if (peiceItemCurrencyInfos.Any())
  8451. {
  8452. rateStr = "\r\n汇率描述:";
  8453. foreach (var item in peiceItemCurrencyInfos)
  8454. {
  8455. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8456. }
  8457. }
  8458. string twoItemRemark = "备注:";
  8459. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8460. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8461. dic.Add("AirTotalStr", airTotalStr);
  8462. dic.Add("AirPriceStr", airPriceStr);
  8463. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8464. dic.Add("TwoItemRemark", twoItemRemark);
  8465. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8466. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8467. int table1Row = 0,
  8468. table2Row = 0,
  8469. table3Row = 0,
  8470. table4Row = 0,
  8471. table5Row = 0;
  8472. //住宿费
  8473. if (_EnterExitCosts.ChoiceThree == 1)
  8474. {
  8475. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8476. table1Row = dac1.Count;
  8477. #region 填充word表格内容
  8478. for (int i = 0; i < dac1.Count; i++)
  8479. {
  8480. var dac = dac1[i];
  8481. if (dac == null) continue;
  8482. builder.MoveToCell(0, i, 0, 0);
  8483. builder.Write("第" + dac.Days.ToString() + "晚:");
  8484. builder.MoveToCell(0, i, 1, 0);
  8485. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8486. //builder.Write(dac.Place == null ? "" : dac.Place);
  8487. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8488. builder.MoveToCell(0, i, 2, 0);
  8489. builder.Write("费用标准:");
  8490. string curr = "";
  8491. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8492. if (currData != null)
  8493. {
  8494. curr = currData.Name;
  8495. }
  8496. builder.MoveToCell(0, i, 3, 0);
  8497. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8498. builder.MoveToCell(0, i, 4, 0);
  8499. builder.Write("费用小计:");
  8500. builder.MoveToCell(0, i, 5, 0);
  8501. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8502. }
  8503. #endregion
  8504. }
  8505. else dic.Add("SubZS", "0.00");
  8506. //删除多余行
  8507. while (table1.Rows.Count > table1Row)
  8508. {
  8509. table1.Rows.RemoveAt(table1Row);
  8510. }
  8511. //伙食费
  8512. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8513. if (_EnterExitCosts.ChoiceFour == 1)
  8514. {
  8515. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8516. table2Row = dac2.Count;
  8517. #region 填充word表格内容
  8518. for (int i = 0; i < dac2.Count; i++)
  8519. {
  8520. var dac = dac2[i];
  8521. if (dac == null) continue;
  8522. builder.MoveToCell(1, i, 0, 0);
  8523. builder.Write("第" + dac.Days.ToString() + "天:");
  8524. builder.MoveToCell(1, i, 1, 0);
  8525. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8526. builder.MoveToCell(1, i, 2, 0);
  8527. builder.Write("费用标准:");
  8528. string curr = "";
  8529. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8530. if (currData != null)
  8531. {
  8532. curr = currData.Name;
  8533. }
  8534. builder.MoveToCell(1, i, 3, 0);
  8535. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8536. builder.MoveToCell(1, i, 4, 0);
  8537. builder.Write("费用小计:");
  8538. builder.MoveToCell(1, i, 5, 0);
  8539. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8540. }
  8541. #endregion
  8542. }
  8543. else dic.Add("SubHS", "0.00");
  8544. //删除多余行
  8545. while (table2.Rows.Count > table2Row)
  8546. {
  8547. table2.Rows.RemoveAt(table2Row);
  8548. }
  8549. //公杂费
  8550. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8551. if (_EnterExitCosts.ChoiceFive == 1)
  8552. {
  8553. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8554. table3Row = dac3.Count;
  8555. #region 填充word表格内容
  8556. for (int i = 0; i < dac3.Count; i++)
  8557. {
  8558. var dac = dac3[i];
  8559. if (dac == null) continue;
  8560. builder.MoveToCell(2, i, 0, 0);
  8561. builder.Write("第" + dac.Days.ToString() + "天:");
  8562. builder.MoveToCell(2, i, 1, 0);
  8563. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8564. builder.MoveToCell(2, i, 2, 0);
  8565. builder.Write("费用标准:");
  8566. string curr = "";
  8567. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8568. if (currData != null)
  8569. {
  8570. curr = currData.Name;
  8571. }
  8572. builder.MoveToCell(2, i, 3, 0);
  8573. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8574. builder.MoveToCell(2, i, 4, 0);
  8575. builder.Write("费用小计:");
  8576. builder.MoveToCell(2, i, 5, 0);
  8577. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8578. }
  8579. //删除多余行
  8580. while (table3.Rows.Count > table3Row)
  8581. {
  8582. table3.Rows.RemoveAt(table3Row);
  8583. }
  8584. #endregion
  8585. }
  8586. else dic.Add("SubGZF", "0.00");
  8587. //删除多余行
  8588. while (table3.Rows.Count > table3Row)
  8589. {
  8590. table3.Rows.RemoveAt(table3Row);
  8591. }
  8592. //培训费
  8593. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8594. if (_EnterExitCosts.ChoiceSix == 1)
  8595. {
  8596. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8597. dic.Add("SubPX", pxStr);
  8598. table4Row = dac4.Count;
  8599. #region 填充word表格内容
  8600. for (int i = 0; i < dac4.Count; i++)
  8601. {
  8602. var dac = dac4[i];
  8603. if (dac == null) continue;
  8604. builder.MoveToCell(3, i, 0, 0);
  8605. builder.Write("第" + dac.Days.ToString() + "天:");
  8606. builder.MoveToCell(3, i, 1, 0);
  8607. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8608. builder.MoveToCell(3, i, 2, 0);
  8609. builder.Write("费用标准:");
  8610. string curr = "";
  8611. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8612. if (currData != null)
  8613. {
  8614. curr = currData.Name;
  8615. }
  8616. builder.MoveToCell(3, i, 3, 0);
  8617. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8618. builder.MoveToCell(3, i, 4, 0);
  8619. builder.Write("费用小计:");
  8620. builder.MoveToCell(3, i, 5, 0);
  8621. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8622. }
  8623. #endregion
  8624. }
  8625. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8626. //删除多余行
  8627. while (table4.Rows.Count > table4Row)
  8628. {
  8629. table4.Rows.RemoveAt(table4Row);
  8630. }
  8631. //其他费用
  8632. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8633. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8634. {
  8635. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8636. dic.Add("titleQi", qtStr);
  8637. table5Row = dac5.Count;
  8638. #region 填充word表格内容
  8639. for (int i = 0; i < dac5.Count; i++)
  8640. {
  8641. var dac = dac5[i];
  8642. if (dac == null) continue;
  8643. builder.MoveToCell(4, i, 0, 0);
  8644. builder.Write("第" + dac.Index.ToString() + "项:");
  8645. builder.MoveToCell(4, i, 1, 0);
  8646. builder.Write(dac.itemName);
  8647. builder.MoveToCell(4, i, 2, 0);
  8648. builder.Write("费用标准:");
  8649. builder.MoveToCell(4, i, 3, 0);
  8650. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8651. builder.MoveToCell(4, i, 4, 0);
  8652. builder.Write("费用小计:");
  8653. builder.MoveToCell(4, i, 5, 0);
  8654. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8655. builder.MoveToCell(4, i, 6, 0);
  8656. builder.Write("备注:");
  8657. builder.MoveToCell(4, i, 7, 0);
  8658. builder.Write(dac.Remark);
  8659. }
  8660. #endregion
  8661. }
  8662. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8663. //删除多余行
  8664. while (table5.Rows.Count > table5Row)
  8665. {
  8666. table5.Rows.RemoveAt(table5Row);
  8667. }
  8668. //加上其他费用
  8669. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8670. decimal subJJC = 0.00M,
  8671. subGWC = 0.00M,
  8672. subTDC = 0.00M;
  8673. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8674. string totalLabel = string.Format("全部费用总计:");
  8675. //经济舱
  8676. if (_EnterExitCosts.SumJJC == 1)
  8677. {
  8678. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8679. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8680. }
  8681. //公务舱
  8682. if (_EnterExitCosts.SumGWC == 1)
  8683. {
  8684. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8685. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8686. }
  8687. //头等舱
  8688. if (_EnterExitCosts.SumTDC == 1)
  8689. {
  8690. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8691. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8692. }
  8693. //TotalLabel
  8694. dic.Add("TotalLabel", totalLabel);
  8695. #region 填充word模板书签内容
  8696. foreach (var key in dic.Keys)
  8697. {
  8698. Bookmark bookmark = doc.Range.Bookmarks[key];
  8699. if (bookmark != null)
  8700. {
  8701. builder.MoveToBookmark(key);
  8702. builder.Write(dic[key]);
  8703. }
  8704. }
  8705. #endregion
  8706. //文件名
  8707. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8708. strFileName = CommonFun.ValidFileName(strFileName);
  8709. AsposeHelper.removewatermark_v2180();
  8710. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8711. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8712. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8713. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8714. }
  8715. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8716. {
  8717. //获取模板
  8718. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8719. //载入模板
  8720. Document doc = new Document(tempPath);
  8721. DocumentBuilder builder = new DocumentBuilder(doc);
  8722. Dictionary<string, string> dic = new Dictionary<string, string>();
  8723. string returnCodeLabel = string.Empty;
  8724. if (nationalTravelFeeData.Any())
  8725. {
  8726. List<string> list = new List<string>();
  8727. foreach (var item in nationalTravelFeeData)
  8728. {
  8729. list.Add($"{item.Country}({item.City})");
  8730. }
  8731. list = list.Distinct().ToList();
  8732. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8733. }
  8734. var countryLabel = string.Empty;
  8735. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8736. if (countryData.Any())
  8737. {
  8738. countryLabel = string.Join("、", countryData);
  8739. }
  8740. dic.Add("ReturnCodeAir", returnCodeLabel);
  8741. dic.Add("VisitStartDate", "-");
  8742. dic.Add("VisitEndDate", "-");
  8743. dic.Add("Day", "-");
  8744. dic.Add("VisitCountry", countryLabel);
  8745. dic.Add("ClientUnit", "-");
  8746. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8747. //dic.Add("Names", Names);
  8748. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8749. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8750. decimal dac1totalPrice = 0.00M;
  8751. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8752. foreach (var dac in dac1)
  8753. {
  8754. if (dac.SubTotal == 0.00M)
  8755. {
  8756. continue;
  8757. }
  8758. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8759. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8760. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8761. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8762. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8763. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8764. builder.Write(currency);//币种
  8765. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8766. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8767. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8768. builder.Write("");//人数
  8769. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8770. builder.Write("");//天数
  8771. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8772. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8773. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8774. decimal rate = 0.00M;
  8775. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8776. builder.Write(rate.ToString("#0.0000"));//汇率
  8777. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8778. decimal rbmPrice = dac.SubTotal;
  8779. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8780. accommodationStartIndex++;
  8781. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8782. }
  8783. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8784. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8785. {
  8786. table1.Rows.RemoveAt(i - 1);
  8787. foodandotherStartIndex--;
  8788. }
  8789. if (dac2.Count == dac3.Count)//国家 币种 金额
  8790. {
  8791. for (int i = 0; i < dac2.Count; i++)
  8792. {
  8793. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8794. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8795. }
  8796. }
  8797. decimal dac2totalPrice = 0.00M;
  8798. foreach (var dac in dac2)
  8799. {
  8800. if (dac.SubTotal == 0)
  8801. {
  8802. continue;
  8803. }
  8804. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8805. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8806. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8807. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8808. builder.Write(currency);//币种
  8809. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8810. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8811. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8812. builder.Write("");//人数
  8813. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8814. builder.Write("");//天数
  8815. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8816. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8817. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8818. decimal rate = 0.00M;
  8819. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8820. builder.Write(rate.ToString("#0.0000"));//汇率
  8821. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8822. decimal rbmPrice = dac.SubTotal;
  8823. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8824. foodandotherStartIndex++;
  8825. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8826. }
  8827. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8828. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8829. {
  8830. table1.Rows.RemoveAt(i - 1);
  8831. }
  8832. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8833. string otherFeeStr = "";
  8834. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8835. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8836. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8837. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8838. foreach (var otherInfo in dac5)
  8839. {
  8840. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8841. }
  8842. #endregion
  8843. if (otherFeeStr.Length > 0)
  8844. {
  8845. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8846. otherFeeStr = $"({otherFeeStr})";
  8847. dic.Add("OtherFeeStr", otherFeeStr);
  8848. }
  8849. //总计
  8850. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8851. //国际旅费
  8852. string outsideAir = string.Empty;
  8853. string allPriceAir = string.Empty;
  8854. if (_EnterExitCosts.SumJJC == 1)
  8855. {
  8856. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8857. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8858. }
  8859. if (_EnterExitCosts.SumGWC == 1)
  8860. {
  8861. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8862. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8863. }
  8864. if (_EnterExitCosts.SumTDC == 1)
  8865. {
  8866. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8867. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8868. }
  8869. dic.Add("InTravelPrice", $"({outsideAir})");
  8870. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8871. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8872. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8873. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8874. foreach (var key in dic.Keys)
  8875. {
  8876. builder.MoveToBookmark(key);
  8877. builder.Write(dic[key]);
  8878. }
  8879. //模板文件名
  8880. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8881. strFileName = CommonFun.ValidFileName(strFileName);
  8882. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8883. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8884. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8885. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8886. }
  8887. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8888. {
  8889. //获取模板
  8890. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8891. //载入模板
  8892. WorkbookDesigner designer = new WorkbookDesigner();
  8893. designer.Workbook = new Workbook(tempPath);
  8894. Dictionary<string, string> dic = new Dictionary<string, string>();
  8895. string returnCodeLabel = string.Empty;
  8896. if (nationalTravelFeeData.Any())
  8897. {
  8898. List<string> list = new List<string>();
  8899. foreach (var item in nationalTravelFeeData)
  8900. {
  8901. list.Add($"{item.Country}({item.City})");
  8902. }
  8903. list = list.Distinct().ToList();
  8904. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8905. }
  8906. var countryLabel = string.Empty;
  8907. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8908. if (countryData.Any())
  8909. {
  8910. countryLabel = string.Join("、", countryData);
  8911. }
  8912. dic.Add("ReturnCodeAir", returnCodeLabel);
  8913. dic.Add("VisitStartDate", "-");
  8914. dic.Add("VisitEndDate", "-");
  8915. dic.Add("Day", "0");
  8916. dic.Add("VisitCountry", countryLabel);
  8917. dic.Add("ClientUnit", "-");
  8918. designer.SetDataSource("ClientUnit", "-");
  8919. designer.SetDataSource("VisitCountry", countryLabel);
  8920. designer.SetDataSource("Group", "-");
  8921. designer.SetDataSource("ClientUnitTitle", "-");
  8922. designer.SetDataSource("Name", "-");
  8923. designer.SetDataSource("VisitStartDate", "-");
  8924. designer.SetDataSource("Day", "0");
  8925. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8926. designer.SetDataSource("ReturnCodeAir", "-");
  8927. int startIndex = 10;
  8928. const int startIndexcopy = 10;
  8929. if (dac2.Count == dac3.Count)//国家 币种 金额
  8930. {
  8931. for (int i = 0; i < dac2.Count; i++)
  8932. {
  8933. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8934. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8935. }
  8936. }
  8937. DataTable dtdac1 = new DataTable();
  8938. List<string> place = new List<string>();
  8939. dtdac1.Columns.AddRange(new DataColumn[] {
  8940. new DataColumn(){ ColumnName = "city"},
  8941. new DataColumn(){ ColumnName = "curr"},
  8942. new DataColumn(){ ColumnName = "criterion"},
  8943. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8944. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8945. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8946. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8947. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8948. });
  8949. DataTable dtdac2 = new DataTable();
  8950. dtdac2.Columns.AddRange(new DataColumn[] {
  8951. new DataColumn(){ ColumnName = "city"},
  8952. new DataColumn(){ ColumnName = "curr"},
  8953. new DataColumn(){ ColumnName = "criterion"},
  8954. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8955. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8956. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8957. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8958. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8959. });
  8960. dtdac1.TableName = "tb1";
  8961. dtdac2.TableName = "tb2";
  8962. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8963. foreach (var item in dac1)
  8964. {
  8965. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8966. if (place.Contains(item.Place))
  8967. {
  8968. continue;
  8969. }
  8970. DataRow row = dtdac1.NewRow();
  8971. row["city"] = item.Place;
  8972. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8973. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8974. row["curr"] = currency;
  8975. row["rate"] = rate.ToString("#0.0000");
  8976. row["criterion"] = item.Cost.ToString("#0.00");
  8977. row["number"] = 1;
  8978. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8979. //row["costRMB"] = rbmPrice;
  8980. dtdac1.Rows.Add(row);
  8981. place.Add(item.Place);
  8982. }
  8983. place = new List<string>();
  8984. foreach (var item in dac2)
  8985. {
  8986. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8987. if (place.Contains(item.Place))
  8988. {
  8989. continue;
  8990. }
  8991. DataRow row = dtdac2.NewRow();
  8992. row["city"] = item.Place;
  8993. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8994. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8995. row["curr"] = currency;
  8996. row["rate"] = rate.ToString("#0.0000");
  8997. row["criterion"] = item.Cost.ToString("#0.00");
  8998. row["number"] = 1;
  8999. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9000. //row["cost"] = item.SubTotal;
  9001. //row["costRMB"] = rbmPrice;
  9002. dtdac2.Rows.Add(row);
  9003. place.Add(item.Place);
  9004. //dac2totalPrice += rbmPrice;
  9005. }
  9006. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9007. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9008. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9009. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9010. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9011. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9012. string cell4Str1 = string.Empty;
  9013. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9014. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9015. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9016. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9017. string cellStr = $" 5.其他费用(";
  9018. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9019. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9020. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9021. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9022. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9023. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9024. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9025. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9026. foreach (var otherInfo in dac5)
  9027. {
  9028. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9029. }
  9030. #endregion
  9031. if (cellStr.Length > 8)
  9032. {
  9033. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9034. }
  9035. cellStr += ")";
  9036. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9037. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9038. decimal pxFee = dac4.Sum(it => it.Cost);
  9039. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9040. string celllastStr1 = "";
  9041. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9042. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9043. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9044. celllastStr1 += $",国际旅费 元";
  9045. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9046. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9047. designer.SetDataSource("cell4Str", cell4Str);
  9048. designer.SetDataSource("cellStr", cellStr);
  9049. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9050. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9051. designer.SetDataSource("celllastStr", celllastStr);
  9052. Workbook wb = designer.Workbook;
  9053. var sheet = wb.Worksheets[0];
  9054. //绑定datatable数据集
  9055. designer.SetDataSource(dtdac1);
  9056. designer.SetDataSource(dtdac2);
  9057. designer.Process();
  9058. var rowStart = dtdac1.Rows.Count;
  9059. while (rowStart > 0)
  9060. {
  9061. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  9062. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9063. startIndex++;
  9064. rowStart--;
  9065. }
  9066. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  9067. startIndex += 1; //总计行
  9068. rowStart = dtdac2.Rows.Count;
  9069. while (rowStart > 0)
  9070. {
  9071. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  9072. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9073. startIndex++;
  9074. rowStart--;
  9075. }
  9076. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  9077. wb.CalculateFormula(true);
  9078. //模板文件名
  9079. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9080. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9081. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9082. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9083. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9084. }
  9085. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  9086. {
  9087. //获取模板
  9088. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  9089. //载入模板
  9090. Document doc = new Document(tempPath);
  9091. DocumentBuilder builder = new DocumentBuilder(doc);
  9092. Dictionary<string, string> dic = new Dictionary<string, string>();
  9093. dic.Add("GroupName", "-");
  9094. dic.Add("ClientUnit", "-");
  9095. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9096. //string missionLeaderJob = "";//负责人job
  9097. //int groupNumber = 0; //团人数
  9098. dic.Add("MissionLeader", "-"); //团负责人
  9099. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9100. dic.Add("GroupNumber", "0"); //团人数
  9101. dic.Add("Day", "0");
  9102. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9103. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9104. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9105. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9106. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9107. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9108. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9109. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9110. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9111. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9112. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9113. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9114. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9115. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9116. //其他费用
  9117. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9118. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9119. //其他费用合计
  9120. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9121. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9122. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9123. //公务舱合计
  9124. //国际旅费
  9125. //string outsideJJ = "";
  9126. //string allPriceJJ = "";
  9127. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9128. {
  9129. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9130. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9131. }
  9132. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9133. {
  9134. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9135. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9136. }
  9137. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9138. {
  9139. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9140. dic.Add("AirFeeTotal", airFeeTotalStr);
  9141. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9142. dic.Add("FeeTotal", feeTotalStr);
  9143. }
  9144. foreach (var key in dic.Keys)
  9145. {
  9146. builder.MoveToBookmark(key);
  9147. builder.Write(dic[key]);
  9148. }
  9149. //模板文件名
  9150. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9151. strFileName = CommonFun.ValidFileName(strFileName);
  9152. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9153. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9154. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9155. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9156. }
  9157. }
  9158. else if (dto.ExportType == 2) //表格
  9159. {
  9160. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9161. }
  9162. else if (dto.ExportType == 3)
  9163. {
  9164. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9165. }
  9166. return Ok(JsonView(400, "只可导出明细表!", ""));
  9167. }
  9168. catch (Exception ex)
  9169. {
  9170. return Ok(JsonView(400, ex.Message, ""));
  9171. }
  9172. }
  9173. /// <summary>
  9174. /// 获取三公费用标准city
  9175. /// </summary>
  9176. /// <param name="placeData"></param>
  9177. /// <param name="nationalTravelFeeId"></param>
  9178. /// <returns></returns>
  9179. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9180. {
  9181. string _city = string.Empty;
  9182. if (!placeData.Any()) return _city;
  9183. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9184. if (data == null) return _city;
  9185. string country = data.Country;
  9186. string city = data.City;
  9187. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9188. else _city = city;
  9189. return _city;
  9190. }
  9191. /// <summary>
  9192. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9193. /// </summary>
  9194. /// <returns></returns>
  9195. [HttpPost]
  9196. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9198. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9199. {
  9200. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9201. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9202. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9203. if (_view.Code == 0)
  9204. {
  9205. return Ok(JsonView(true, "操作成功"));
  9206. }
  9207. return Ok(JsonView(false, "操作失败"));
  9208. }
  9209. /// <summary>
  9210. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9211. /// </summary>
  9212. /// <returns></returns>
  9213. [HttpPost]
  9214. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9216. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9217. {
  9218. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9219. if (data.Code != 0)
  9220. {
  9221. return Ok(JsonView(false, data.Msg));
  9222. }
  9223. return Ok(JsonView(true, "操作成功!", data.Data));
  9224. }
  9225. /// <summary>
  9226. /// 三公其他费用草稿 删除
  9227. /// </summary>
  9228. /// <param name="dto"></param>
  9229. /// <returns></returns>
  9230. [HttpPost]
  9231. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9232. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9233. {
  9234. var jw = JsonView(false, "删除失败!");
  9235. var data = new Grp_DayOtherPriceDraft()
  9236. {
  9237. Id = dto.Id,
  9238. IsDel = 1,
  9239. DeleteUserId = dto.DeleteUserId,
  9240. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9241. };
  9242. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9243. if (del > 0)
  9244. {
  9245. jw.Code = 200;
  9246. jw.Msg = "删除成功!";
  9247. }
  9248. return Ok(jw);
  9249. }
  9250. /// <summary>
  9251. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9252. /// </summary>
  9253. /// <returns></returns>
  9254. [HttpPost]
  9255. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9256. {
  9257. var jw = JsonView(false);
  9258. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9259. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9260. jw.Code = StatusCodes.Status200OK;
  9261. jw.Msg = "操作成功!";
  9262. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9263. return Ok(jw);
  9264. }
  9265. /// <summary>
  9266. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9267. /// </summary>
  9268. /// <param name="dto"></param>
  9269. /// <returns></returns>
  9270. [HttpPost]
  9271. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9272. {
  9273. int userId = dto.UserId,
  9274. portId = dto.PortType,
  9275. groupId = dto.GroupId,
  9276. draftId = dto.DraftId;
  9277. _portTypeData.Add(1);
  9278. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9279. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9280. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9281. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9282. _sqlSugar.BeginTran();
  9283. try
  9284. {
  9285. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9286. if (draftDatas == null)
  9287. {
  9288. _sqlSugar.RollbackTran();
  9289. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9290. }
  9291. //验证可覆盖已有数据 两边创建人需为同一人;
  9292. int draftCreateUserId = draftDatas.CreateUserId,
  9293. formalCreateUserId = 0;
  9294. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9295. if (formalData != null)
  9296. {
  9297. formalCreateUserId = formalData.CreateUserId;
  9298. if (draftCreateUserId != formalCreateUserId)
  9299. {
  9300. _sqlSugar.RollbackTran();
  9301. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9302. }
  9303. }
  9304. //默认添加查看、编辑权限(创建人、自己)
  9305. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9306. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9307. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9308. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9309. newExterData.DiId = groupId;
  9310. newExterData.CreateUserId = userId;
  9311. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9312. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9313. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9314. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9315. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9316. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9317. //数据如果存在执行删除
  9318. if (enterExitCostInfo != null)
  9319. {
  9320. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9321. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9322. .Where(x => x.Id == enterExitCostInfo.Id)
  9323. .ExecuteCommand();
  9324. _sqlSugar.Updateable<Grp_DayAndCost>()
  9325. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9326. .Where(x => x.DiId == groupId)
  9327. .ExecuteCommand();
  9328. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9329. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9330. .Where(x => x.Diid == groupId)
  9331. .ExecuteCommand();
  9332. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9333. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9334. .Where(x => x.GroupId == groupId)
  9335. .ExecuteCommand();
  9336. }
  9337. //执行insert
  9338. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9339. if (insertId < 1)
  9340. {
  9341. _sqlSugar.RollbackTran();
  9342. return Ok(JsonView(false, "草稿数据导入失败!"));
  9343. }
  9344. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9345. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9346. #region 默认添加权限
  9347. #endregion
  9348. _sqlSugar.CommitTran();
  9349. //执行操作之后
  9350. //生成默认文件pdf并且通知人员
  9351. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9352. {
  9353. DiId = groupId,
  9354. ExportType = 1,
  9355. SubTypeId = 1005
  9356. }, "pdf");
  9357. //发送通知
  9358. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9359. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9360. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9361. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9362. //汇率信息记录
  9363. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9364. return Ok(JsonView(true));
  9365. }
  9366. catch (Exception ex)
  9367. {
  9368. _sqlSugar.RollbackTran();
  9369. return Ok(JsonView(false, ex.Message));
  9370. }
  9371. }
  9372. #endregion
  9373. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9374. /// <summary>
  9375. /// 获取币种基础数据(含逻辑处理)
  9376. /// </summary>
  9377. /// <returns></returns>
  9378. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9379. {
  9380. return await GeneralMethod.EnterExitCostInitRate();
  9381. }
  9382. /// <summary>
  9383. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9384. /// </summary>
  9385. /// <returns></returns>
  9386. [HttpPost]
  9387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9388. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9389. {
  9390. //验证城市归属并给默认值
  9391. int provinceId = dto.ProvinceId;
  9392. if (provinceId < 1) provinceId = 122;
  9393. var dataSource = await _sqlSugar
  9394. .Queryable<Sys_SetData>()
  9395. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9396. .ToListAsync();
  9397. var fileTypes = new List<EecSetDataInfoView>();
  9398. //三公费用-Word明细类型
  9399. var wordTypeData = dataSource
  9400. .Where(it => it.STid == 72)
  9401. .Select(x => new EecSetDataInfoView
  9402. {
  9403. ParentId = 1,
  9404. Id = x.Id,
  9405. Name = x.Name
  9406. })
  9407. .ToArray();
  9408. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9409. var excelTypeData = dataSource
  9410. .Where(it => it.STid == 73)
  9411. .Select(x => new EecSetDataInfoView
  9412. {
  9413. ParentId = 2,
  9414. Id = x.Id,
  9415. Name = x.Name
  9416. })
  9417. .ToArray();
  9418. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9419. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9420. fileTypes.Add(groupNameList);
  9421. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9422. //默认币种显示
  9423. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9424. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9425. return Ok(JsonView(true, "查询成功!", new
  9426. {
  9427. FileTypeData = fileTypes,
  9428. CurrencyInit = _currencyInfos,
  9429. viewPermissionData = viewPermissionData
  9430. }));
  9431. }
  9432. /// <summary>
  9433. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9434. /// </summary>
  9435. /// <returns></returns>
  9436. [HttpPost]
  9437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9438. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9439. {
  9440. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9441. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9442. RefAsync<int> total = 0;
  9443. int diId = 0;
  9444. var status = int.TryParse(dto.GroupName, out diId);
  9445. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9446. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9447. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9448. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9449. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9450. .OrderByDescending(x => x.VisitStartDate)
  9451. .Select(x => new EnterExitCostMobileGroupView()
  9452. {
  9453. Id = x.Id,
  9454. GroupName = x.TeamName,
  9455. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9456. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9457. ProvinceId = x.CityId
  9458. })
  9459. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9460. //处理省份Id
  9461. if (data.Any())
  9462. {
  9463. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9464. if (provCityDatas.Any())
  9465. {
  9466. foreach (var item in data)
  9467. {
  9468. var provinceId = item.ProvinceId;
  9469. var isDefualtVal = true;
  9470. if (provinceId > 0)
  9471. {
  9472. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9473. if (parentId != null)
  9474. {
  9475. isDefualtVal = false;
  9476. item.ProvinceId = (int)parentId;
  9477. }
  9478. }
  9479. if (isDefualtVal)
  9480. {
  9481. item.ProvinceId = 122; //默认四川
  9482. }
  9483. }
  9484. }
  9485. }
  9486. //处理是否显示
  9487. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9488. {
  9489. foreach (var item in data)
  9490. {
  9491. item.IsView = true;
  9492. }
  9493. }
  9494. return Ok(JsonView(true, "查询成功!", data, total));
  9495. }
  9496. /// <summary>
  9497. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9498. /// </summary>
  9499. /// <returns></returns>
  9500. [HttpPost]
  9501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9502. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9503. {
  9504. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9505. RefAsync<int> total = 0;
  9506. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9507. .Where(x => x.IsDel == 0 && x.STid == 66)
  9508. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9509. .Select(x => new
  9510. {
  9511. id = x.Id,
  9512. name = x.Name,
  9513. remark = x.Remark,
  9514. })
  9515. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9516. return Ok(JsonView(true, "查询成功!", data, total));
  9517. }
  9518. /// <summary>
  9519. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9520. /// </summary>
  9521. /// <returns></returns>
  9522. [HttpPost]
  9523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9524. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9525. {
  9526. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9527. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9528. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9529. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9530. var groupOtherRateData = groupRateData.TeamRates;
  9531. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9532. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9533. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9534. groupOtherRateData = groupOtherRateData
  9535. .Select(x => new TeamRateDescAddCurrencyIdView
  9536. {
  9537. CurrencyId = x.CurrencyId,
  9538. CurrencyName = x.CurrencyName,
  9539. CurrencyCode = x.CurrencyCode,
  9540. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9541. }).ToList();
  9542. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9543. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9544. }
  9545. /// <summary>
  9546. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9547. /// </summary>
  9548. /// <returns></returns>
  9549. [HttpPost]
  9550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9551. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9552. {
  9553. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9554. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9555. var tipsData = new List<int>() { 1, 2, 3 };
  9556. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9557. if (dto.TipsType == 1)
  9558. {
  9559. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9560. }
  9561. else if (dto.TipsType == 2)
  9562. {
  9563. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9564. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9565. }
  9566. else if (dto.TipsType == 3)
  9567. {
  9568. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9569. return Ok(JsonView(true, "查询成功!", airData));
  9570. }
  9571. return Ok(JsonView(false));
  9572. }
  9573. /// <summary>
  9574. /// 团组模块 - 出入境国家费用标准-移动端 List
  9575. /// </summary>
  9576. /// <returns></returns>
  9577. [HttpPost]
  9578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9579. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9580. {
  9581. Stopwatch sw = new Stopwatch();
  9582. sw.Start();
  9583. int provinceId = dto.ProvinceId;
  9584. if (provinceId < 1) provinceId = 122; // 默认四川
  9585. RefAsync<int> total = 0;
  9586. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9587. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9588. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9589. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9590. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9591. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9592. .Select((ntf, sd, u, sd1) => new
  9593. {
  9594. Id = ntf.Id,
  9595. Area = $"{ntf.Country}-{ntf.City}",
  9596. Currency = ntf.Currency,
  9597. CurrencyCode = sd.Name,
  9598. CurrencyName = sd.Remark,
  9599. RoomCost = ntf.RoomCost,
  9600. FoodCost = ntf.FoodCost,
  9601. PublicCost = ntf.PublicCost,
  9602. TrainCost = ntf.TrainCost,
  9603. LastUpdateUserId = ntf.LastUpdateUserId,
  9604. LastUpdateUserName = u.CnName,
  9605. LastUpdateTime = ntf.LastUpdateTime
  9606. })
  9607. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9608. sw.Stop();
  9609. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9610. }
  9611. /// <summary>
  9612. /// 团组模块 - 出入境费用-移动端 - Info
  9613. /// </summary>
  9614. /// <returns></returns>
  9615. [HttpPost]
  9616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9617. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9618. {
  9619. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9620. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9621. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9622. return Ok(data);
  9623. }
  9624. /// <summary>
  9625. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9626. /// </summary>
  9627. /// <returns></returns>
  9628. [HttpPost]
  9629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9630. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9631. {
  9632. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9633. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9634. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9635. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9636. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9637. mobileInfo.DiId = dto.DiId;
  9638. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9639. if (eecInfo == null) return Ok(mobileInfo);
  9640. //验证查看权限
  9641. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9642. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9643. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9644. mobileInfo.IsAssignPerm = isSet;
  9645. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9646. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9647. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9648. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9649. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9650. {
  9651. SubId = dac.Id,
  9652. DiId = dac.DiId,
  9653. Type = dac.Type,
  9654. Days = dac.Days,
  9655. NationalTravelFeeId = dac.NationalTravelFeeId,
  9656. Arae = $"{ntf.Country}-{ntf.City}",
  9657. Cost = dac.Cost,
  9658. Currency = dac.Currency,
  9659. CurrencyName = sd.Name,
  9660. SubTotal = dac.SubTotal,
  9661. })
  9662. .ToList();
  9663. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9664. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9665. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9666. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9667. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9668. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9669. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9670. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9671. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9672. //其他款项
  9673. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9674. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9675. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9676. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9677. .OrderBy((dop, sd1, sd2) => dop.Index)
  9678. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9679. {
  9680. SubId = dop.Id,
  9681. DiId = dop.Diid,
  9682. Index = dop.Index,
  9683. SetDataId = dop.SetDataId,
  9684. SetDataName = sd1.Name,
  9685. Cost = dop.Cost,
  9686. Currency = dop.Currency,
  9687. CurrencyName = sd2.Remark,
  9688. SubTotal = dop.SubTotal,
  9689. Remark = dop.Remark,
  9690. })
  9691. .ToArray();
  9692. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9693. return Ok(mobileInfo);
  9694. }
  9695. /// <summary>
  9696. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9697. /// </summary>
  9698. /// <returns></returns>
  9699. [HttpPost]
  9700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9701. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9702. {
  9703. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9704. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9705. //验证查看权限
  9706. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9707. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9708. var userIds = await _sqlSugar
  9709. .Queryable<Grp_EnterExitCostPermission>()
  9710. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9711. .Select(x => x.UserId)
  9712. .ToArrayAsync();
  9713. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9714. var perUsersView = new List<dynamic>();
  9715. foreach (var item in perUsers)
  9716. {
  9717. bool isView1 = false;
  9718. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9719. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9720. }
  9721. return Ok(JsonView(perUsersView));
  9722. }
  9723. /// <summary>
  9724. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9725. /// </summary>
  9726. /// <returns></returns>
  9727. [HttpPost]
  9728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9729. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9730. {
  9731. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9732. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9733. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9734. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9735. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9736. //验证查看权限
  9737. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9738. //if (!isView) return Ok(JsonView(false, msg));
  9739. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9740. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9741. var subType = dto.SubType;
  9742. if (subType == 1) //1:境内费用
  9743. {
  9744. var oneData = new ChoiceOneMobileSubInfoView()
  9745. {
  9746. Id = eecInfo.Id,
  9747. ChoiceOne = eecInfo.ChoiceOne,
  9748. ChoiceOneTotalCost = eecInfo.InsidePay,
  9749. Visa = eecInfo.Visa,
  9750. VisaRemark = eecInfo.VisaRemark,
  9751. YiMiao = eecInfo.YiMiao,
  9752. HeSuan = eecInfo.HeSuan,
  9753. Service = eecInfo.Service,
  9754. Ticket = eecInfo.Ticket,
  9755. Safe = eecInfo.Safe,
  9756. FirstItemRemark = eecInfo.FirstItemRemark
  9757. };
  9758. return Ok(JsonView(oneData));
  9759. }
  9760. else if (subType == 2) //2:国际旅费
  9761. {
  9762. var twoData = new ChoiceTwoMobileSubInfoView()
  9763. {
  9764. Id = eecInfo.Id,
  9765. ChoiceTwoJJ = eecInfo.SumJJC,
  9766. OutsideJJPay = eecInfo.OutsideJJPay,
  9767. ChoiceTwoGW = eecInfo.SumGWC,
  9768. OutsideGWPay = eecInfo.OutsideGWPay,
  9769. ChoiceTwoTD = eecInfo.SumTDC,
  9770. OutsideTDPay = eecInfo.OutsideTDPay,
  9771. AirJJ = eecInfo.AirJJ,
  9772. AirGW = eecInfo.AirGW,
  9773. AirTD = eecInfo.AirTD,
  9774. CityTranffic = eecInfo.CityTranffic,
  9775. TwoItemRemark = eecInfo.TwoItemRemark
  9776. };
  9777. return Ok(JsonView(twoData));
  9778. }
  9779. else if (subType == 3) //3:住宿费
  9780. {
  9781. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9782. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9783. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9784. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9785. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9786. {
  9787. SubId = dac.Id,
  9788. DiId = dac.DiId,
  9789. Type = dac.Type,
  9790. Days = dac.Days,
  9791. NationalTravelFeeId = dac.NationalTravelFeeId,
  9792. Arae = $"{ntf.Country}-{ntf.City}",
  9793. Cost = dac.Cost,
  9794. Currency = dac.Currency,
  9795. CurrencyName = sd.Name,
  9796. SubTotal = dac.SubTotal,
  9797. })
  9798. .ToArray();
  9799. var data = new ChoiceMobileSubInfo3To6View()
  9800. {
  9801. ParentId = eecInfo.Id,
  9802. Choice = eecInfo.ChoiceThree,
  9803. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9804. Details = dayAndCostDatas
  9805. };
  9806. return Ok(JsonView(data));
  9807. }
  9808. else if (subType == 4) //4:伙食费
  9809. {
  9810. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9811. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9812. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9813. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9814. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9815. {
  9816. SubId = dac.Id,
  9817. DiId = dac.DiId,
  9818. Type = dac.Type,
  9819. Days = dac.Days,
  9820. NationalTravelFeeId = dac.NationalTravelFeeId,
  9821. Arae = $"{ntf.Country}-{ntf.City}",
  9822. Cost = dac.Cost,
  9823. Currency = dac.Currency,
  9824. CurrencyName = sd.Name,
  9825. SubTotal = dac.SubTotal,
  9826. })
  9827. .ToArray();
  9828. var data = new ChoiceMobileSubInfo3To6View()
  9829. {
  9830. ParentId = eecInfo.Id,
  9831. Choice = eecInfo.ChoiceFour,
  9832. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9833. Details = dayAndCostDatas
  9834. };
  9835. return Ok(JsonView(data));
  9836. }
  9837. else if (subType == 5) //5:公杂费
  9838. {
  9839. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9840. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9841. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9842. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9843. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9844. {
  9845. SubId = dac.Id,
  9846. DiId = dac.DiId,
  9847. Type = dac.Type,
  9848. Days = dac.Days,
  9849. NationalTravelFeeId = dac.NationalTravelFeeId,
  9850. Arae = $"{ntf.Country}-{ntf.City}",
  9851. Cost = dac.Cost,
  9852. Currency = dac.Currency,
  9853. CurrencyName = sd.Name,
  9854. SubTotal = dac.SubTotal,
  9855. })
  9856. .ToArray();
  9857. var data = new ChoiceMobileSubInfo3To6View()
  9858. {
  9859. ParentId = eecInfo.Id,
  9860. Choice = eecInfo.ChoiceFive,
  9861. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9862. Details = dayAndCostDatas
  9863. };
  9864. return Ok(JsonView(data));
  9865. }
  9866. else if (subType == 6) //6:培训费
  9867. {
  9868. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9869. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9870. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9871. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9872. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9873. {
  9874. SubId = dac.Id,
  9875. DiId = dac.DiId,
  9876. Type = dac.Type,
  9877. Days = dac.Days,
  9878. NationalTravelFeeId = dac.NationalTravelFeeId,
  9879. Arae = $"{ntf.Country}-{ntf.City}",
  9880. Cost = dac.Cost,
  9881. Currency = dac.Currency,
  9882. CurrencyName = sd.Name,
  9883. SubTotal = dac.SubTotal,
  9884. })
  9885. .ToArray();
  9886. var data = new ChoiceMobileSubInfo3To6View()
  9887. {
  9888. ParentId = eecInfo.Id,
  9889. Choice = eecInfo.ChoiceSix,
  9890. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9891. Details = dayAndCostDatas
  9892. };
  9893. return Ok(JsonView(data));
  9894. }
  9895. else if (subType == 7) //7:其他
  9896. {
  9897. //其他款项
  9898. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9899. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9900. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9901. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9902. .OrderBy((dop, sd1, sd2) => dop.Index)
  9903. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9904. {
  9905. SubId = dop.Id,
  9906. DiId = dop.Diid,
  9907. Index = dop.Index,
  9908. SetDataId = dop.SetDataId,
  9909. SetDataName = sd1.Name,
  9910. Cost = dop.Cost,
  9911. Currency = dop.Currency,
  9912. CurrencyName = sd2.Name,
  9913. SubTotal = dop.SubTotal,
  9914. Remark = dop.Remark,
  9915. })
  9916. .ToArray();
  9917. var data = new ChoiceSevenMobileSubInfoView()
  9918. {
  9919. ParentId = eecInfo.Id,
  9920. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9921. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9922. Details = otherData
  9923. };
  9924. return Ok(JsonView(data));
  9925. }
  9926. return Ok(JsonView(false));
  9927. }
  9928. #region op
  9929. ///// <summary>
  9930. ///// 移动端更新费用消息通知
  9931. ///// </summary>
  9932. ///// <param name="diid"></param>
  9933. ///// <param name="id"></param>
  9934. ///// <param name="currUserId"></param>
  9935. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9936. //{
  9937. // try
  9938. // {
  9939. // ////生成默认文件pdf并且通知人员
  9940. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9941. // //{
  9942. // // DiId = diid,
  9943. // // ExportType = 1,
  9944. // // SubTypeId = 1005
  9945. // //}, "pdf");
  9946. // ////发送通知
  9947. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9948. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9949. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9950. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9951. // ////汇率信息记录
  9952. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9953. // }
  9954. // catch (Exception ex)
  9955. // {
  9956. // //记录日志
  9957. // throw;
  9958. // }
  9959. //}
  9960. /// <summary>
  9961. /// 验证出入境费用数据是否存在
  9962. /// 不存在添加
  9963. /// </summary>
  9964. /// <param name="diId"></param>
  9965. /// <param name="currUserId"></param>
  9966. /// <returns></returns>
  9967. /// <exception cref="CustomException"></exception>
  9968. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9969. {
  9970. var parentId = 0;
  9971. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9972. if (info != null)
  9973. {
  9974. parentId = info.Id;
  9975. }
  9976. else
  9977. {
  9978. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9979. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9980. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9981. parentId = addId;
  9982. }
  9983. return parentId;
  9984. }
  9985. /// <summary>
  9986. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9987. /// </summary>
  9988. /// <returns></returns>
  9989. [HttpPost]
  9990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9991. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9992. {
  9993. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9994. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9995. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9996. //验证编辑权限
  9997. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9998. //if (!isEdit) return Ok(JsonView(false, msg));
  9999. var permissions = new List<Grp_EnterExitCostPermission>();
  10000. foreach (var userId in dto.UserIds)
  10001. {
  10002. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10003. }
  10004. if (permissions.Any())
  10005. {
  10006. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10007. {
  10008. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10009. }
  10010. _sqlSugar.BeginTran();
  10011. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10012. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10013. if (result < 1)
  10014. {
  10015. _sqlSugar.RollbackTran();
  10016. return Ok(JsonView(false));
  10017. }
  10018. _sqlSugar.CommitTran();
  10019. return Ok(JsonView(true));
  10020. }
  10021. return Ok(JsonView(false));
  10022. }
  10023. /// <summary>
  10024. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10025. /// </summary>
  10026. /// <returns></returns>
  10027. [HttpPost]
  10028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10029. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10030. {
  10031. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10032. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10033. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10034. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10035. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10036. int id = dto.Id;
  10037. if (id <= 0) //add
  10038. {
  10039. //int provinceId = dto.ProvinceId;
  10040. int groupId = dto.DiId;
  10041. //if (provinceId < 1) provinceId = 122;
  10042. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10043. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10044. if (add < 1) return Ok(JsonView(false));
  10045. id = add;
  10046. }
  10047. else //update
  10048. {
  10049. ////验证编辑权限
  10050. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10051. //if (!isEdit) return Ok(JsonView(false, msg));
  10052. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  10053. if (upd < 1) return Ok(JsonView(false));
  10054. }
  10055. #region 汇率变更时更改币种相关费用
  10056. var opDayCosts = new List<Grp_DayAndCost>();
  10057. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  10058. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10059. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  10060. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10061. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10062. .Select((dac, sd) => new
  10063. {
  10064. dac.Id,
  10065. dac.DiId,
  10066. CurrencyCode = sd.Name,
  10067. dac.Cost
  10068. })
  10069. .ToList();
  10070. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10071. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10072. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10073. .Select((dop, sd) => new
  10074. {
  10075. dop.Id,
  10076. dop.Diid,
  10077. CurrencyCode = sd.Name,
  10078. dop.Cost
  10079. })
  10080. .ToList();
  10081. if (dayCosts.Count > 0)
  10082. {
  10083. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10084. foreach (var dc in new_dayCosts)
  10085. {
  10086. var thisCurrency = dc.Key.ToUpper();
  10087. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10088. if (thisRate == 0.00M) continue;
  10089. foreach (var dcSub in dc)
  10090. {
  10091. opDayCosts.Add(new Grp_DayAndCost()
  10092. {
  10093. Id = dcSub.Id,
  10094. DiId = dcSub.DiId,
  10095. Cost = dcSub.Cost,
  10096. SubTotal = dcSub.Cost * thisRate,
  10097. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10098. });
  10099. }
  10100. }
  10101. if (opDayCosts.Count > 0)
  10102. {
  10103. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10104. }
  10105. }
  10106. if (dayOtherCosts.Count > 0)
  10107. {
  10108. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10109. foreach (var dc in new_dayOtherCosts)
  10110. {
  10111. var thisCurrency = dc.Key.ToUpper();
  10112. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10113. if (thisRate == 0.00M) continue;
  10114. foreach (var dcSub in dc)
  10115. {
  10116. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10117. {
  10118. Id = dcSub.Id,
  10119. Diid = dcSub.Diid,
  10120. Cost = dcSub.Cost,
  10121. SubTotal = dcSub.Cost * thisRate,
  10122. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10123. });
  10124. }
  10125. }
  10126. if (opDayOtherCosts.Count > 0)
  10127. {
  10128. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10129. }
  10130. }
  10131. #endregion
  10132. //消息通知
  10133. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10134. //汇率信息记录
  10135. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10136. return Ok(JsonView(new { parentId = id }));
  10137. }
  10138. /// <summary>
  10139. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10140. /// </summary>
  10141. /// <returns></returns>
  10142. [HttpPost]
  10143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10144. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10145. {
  10146. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10147. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10148. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10149. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10150. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10151. int id = dto.Id;
  10152. if (id <= 0) //add
  10153. {
  10154. checkboxInfo.CreateUserId = dto.CurrUserId;
  10155. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10156. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10157. if (add < 1) return Ok(JsonView(false));
  10158. }
  10159. else //update
  10160. {
  10161. ////验证编辑权限
  10162. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10163. //if (!isEdit) return Ok(JsonView(false, msg));
  10164. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10165. .UpdateColumns(x => new
  10166. {
  10167. x.ChoiceOne,
  10168. x.ChoiceTwo,
  10169. x.SumJJC,
  10170. x.SumGWC,
  10171. x.SumTDC,
  10172. x.ChoiceThree,
  10173. x.ChoiceFour,
  10174. x.ChoiceFive,
  10175. x.ChoiceSix,
  10176. x.OtherExpenses_Checked
  10177. })
  10178. .Where(x => x.Id == id)
  10179. .ExecuteCommandAsync();
  10180. if (upd < 1) return Ok(JsonView(false));
  10181. }
  10182. return Ok(JsonView(new { parentId = id }));
  10183. }
  10184. /// <summary>
  10185. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10186. /// </summary>
  10187. /// <returns></returns>
  10188. [HttpPost]
  10189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10190. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10191. {
  10192. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10193. // if (provinceId < 1) provinceId = 122;
  10194. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10195. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10196. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10197. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10198. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10199. var checkboxInfo = new Grp_EnterExitCost()
  10200. {
  10201. Id = id,
  10202. //ProvinceId = provinceId,
  10203. DiId = diId,
  10204. CreateUserId = currUserId
  10205. };
  10206. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10207. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10208. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10209. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10210. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10211. if (id <= 0) //add
  10212. {
  10213. checkboxInfo.CreateUserId = dto.CurrUserId;
  10214. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10215. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10216. if (add < 1) return Ok(JsonView(false));
  10217. }
  10218. else //update
  10219. {
  10220. ////验证编辑权限
  10221. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10222. //if (!isEdit) return Ok(JsonView(false, msg));
  10223. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10224. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10225. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10226. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10227. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10228. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10229. .Where(x => x.Id == id)
  10230. .ExecuteCommandAsync();
  10231. if (upd < 1) return Ok(JsonView(false));
  10232. }
  10233. return Ok(JsonView(new { parentId = id }));
  10234. }
  10235. /// <summary>
  10236. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10237. /// </summary>
  10238. /// <returns></returns>
  10239. [HttpPost]
  10240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10241. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10242. {
  10243. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10244. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10245. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10246. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10247. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10248. info.FirstItemRemark = dto.FirstItemRemark;
  10249. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10250. int id = dto.Id;
  10251. if (id <= 0) //add
  10252. {
  10253. info.CreateUserId = dto.CurrUserId;
  10254. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10255. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10256. if (add < 1) return Ok(JsonView(false));
  10257. id = add;
  10258. }
  10259. else //update
  10260. {
  10261. ////验证编辑权限
  10262. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10263. //if (!isEdit) return Ok(JsonView(false, msg));
  10264. var upd = await _sqlSugar.Updateable(info)
  10265. .UpdateColumns(x => new
  10266. {
  10267. x.ChoiceOne,
  10268. x.InsidePay,
  10269. x.VisaRemark,
  10270. x.Visa,
  10271. x.Service,
  10272. x.Safe,
  10273. x.Ticket,
  10274. x.HeSuan,
  10275. x.YiMiao,
  10276. x.FirstItemRemark
  10277. })
  10278. .Where(x => x.Id == id)
  10279. .ExecuteCommandAsync();
  10280. if (upd < 1) return Ok(JsonView(false));
  10281. }
  10282. //消息通知
  10283. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10284. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10285. }
  10286. /// <summary>
  10287. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10288. /// </summary>
  10289. /// <returns></returns>
  10290. [HttpPost]
  10291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10292. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10293. {
  10294. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10295. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10296. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10297. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10298. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10299. info.DiId = dto.DiId;
  10300. //info.ProvinceId = dto.ProvinceId;
  10301. info.OutsideJJPay = dto.OutsideJJPay;
  10302. info.OutsideGWPay = dto.OutsideGWPay;
  10303. info.OutsideTDPay = dto.OutsideTDPay;
  10304. info.AirJJ = dto.AirJJ;
  10305. info.AirGW = dto.AirGW;
  10306. info.AirTD = dto.AirTD;
  10307. info.CityTranffic = dto.CityTranffic;
  10308. info.TwoItemRemark = dto.TwoItemRemark;
  10309. info.SumJJC = dto.ChoiceTwoJJ;
  10310. info.SumGWC = dto.ChoiceTwoGW;
  10311. info.SumTDC = dto.ChoiceTwoTD;
  10312. int id = dto.Id;
  10313. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10314. if (id <= 0) //add
  10315. {
  10316. info.CreateUserId = dto.CurrUserId;
  10317. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10318. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10319. if (addId <= 0) return Ok(JsonView(false));
  10320. id = addId;
  10321. }
  10322. else //update
  10323. {
  10324. ////验证编辑权限
  10325. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10326. //if (!isEdit) return Ok(JsonView(false, msg));
  10327. var upd = await _sqlSugar.Updateable(info)
  10328. .UpdateColumns(x => new
  10329. {
  10330. x.SumJJC,
  10331. x.OutsideJJPay,
  10332. x.SumGWC,
  10333. x.OutsideGWPay,
  10334. x.SumTDC,
  10335. x.OutsideTDPay,
  10336. x.AirJJ,
  10337. x.AirGW,
  10338. x.AirTD,
  10339. x.CityTranffic,
  10340. x.TwoItemRemark
  10341. })
  10342. .Where(x => x.Id == id)
  10343. .ExecuteCommandAsync();
  10344. if (upd < 1) return Ok(JsonView(false));
  10345. }
  10346. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10347. gwcItemTotal = info.AirGW + info.CityTranffic;
  10348. tdcItemTotal = info.AirTD + info.CityTranffic;
  10349. //消息通知
  10350. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10351. return Ok(JsonView(new
  10352. {
  10353. parentId = id,
  10354. choiceTwoJJ = dto.ChoiceTwoJJ,
  10355. jjcItemTotal = jjcItemTotal,
  10356. choiceTwoGW = dto.ChoiceTwoGW,
  10357. gwcItemTotal = gwcItemTotal,
  10358. choiceTwoTD = dto.ChoiceTwoTD,
  10359. tdcItemTotal = tdcItemTotal
  10360. }));
  10361. }
  10362. /// <summary>
  10363. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10364. /// </summary>
  10365. /// <returns></returns>
  10366. [HttpPost]
  10367. [ApiExplorerSettings(IgnoreApi = true)]
  10368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10369. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10370. {
  10371. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10372. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10373. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10374. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10375. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10376. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10377. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10378. var infos = infos1.Select(x => new Grp_DayAndCost
  10379. {
  10380. Id = x.Id,
  10381. DiId = dto.DiId,
  10382. Type = dto.FeeType,
  10383. Days = x.Days,
  10384. NationalTravelFeeId = x.NationalTravelFeeId,
  10385. Cost = x.Cost,
  10386. Currency = x.Currency,
  10387. SubTotal = x.SubTotal,
  10388. CreateUserId = dto.CurrUserId
  10389. })
  10390. .ToList();
  10391. var adds = infos.Where(x => x.Id <= 0).ToList();
  10392. var upds = infos.Where(x => x.Id > 0).ToList();
  10393. if (adds.Count > 0)
  10394. {
  10395. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10396. if (add < 1) return Ok(JsonView(false));
  10397. }
  10398. if (upds.Count > 0)
  10399. {
  10400. var upd = await _sqlSugar.Updateable(adds)
  10401. .UpdateColumns(x => new
  10402. {
  10403. x.Days,
  10404. x.NationalTravelFeeId,
  10405. x.Cost,
  10406. x.Currency,
  10407. x.SubTotal
  10408. })
  10409. .WhereColumns(x => new { x.Id })
  10410. .ExecuteCommandAsync();
  10411. if (upd < 1) return Ok(JsonView(false));
  10412. }
  10413. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10414. //消息通知
  10415. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10416. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10417. return Ok(JsonView(new { itemTotal = itemTotal }));
  10418. }
  10419. /// <summary>
  10420. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10421. /// </summary>
  10422. /// <returns></returns>
  10423. [HttpPost]
  10424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10425. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10426. {
  10427. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10428. int subId = dto.SubId, feeType = dto.FeeType;
  10429. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10430. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10431. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10432. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10433. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10434. subInfo.Id = subId;
  10435. subInfo.DiId = dto.DiId;
  10436. if (feeType == 3) subInfo.Type = 1;
  10437. else if (feeType == 4) subInfo.Type = 2;
  10438. else if (feeType == 5) subInfo.Type = 3;
  10439. else if (feeType == 6) subInfo.Type = 4;
  10440. subInfo.CreateUserId = dto.CurrUserId;
  10441. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10442. if (parentId < 1) return Ok(JsonView(false));
  10443. //子表op
  10444. if (subId < 1)
  10445. {
  10446. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10447. if (subAdd < 1) return Ok(JsonView(false));
  10448. }
  10449. else
  10450. {
  10451. ////验证编辑权限
  10452. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10453. //if (!isEdit) return Ok(JsonView(false, msg));
  10454. var subUpd = await _sqlSugar.Updateable(subInfo)
  10455. .UpdateColumns(x => new
  10456. {
  10457. x.Days,
  10458. x.NationalTravelFeeId,
  10459. x.Cost,
  10460. x.Currency,
  10461. x.SubTotal
  10462. })
  10463. .WhereColumns(x => new { x.Id })
  10464. .ExecuteCommandAsync();
  10465. if (subUpd < 1) return Ok(JsonView(false));
  10466. }
  10467. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10468. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10469. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10470. }
  10471. /// <summary>
  10472. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10473. /// </summary>
  10474. /// <returns></returns>
  10475. [HttpPost]
  10476. [ApiExplorerSettings(IgnoreApi = true)]
  10477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10478. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10479. {
  10480. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10481. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10482. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10483. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10484. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10485. {
  10486. Id = x.Id,
  10487. Diid = dto.DiId,
  10488. SetDataId = x.SetDataId,
  10489. Index = x.Index,
  10490. Cost = x.Cost,
  10491. Currency = x.Currency,
  10492. SubTotal = x.SubTotal,
  10493. CreateUserId = dto.CurrUserId,
  10494. Remark = x.Remark
  10495. }).ToList();
  10496. var adds = infos.Where(x => x.Id <= 0).ToList();
  10497. var upds = infos.Where(x => x.Id > 0).ToList();
  10498. if (adds.Count > 0)
  10499. {
  10500. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10501. if (add < 1) return Ok(JsonView(false));
  10502. }
  10503. if (upds.Count > 0)
  10504. {
  10505. var upd = await _sqlSugar.Updateable(adds)
  10506. .UpdateColumns(x => new
  10507. {
  10508. x.Index,
  10509. x.SetDataId,
  10510. x.Cost,
  10511. x.Currency,
  10512. x.SubTotal,
  10513. x.Remark
  10514. })
  10515. .WhereColumns(x => new { x.Id })
  10516. .ExecuteCommandAsync();
  10517. if (upd < 1) return Ok(JsonView(false));
  10518. }
  10519. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10520. //消息通知
  10521. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10522. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10523. return Ok(JsonView(new { itemTotal = itemTotal }));
  10524. }
  10525. /// <summary>
  10526. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10527. /// </summary>
  10528. /// <returns></returns>
  10529. [HttpPost]
  10530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10531. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10532. {
  10533. int subId = dto.SubId;
  10534. int diId = dto.Diid;
  10535. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10536. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10537. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10538. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10539. subInfo.Id = subId;
  10540. subInfo.Diid = dto.Diid;
  10541. subInfo.CreateUserId = dto.CurrUserId;
  10542. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10543. if (parentId < 1) return Ok(JsonView(false));
  10544. #region 子表op
  10545. if (subId < 1)//add
  10546. {
  10547. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10548. if (subAdd < 1) return Ok(JsonView(false));
  10549. }
  10550. else //upd
  10551. {
  10552. ////验证编辑权限
  10553. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10554. //if (!isEdit) return Ok(JsonView(false, msg));
  10555. var subUpd = await _sqlSugar.Updateable(subInfo)
  10556. .UpdateColumns(x => new
  10557. {
  10558. x.Index,
  10559. x.SetDataId,
  10560. x.Cost,
  10561. x.Currency,
  10562. x.SubTotal,
  10563. x.Remark
  10564. })
  10565. .WhereColumns(x => new { x.Id })
  10566. .ExecuteCommandAsync();
  10567. if (subUpd < 1) return Ok(JsonView(false));
  10568. }
  10569. #endregion
  10570. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10571. //消息通知
  10572. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10573. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10574. }
  10575. /// <summary>
  10576. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10577. /// </summary>
  10578. /// <returns></returns>
  10579. [HttpPost]
  10580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10581. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10582. {
  10583. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10584. if (data.Code != 0)
  10585. {
  10586. return Ok(JsonView(false, data.Msg));
  10587. }
  10588. return Ok(JsonView(true, "操作成功!", data.Data));
  10589. }
  10590. /// <summary>
  10591. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10592. /// </summary>
  10593. /// <param name="dto"></param>
  10594. /// <returns></returns>
  10595. [HttpPost]
  10596. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10597. {
  10598. var data = new Grp_DayOtherPrice()
  10599. {
  10600. Id = dto.Id,
  10601. IsDel = 1,
  10602. DeleteUserId = dto.DeleteUserId,
  10603. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10604. };
  10605. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10606. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10607. return Ok(JsonView(false, "删除失败!"));
  10608. }
  10609. #endregion
  10610. #endregion
  10611. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10612. /// <summary>
  10613. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10614. /// </summary>
  10615. /// <returns></returns>
  10616. [HttpGet]
  10617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10618. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10619. {
  10620. var provData = await _groupRepository.ProvinceBasicSource();
  10621. return Ok(JsonView(true, "查询成功!", provData));
  10622. }
  10623. /// <summary>
  10624. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10625. /// </summary>
  10626. /// <returns></returns>
  10627. [HttpPost]
  10628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10629. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10630. {
  10631. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10632. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10633. RefAsync<int> total = 0;
  10634. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10635. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10636. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10637. .Select(x => new
  10638. {
  10639. Id = x.Id,
  10640. DraftName = x.DraftName,
  10641. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10642. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10643. .Any()
  10644. })
  10645. .OrderByDescending(x => x.Id)
  10646. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10647. return Ok(JsonView(true, "查询成功!", data, total));
  10648. }
  10649. /// <summary>
  10650. /// 出入境费用-草稿 移动端
  10651. /// 获取币种基础数据(含逻辑处理)
  10652. /// </summary>
  10653. /// <returns></returns>
  10654. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10655. {
  10656. return await GeneralMethod.EnterExitCostInitRate();
  10657. }
  10658. /// <summary>
  10659. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10660. /// </summary>
  10661. /// <returns></returns>
  10662. [HttpPost]
  10663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10664. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10665. {
  10666. //验证城市归属并给默认值
  10667. int provinceId = dto.ProvinceId;
  10668. if (provinceId < 1) provinceId = 122;
  10669. var dataSource = await _sqlSugar
  10670. .Queryable<Sys_SetData>()
  10671. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10672. .ToListAsync();
  10673. //三公费用-Word明细类型
  10674. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10675. .Select(x => new SetDataInfoView
  10676. {
  10677. Id = x.Id,
  10678. Name = x.Name,
  10679. Remark = x.Remark
  10680. })
  10681. .ToList();
  10682. //三公费用-Excel明细类型
  10683. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10684. .Select(x => new SetDataInfoView
  10685. {
  10686. Id = x.Id,
  10687. Name = x.Name,
  10688. Remark = x.Remark
  10689. })
  10690. .ToList();
  10691. //默认币种显示
  10692. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10693. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10694. return Ok(JsonView(true, "查询成功!", new
  10695. {
  10696. WordTypeData = wordTypeData,
  10697. ExcelTypeData = excelTypeData,
  10698. CurrencyInit = _currencyInfos,
  10699. viewPermissionData = viewPermissionData
  10700. }));
  10701. }
  10702. /// <summary>
  10703. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10704. /// </summary>
  10705. /// <returns></returns>
  10706. [HttpPost]
  10707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10708. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10709. {
  10710. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10711. RefAsync<int> total = 0;
  10712. int diId = 0;
  10713. var status = int.TryParse(dto.GroupName, out diId);
  10714. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10715. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10716. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10717. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10718. .OrderByDescending(x => x.VisitStartDate)
  10719. .Select(x => new
  10720. {
  10721. Id = x.Id,
  10722. GroupName = x.TeamName
  10723. })
  10724. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10725. return Ok(JsonView(true, "查询成功!", data, total));
  10726. }
  10727. /// <summary>
  10728. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10729. /// </summary>
  10730. /// <returns></returns>
  10731. [HttpPost]
  10732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10733. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10734. {
  10735. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10736. RefAsync<int> total = 0;
  10737. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10738. .Where(x => x.IsDel == 0 && x.STid == 66)
  10739. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10740. .Select(x => new
  10741. {
  10742. id = x.Id,
  10743. name = x.Name,
  10744. remark = x.Remark,
  10745. })
  10746. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10747. return Ok(JsonView(true, "查询成功!", data, total));
  10748. }
  10749. /// <summary>
  10750. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10751. /// </summary>
  10752. /// <returns></returns>
  10753. [HttpPost]
  10754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10755. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10756. {
  10757. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10758. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10759. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10760. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10761. var groupOtherRateData = groupRateData.TeamRates;
  10762. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10763. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10764. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10765. groupOtherRateData = groupOtherRateData
  10766. .Select(x => new TeamRateDescAddCurrencyIdView
  10767. {
  10768. CurrencyId = x.CurrencyId,
  10769. CurrencyName = x.CurrencyName,
  10770. CurrencyCode = x.CurrencyCode,
  10771. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10772. }).ToList();
  10773. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10774. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10775. }
  10776. /// <summary>
  10777. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10778. /// </summary>
  10779. /// <returns></returns>
  10780. [HttpPost]
  10781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10782. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10783. {
  10784. int portType = dto.PortType;
  10785. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10786. var tipsData = new List<int>() { 1, 2, 3 };
  10787. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10788. if (dto.TipsType == 1)
  10789. {
  10790. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10791. }
  10792. else if (dto.TipsType == 2)
  10793. {
  10794. if (portType == 2)
  10795. {
  10796. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10797. }
  10798. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10799. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10800. .Select(x => x.NationalTravelFeeId)
  10801. .Distinct()
  10802. .ToListAsync();
  10803. if (portType == 2)
  10804. {
  10805. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10806. }
  10807. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10808. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10809. .Select(x => x.Country)
  10810. .Distinct()
  10811. .ToArrayAsync();
  10812. if (portType == 2)
  10813. {
  10814. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10815. }
  10816. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10817. return Ok(JsonView(true, "查询成功!", new
  10818. {
  10819. totalAmt = totalAmt,
  10820. remark = remark
  10821. }));
  10822. }
  10823. else if (dto.TipsType == 3)
  10824. {
  10825. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10826. }
  10827. return Ok(JsonView(false));
  10828. }
  10829. /// <summary>
  10830. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10831. /// </summary>
  10832. /// <returns></returns>
  10833. [HttpPost]
  10834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10835. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10836. {
  10837. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10838. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10839. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10840. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10841. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10842. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10843. var info = new Grp_EnterExitCostDraft()
  10844. {
  10845. ProvinceId = dto.ProvinceId,
  10846. DraftName = dto.DraftName,
  10847. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10848. CreateUserId = dto.CurrUserId
  10849. };
  10850. _sqlSugar.BeginTran();
  10851. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10852. if (draftId < 1)
  10853. {
  10854. _sqlSugar.RollbackTran();
  10855. return Ok(JsonView(false, "草稿创建失败!"));
  10856. }
  10857. //添加默认权限
  10858. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10859. _sqlSugar.CommitTran();
  10860. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10861. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10862. mobileInfo.Id = draftId;
  10863. mobileInfo.DraftName = dto.DraftName;
  10864. mobileInfo.Currencys = rateInfos;
  10865. mobileInfo.IsAssignPerm = assignPerm;
  10866. return Ok(JsonView(mobileInfo));
  10867. }
  10868. /// <summary>
  10869. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10870. /// </summary>
  10871. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10872. /// <summary>
  10873. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10874. /// </summary>
  10875. /// <returns></returns>
  10876. [HttpPost]
  10877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10878. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10879. {
  10880. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10881. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10882. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10883. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10884. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10885. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10886. //验证查看编辑权限
  10887. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10888. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10889. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10890. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10891. mobileInfo.IsAssignPerm = assignPerm;
  10892. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10893. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10894. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10895. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10896. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10897. {
  10898. ParentId = dac.ParentId,
  10899. SubId = dac.Id,
  10900. Type = dac.Type,
  10901. Days = dac.Days,
  10902. NationalTravelFeeId = dac.NationalTravelFeeId,
  10903. Arae = $"{ntf.Country}-{ntf.City}",
  10904. Cost = dac.Cost,
  10905. Currency = dac.Currency,
  10906. CurrencyName = sd.Name,
  10907. SubTotal = dac.SubTotal,
  10908. })
  10909. .ToList();
  10910. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10911. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10912. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10913. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10914. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10915. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10916. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10917. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10918. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10919. //其他款项
  10920. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10921. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10922. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10923. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10924. .OrderBy((dop, sd1, sd2) => dop.Index)
  10925. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10926. {
  10927. ParentId = dop.ParentId,
  10928. SubId = dop.Id,
  10929. Index = dop.Index,
  10930. SetDataId = dop.SetDataId,
  10931. SetDataName = sd1.Name,
  10932. Cost = dop.Cost,
  10933. Currency = dop.Currency,
  10934. CurrencyName = sd2.Remark,
  10935. SubTotal = dop.SubTotal,
  10936. Remark = dop.Remark,
  10937. })
  10938. .ToArray();
  10939. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10940. return Ok(mobileInfo);
  10941. }
  10942. /// <summary>
  10943. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10944. /// </summary>
  10945. /// <returns></returns>
  10946. [HttpPost]
  10947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10948. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10949. {
  10950. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10951. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10952. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10953. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10954. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10955. //验证查看编辑权限
  10956. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10957. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10958. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10959. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10960. var subType = dto.SubType;
  10961. if (subType == 1) //1:境内费用
  10962. {
  10963. var oneData = new ChoiceOneMobileSubInfoView()
  10964. {
  10965. Id = eecInfo.Id,
  10966. ChoiceOne = eecInfo.ChoiceOne,
  10967. ChoiceOneTotalCost = eecInfo.InsidePay,
  10968. Visa = eecInfo.Visa,
  10969. VisaRemark = eecInfo.VisaRemark,
  10970. YiMiao = eecInfo.YiMiao,
  10971. HeSuan = eecInfo.HeSuan,
  10972. Service = eecInfo.Service,
  10973. Ticket = eecInfo.Ticket,
  10974. Safe = eecInfo.Safe,
  10975. FirstItemRemark = eecInfo.FirstItemRemark
  10976. };
  10977. return Ok(JsonView(oneData));
  10978. }
  10979. else if (subType == 2) //2:国际旅费
  10980. {
  10981. var twoData = new ChoiceTwoMobileSubInfoView()
  10982. {
  10983. Id = eecInfo.Id,
  10984. ChoiceTwoJJ = eecInfo.SumJJC,
  10985. OutsideJJPay = eecInfo.OutsideJJPay,
  10986. ChoiceTwoGW = eecInfo.SumGWC,
  10987. OutsideGWPay = eecInfo.OutsideGWPay,
  10988. ChoiceTwoTD = eecInfo.SumTDC,
  10989. OutsideTDPay = eecInfo.OutsideTDPay,
  10990. AirJJ = eecInfo.AirJJ,
  10991. AirGW = eecInfo.AirGW,
  10992. AirTD = eecInfo.AirTD,
  10993. CityTranffic = eecInfo.CityTranffic,
  10994. TwoItemRemark = eecInfo.TwoItemRemark
  10995. };
  10996. return Ok(JsonView(twoData));
  10997. }
  10998. else if (subType == 3) //3:住宿费
  10999. {
  11000. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11001. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11002. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11003. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11004. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11005. {
  11006. ParentId = dac.ParentId,
  11007. SubId = dac.Id,
  11008. Type = dac.Type,
  11009. Days = dac.Days,
  11010. NationalTravelFeeId = dac.NationalTravelFeeId,
  11011. Arae = $"{ntf.Country}-{ntf.City}",
  11012. Cost = dac.Cost,
  11013. Currency = dac.Currency,
  11014. CurrencyName = sd.Name,
  11015. SubTotal = dac.SubTotal,
  11016. })
  11017. .ToArray();
  11018. var data = new ChoiceDraftMobileSubInfo3To6View()
  11019. {
  11020. ParentId = eecInfo.Id,
  11021. Choice = eecInfo.ChoiceThree,
  11022. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11023. Details = dayAndCostDatas
  11024. };
  11025. return Ok(JsonView(data));
  11026. }
  11027. else if (subType == 4) //4:伙食费
  11028. {
  11029. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11030. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11031. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11032. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  11033. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11034. {
  11035. ParentId = dac.ParentId,
  11036. SubId = dac.Id,
  11037. Type = dac.Type,
  11038. Days = dac.Days,
  11039. NationalTravelFeeId = dac.NationalTravelFeeId,
  11040. Arae = $"{ntf.Country}-{ntf.City}",
  11041. Cost = dac.Cost,
  11042. Currency = dac.Currency,
  11043. CurrencyName = sd.Name,
  11044. SubTotal = dac.SubTotal,
  11045. })
  11046. .ToArray();
  11047. var data = new ChoiceDraftMobileSubInfo3To6View()
  11048. {
  11049. ParentId = eecInfo.Id,
  11050. Choice = eecInfo.ChoiceFour,
  11051. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11052. Details = dayAndCostDatas
  11053. };
  11054. return Ok(JsonView(data));
  11055. }
  11056. else if (subType == 5) //5:公杂费
  11057. {
  11058. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11059. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11060. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11061. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  11062. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11063. {
  11064. ParentId = dac.ParentId,
  11065. SubId = dac.Id,
  11066. Type = dac.Type,
  11067. Days = dac.Days,
  11068. NationalTravelFeeId = dac.NationalTravelFeeId,
  11069. Arae = $"{ntf.Country}-{ntf.City}",
  11070. Cost = dac.Cost,
  11071. Currency = dac.Currency,
  11072. CurrencyName = sd.Name,
  11073. SubTotal = dac.SubTotal,
  11074. })
  11075. .ToArray();
  11076. var data = new ChoiceDraftMobileSubInfo3To6View()
  11077. {
  11078. ParentId = eecInfo.Id,
  11079. Choice = eecInfo.ChoiceFive,
  11080. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11081. Details = dayAndCostDatas
  11082. };
  11083. return Ok(JsonView(data));
  11084. }
  11085. else if (subType == 6) //6:培训费
  11086. {
  11087. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11088. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11089. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11090. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  11091. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11092. {
  11093. ParentId = dac.ParentId,
  11094. SubId = dac.Id,
  11095. Type = dac.Type,
  11096. Days = dac.Days,
  11097. NationalTravelFeeId = dac.NationalTravelFeeId,
  11098. Arae = $"{ntf.Country}-{ntf.City}",
  11099. Cost = dac.Cost,
  11100. Currency = dac.Currency,
  11101. CurrencyName = sd.Name,
  11102. SubTotal = dac.SubTotal,
  11103. })
  11104. .ToArray();
  11105. var data = new ChoiceDraftMobileSubInfo3To6View()
  11106. {
  11107. ParentId = eecInfo.Id,
  11108. Choice = eecInfo.ChoiceSix,
  11109. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11110. Details = dayAndCostDatas
  11111. };
  11112. return Ok(JsonView(data));
  11113. }
  11114. else if (subType == 7) //7:其他
  11115. {
  11116. //其他款项
  11117. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11118. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11119. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11120. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11121. .OrderBy((dop, sd1, sd2) => dop.Index)
  11122. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11123. {
  11124. ParentId = dop.ParentId,
  11125. SubId = dop.Id,
  11126. Index = dop.Index,
  11127. SetDataId = dop.SetDataId,
  11128. SetDataName = sd1.Name,
  11129. Cost = dop.Cost,
  11130. Currency = dop.Currency,
  11131. CurrencyName = sd2.Name,
  11132. SubTotal = dop.SubTotal,
  11133. Remark = dop.Remark,
  11134. })
  11135. .ToArray();
  11136. var data = new ChoiceSevenDraftMobileSubInfoView()
  11137. {
  11138. ParentId = eecInfo.Id,
  11139. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11140. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11141. Details = otherData
  11142. };
  11143. return Ok(JsonView(data));
  11144. }
  11145. return Ok(JsonView(false));
  11146. }
  11147. #region op
  11148. ///// <summary>
  11149. ///// 移动端更新费用消息通知
  11150. ///// </summary>
  11151. ///// <param name="draftId"></param>
  11152. ///// <param name="id"></param>
  11153. ///// <param name="currUserId"></param>
  11154. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11155. //{
  11156. // try
  11157. // {
  11158. // ////生成默认文件pdf并且通知人员
  11159. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11160. // //{
  11161. // // DiId = draftId,
  11162. // // ExportType = 1,
  11163. // // SubTypeId = 1005
  11164. // //}, "pdf");
  11165. // ////发送通知
  11166. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11167. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11168. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11169. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11170. // ////汇率信息记录
  11171. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11172. // }
  11173. // catch (Exception ex)
  11174. // {
  11175. // //记录日志
  11176. // throw;
  11177. // }
  11178. //}
  11179. /// <summary>
  11180. /// 验证出入境费用数据是否存在
  11181. /// 不存在添加
  11182. /// </summary>
  11183. /// <param name="draftId"></param>
  11184. /// <param name="currUserId"></param>
  11185. /// <returns></returns>
  11186. /// <exception cref="CustomException"></exception>
  11187. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11188. {
  11189. var parentId = 0;
  11190. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11191. if (info != null) parentId = info.Id;
  11192. else
  11193. {
  11194. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11195. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11196. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11197. parentId = addId;
  11198. }
  11199. return parentId;
  11200. }
  11201. /// <summary>
  11202. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11203. /// </summary>
  11204. /// <returns></returns>
  11205. [HttpPost]
  11206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11207. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11208. {
  11209. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11210. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11211. //验证查看权限
  11212. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11213. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11214. var userIds = await _sqlSugar
  11215. .Queryable<Grp_EnterExitCostDraftPermission>()
  11216. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11217. .Select(x => x.UserId)
  11218. .ToArrayAsync();
  11219. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11220. var perUsersView = new List<dynamic>();
  11221. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11222. var viewPermissionData = new List<PermissionViewUserview>();
  11223. if (feeBasePerm.Any())
  11224. {
  11225. foreach (var item in feeBasePerm)
  11226. {
  11227. if (item.Users.Any())
  11228. {
  11229. viewPermissionData.AddRange(item.Users);
  11230. }
  11231. }
  11232. }
  11233. foreach (var item in perUsers)
  11234. {
  11235. bool isView1 = false;
  11236. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11237. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11238. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11239. }
  11240. return Ok(JsonView(perUsersView));
  11241. }
  11242. /// <summary>
  11243. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11244. /// </summary>
  11245. /// <returns></returns>
  11246. [HttpPost]
  11247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11248. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11249. {
  11250. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11251. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11252. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11253. //验证查看编辑权限
  11254. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11255. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11256. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11257. foreach (var userId in dto.UserIds)
  11258. {
  11259. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11260. }
  11261. if (permissions.Any())
  11262. {
  11263. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11264. {
  11265. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11266. }
  11267. _sqlSugar.BeginTran();
  11268. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11269. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11270. if (result < 1)
  11271. {
  11272. _sqlSugar.RollbackTran();
  11273. return Ok(JsonView(false));
  11274. }
  11275. _sqlSugar.CommitTran();
  11276. return Ok(JsonView(true));
  11277. }
  11278. return Ok(JsonView(false));
  11279. }
  11280. /// <summary>
  11281. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11282. /// </summary>
  11283. /// <returns></returns>
  11284. [HttpPost]
  11285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11286. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11287. {
  11288. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11289. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11290. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11291. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11292. int id = dto.DraftId;
  11293. if (id <= 0) //add
  11294. {
  11295. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11296. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11297. if (add < 1) return Ok(JsonView(false));
  11298. id = add;
  11299. }
  11300. else //update
  11301. {
  11302. //验证查看编辑权限
  11303. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11304. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11305. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11306. if (upd < 1) return Ok(JsonView(false));
  11307. }
  11308. return Ok(JsonView(new { parentId = id }));
  11309. }
  11310. /// <summary>
  11311. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11312. /// </summary>
  11313. /// <returns></returns>
  11314. [HttpPost]
  11315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11316. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11317. {
  11318. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11319. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11320. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11321. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11322. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11323. int id = dto.DraftId;
  11324. if (id <= 0) //add
  11325. {
  11326. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11327. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11328. if (add < 1) return Ok(JsonView(false));
  11329. id = add;
  11330. }
  11331. else //update
  11332. {
  11333. //验证查看编辑权限
  11334. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11335. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11336. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11337. if (upd < 1) return Ok(JsonView(false));
  11338. }
  11339. #region 汇率变更时更改币种相关费用
  11340. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11341. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11342. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11343. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11344. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11345. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11346. .Select((dac, sd) => new
  11347. {
  11348. dac.Id,
  11349. dac.ParentId,
  11350. CurrencyCode = sd.Name,
  11351. dac.Cost
  11352. })
  11353. .ToList();
  11354. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11355. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11356. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11357. .Select((dop, sd) => new
  11358. {
  11359. dop.Id,
  11360. dop.ParentId,
  11361. CurrencyCode = sd.Name,
  11362. dop.Cost
  11363. })
  11364. .ToList();
  11365. if (dayCosts.Count > 0)
  11366. {
  11367. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11368. foreach (var dc in new_dayCosts)
  11369. {
  11370. var thisCurrency = dc.Key.ToUpper();
  11371. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11372. if (thisRate == 0.00M) continue;
  11373. foreach (var dcSub in dc)
  11374. {
  11375. opDayCosts.Add(new Grp_DayAndCostDraft()
  11376. {
  11377. Id = dcSub.Id,
  11378. ParentId = dcSub.ParentId,
  11379. Cost = dcSub.Cost,
  11380. SubTotal = dcSub.Cost * thisRate,
  11381. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11382. });
  11383. }
  11384. }
  11385. if (opDayCosts.Count > 0)
  11386. {
  11387. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11388. }
  11389. }
  11390. if (dayOtherCosts.Count > 0)
  11391. {
  11392. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11393. foreach (var dc in new_dayOtherCosts)
  11394. {
  11395. var thisCurrency = dc.Key.ToUpper();
  11396. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11397. if (thisRate == 0.00M) continue;
  11398. foreach (var dcSub in dc)
  11399. {
  11400. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11401. {
  11402. Id = dcSub.Id,
  11403. ParentId = dcSub.ParentId,
  11404. Cost = dcSub.Cost,
  11405. SubTotal = dcSub.Cost * thisRate,
  11406. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11407. });
  11408. }
  11409. }
  11410. if (opDayOtherCosts.Count > 0)
  11411. {
  11412. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11413. }
  11414. }
  11415. #endregion
  11416. ////消息通知
  11417. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11418. ////汇率信息记录
  11419. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11420. return Ok(JsonView(new { parentId = id }));
  11421. }
  11422. /// <summary>
  11423. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11424. /// </summary>
  11425. /// <returns></returns>
  11426. [HttpPost]
  11427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11428. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11429. {
  11430. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11431. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11432. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11433. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11434. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11435. int id = dto.DraftId;
  11436. if (id <= 0) //add
  11437. {
  11438. checkboxInfo.ProvinceId = dto.ProvinceId;
  11439. checkboxInfo.CreateUserId = dto.CurrUserId;
  11440. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11441. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11442. if (add < 1) return Ok(JsonView(false));
  11443. }
  11444. else //update
  11445. {
  11446. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11447. .UpdateColumns(x => new
  11448. {
  11449. x.ChoiceOne,
  11450. x.ChoiceTwo,
  11451. x.SumJJC,
  11452. x.SumGWC,
  11453. x.SumTDC,
  11454. x.ChoiceThree,
  11455. x.ChoiceFour,
  11456. x.ChoiceFive,
  11457. x.ChoiceSix,
  11458. x.OtherExpenses_Checked
  11459. })
  11460. .Where(x => x.Id == id)
  11461. .ExecuteCommandAsync();
  11462. if (upd < 1) return Ok(JsonView(false));
  11463. }
  11464. return Ok(JsonView(new { parentId = id }));
  11465. }
  11466. /// <summary>
  11467. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11468. /// </summary>
  11469. /// <returns></returns>
  11470. [HttpPost]
  11471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11472. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11473. {
  11474. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11475. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11476. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11477. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11478. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11479. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11480. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11481. var checkboxInfo = new Grp_EnterExitCostDraft()
  11482. {
  11483. Id = draftId,
  11484. ProvinceId = dto.ProvinceId,
  11485. CreateUserId = currUserId
  11486. };
  11487. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11488. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11489. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11490. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11491. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11492. if (draftId <= 0) //add
  11493. {
  11494. checkboxInfo.CreateUserId = dto.CurrUserId;
  11495. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11496. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11497. if (add < 1) return Ok(JsonView(false));
  11498. }
  11499. else //update
  11500. {
  11501. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11502. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11503. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11504. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11505. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11506. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11507. .Where(x => x.Id == draftId)
  11508. .ExecuteCommandAsync();
  11509. if (upd < 1) return Ok(JsonView(false));
  11510. }
  11511. return Ok(JsonView(new { parentId = draftId }));
  11512. }
  11513. /// <summary>
  11514. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11515. /// </summary>
  11516. /// <returns></returns>
  11517. [HttpPost]
  11518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11519. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11520. {
  11521. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11522. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11523. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11524. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11525. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11526. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11527. info.ProvinceId = dto.ProvinceId;
  11528. info.FirstItemRemark = dto.FirstItemRemark;
  11529. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11530. if (id <= 0) //add
  11531. {
  11532. info.CreateUserId = dto.CurrUserId;
  11533. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11534. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11535. if (add < 1) return Ok(JsonView(false));
  11536. id = add;
  11537. }
  11538. else //update
  11539. {
  11540. var upd = await _sqlSugar.Updateable(info)
  11541. .UpdateColumns(x => new
  11542. {
  11543. x.ChoiceOne,
  11544. x.InsidePay,
  11545. x.VisaRemark,
  11546. x.Visa,
  11547. x.Service,
  11548. x.Safe,
  11549. x.Ticket,
  11550. x.HeSuan,
  11551. x.YiMiao,
  11552. x.FirstItemRemark
  11553. })
  11554. .Where(x => x.Id == id)
  11555. .ExecuteCommandAsync();
  11556. if (upd < 1) return Ok(JsonView(false));
  11557. }
  11558. ////消息通知
  11559. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11560. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11561. }
  11562. /// <summary>
  11563. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11564. /// </summary>
  11565. /// <returns></returns>
  11566. [HttpPost]
  11567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11568. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11569. {
  11570. int id = dto.DraftId;
  11571. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11572. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11573. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11574. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11575. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11576. info.ProvinceId = dto.ProvinceId;
  11577. info.OutsideJJPay = dto.OutsideJJPay;
  11578. info.OutsideGWPay = dto.OutsideGWPay;
  11579. info.OutsideTDPay = dto.OutsideTDPay;
  11580. info.AirJJ = dto.AirJJ;
  11581. info.AirGW = dto.AirGW;
  11582. info.AirTD = dto.AirTD;
  11583. info.CityTranffic = dto.CityTranffic;
  11584. info.TwoItemRemark = dto.TwoItemRemark;
  11585. info.SumJJC = dto.ChoiceTwoJJ;
  11586. info.SumGWC = dto.ChoiceTwoGW;
  11587. info.SumTDC = dto.ChoiceTwoTD;
  11588. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11589. if (id <= 0) //add
  11590. {
  11591. info.CreateUserId = dto.CurrUserId;
  11592. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11593. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11594. if (addId <= 0) return Ok(JsonView(false));
  11595. id = addId;
  11596. }
  11597. else //update
  11598. {
  11599. var upd = await _sqlSugar.Updateable(info)
  11600. .UpdateColumns(x => new
  11601. {
  11602. x.SumJJC,
  11603. x.OutsideJJPay,
  11604. x.SumGWC,
  11605. x.OutsideGWPay,
  11606. x.SumTDC,
  11607. x.OutsideTDPay,
  11608. x.AirJJ,
  11609. x.AirGW,
  11610. x.AirTD,
  11611. x.CityTranffic,
  11612. x.TwoItemRemark
  11613. })
  11614. .Where(x => x.Id == id)
  11615. .ExecuteCommandAsync();
  11616. if (upd < 1) return Ok(JsonView(false));
  11617. }
  11618. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11619. gwcItemTotal = info.AirGW + info.CityTranffic;
  11620. tdcItemTotal = info.AirTD + info.CityTranffic;
  11621. ////消息通知
  11622. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11623. return Ok(JsonView(new
  11624. {
  11625. parentId = id,
  11626. choiceTwoJJ = dto.ChoiceTwoJJ,
  11627. jjcItemTotal = jjcItemTotal,
  11628. choiceTwoGW = dto.ChoiceTwoGW,
  11629. gwcItemTotal = gwcItemTotal,
  11630. choiceTwoTD = dto.ChoiceTwoTD,
  11631. tdcItemTotal = tdcItemTotal
  11632. }));
  11633. }
  11634. /// <summary>
  11635. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11636. /// </summary>
  11637. /// <returns></returns>
  11638. [HttpPost]
  11639. [ApiExplorerSettings(IgnoreApi = true)]
  11640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11641. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11642. {
  11643. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11644. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11645. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11646. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11647. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11648. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11649. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11650. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11651. {
  11652. Id = x.Id,
  11653. ParentId = dto.DraftId,
  11654. Type = dto.FeeType,
  11655. Days = x.Days,
  11656. NationalTravelFeeId = x.NationalTravelFeeId,
  11657. Cost = x.Cost,
  11658. Currency = x.Currency,
  11659. SubTotal = x.SubTotal,
  11660. CreateUserId = dto.CurrUserId
  11661. })
  11662. .ToList();
  11663. var adds = infos.Where(x => x.Id <= 0).ToList();
  11664. var upds = infos.Where(x => x.Id > 0).ToList();
  11665. if (adds.Count > 0)
  11666. {
  11667. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11668. if (add < 1) return Ok(JsonView(false));
  11669. }
  11670. if (upds.Count > 0)
  11671. {
  11672. var upd = await _sqlSugar.Updateable(adds)
  11673. .UpdateColumns(x => new
  11674. {
  11675. x.Days,
  11676. x.NationalTravelFeeId,
  11677. x.Cost,
  11678. x.Currency,
  11679. x.SubTotal
  11680. })
  11681. .WhereColumns(x => new { x.Id })
  11682. .ExecuteCommandAsync();
  11683. if (upd < 1) return Ok(JsonView(false));
  11684. }
  11685. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11686. ////消息通知
  11687. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11688. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11689. return Ok(JsonView(new { itemTotal = itemTotal }));
  11690. }
  11691. /// <summary>
  11692. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11693. /// </summary>
  11694. /// <returns></returns>
  11695. [HttpPost]
  11696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11697. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11698. {
  11699. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11700. int subId = dto.SubId, feeType = dto.FeeType;
  11701. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11702. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11703. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11704. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11705. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11706. subInfo.Id = subId;
  11707. subInfo.ParentId = dto.DraftId;
  11708. if (feeType == 3) subInfo.Type = 1;
  11709. else if (feeType == 4) subInfo.Type = 2;
  11710. else if (feeType == 5) subInfo.Type = 3;
  11711. else if (feeType == 6) subInfo.Type = 4;
  11712. subInfo.CreateUserId = dto.CurrUserId;
  11713. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11714. if (parentId < 1) return Ok(JsonView(false));
  11715. //子表op
  11716. if (subId < 1)
  11717. {
  11718. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11719. if (subAdd < 1) return Ok(JsonView(false));
  11720. }
  11721. else
  11722. {
  11723. var subUpd = await _sqlSugar.Updateable(subInfo)
  11724. .UpdateColumns(x => new
  11725. {
  11726. x.Days,
  11727. x.NationalTravelFeeId,
  11728. x.Cost,
  11729. x.Currency,
  11730. x.SubTotal
  11731. })
  11732. .WhereColumns(x => new { x.Id })
  11733. .ExecuteCommandAsync();
  11734. if (subUpd < 1) return Ok(JsonView(false));
  11735. }
  11736. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11737. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11738. }
  11739. /// <summary>
  11740. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11741. /// </summary>
  11742. /// <returns></returns>
  11743. [HttpPost]
  11744. [ApiExplorerSettings(IgnoreApi = true)]
  11745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11746. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11747. {
  11748. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11749. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11750. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11751. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11752. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11753. {
  11754. Id = x.Id,
  11755. ParentId = dto.DraftId,
  11756. SetDataId = x.SetDataId,
  11757. Index = x.Index,
  11758. Cost = x.Cost,
  11759. Currency = x.Currency,
  11760. SubTotal = x.SubTotal,
  11761. CreateUserId = dto.CurrUserId,
  11762. Remark = x.Remark
  11763. }).ToList();
  11764. var adds = infos.Where(x => x.Id <= 0).ToList();
  11765. var upds = infos.Where(x => x.Id > 0).ToList();
  11766. if (adds.Count > 0)
  11767. {
  11768. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11769. if (add < 1) return Ok(JsonView(false));
  11770. }
  11771. if (upds.Count > 0)
  11772. {
  11773. var upd = await _sqlSugar.Updateable(adds)
  11774. .UpdateColumns(x => new
  11775. {
  11776. x.Index,
  11777. x.SetDataId,
  11778. x.Cost,
  11779. x.Currency,
  11780. x.SubTotal,
  11781. x.Remark
  11782. })
  11783. .WhereColumns(x => new { x.Id })
  11784. .ExecuteCommandAsync();
  11785. if (upd < 1) return Ok(JsonView(false));
  11786. }
  11787. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11788. //消息通知
  11789. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11790. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11791. return Ok(JsonView(new { itemTotal = itemTotal }));
  11792. }
  11793. /// <summary>
  11794. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11795. /// </summary>
  11796. /// <returns></returns>
  11797. [HttpPost]
  11798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11799. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11800. {
  11801. int subId = dto.SubId, id = dto.DraftId;
  11802. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11803. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11804. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11805. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11806. subInfo.Id = subId;
  11807. subInfo.ParentId = id;
  11808. subInfo.CreateUserId = dto.CurrUserId;
  11809. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11810. if (parentId < 1) return Ok(JsonView(false));
  11811. #region 子表op
  11812. if (subId < 1)//add
  11813. {
  11814. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11815. if (subAdd < 1) return Ok(JsonView(false));
  11816. }
  11817. else //upd
  11818. {
  11819. var subUpd = await _sqlSugar.Updateable(subInfo)
  11820. .UpdateColumns(x => new
  11821. {
  11822. x.Index,
  11823. x.SetDataId,
  11824. x.Cost,
  11825. x.Currency,
  11826. x.SubTotal,
  11827. x.Remark
  11828. })
  11829. .WhereColumns(x => new { x.Id })
  11830. .ExecuteCommandAsync();
  11831. if (subUpd < 1) return Ok(JsonView(false));
  11832. }
  11833. #endregion
  11834. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11835. ////消息通知
  11836. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11837. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11838. }
  11839. /// <summary>
  11840. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11841. /// </summary>
  11842. /// <returns></returns>
  11843. [HttpPost]
  11844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11845. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11846. {
  11847. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11848. if (data.Code != 0)
  11849. {
  11850. return Ok(JsonView(false, data.Msg));
  11851. }
  11852. return Ok(JsonView(true, "操作成功!", data.Data));
  11853. }
  11854. /// <summary>
  11855. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11856. /// </summary>
  11857. /// <param name="dto"></param>
  11858. /// <returns></returns>
  11859. [HttpPost]
  11860. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11861. {
  11862. var data = new Grp_DayOtherPriceDraft()
  11863. {
  11864. Id = dto.Id,
  11865. IsDel = 1,
  11866. DeleteUserId = dto.DeleteUserId,
  11867. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11868. };
  11869. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11870. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11871. return Ok(JsonView(false, "删除失败!"));
  11872. }
  11873. #endregion
  11874. #endregion
  11875. #region 团组经理模块 出入境费用报价表
  11876. /// <summary>
  11877. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11878. /// </summary>
  11879. /// <returns></returns>
  11880. [HttpPost]
  11881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11882. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11883. {
  11884. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11885. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11886. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11887. initRates.Insert(0, cnyInfo);
  11888. liveRates.Insert(0, cnyInfo);
  11889. return Ok(JsonView(true, "查询成功!", new
  11890. {
  11891. InitRates = initRates,
  11892. LiveRates = liveRates
  11893. }));
  11894. }
  11895. /// <summary>
  11896. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11897. /// </summary>
  11898. /// <returns></returns>
  11899. [HttpPost]
  11900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11901. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11902. {
  11903. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11904. }
  11905. /// <summary>
  11906. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11907. /// </summary>
  11908. /// <returns></returns>
  11909. [HttpPost]
  11910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11911. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11912. {
  11913. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11914. }
  11915. /// <summary>
  11916. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11917. /// </summary>
  11918. /// <returns></returns>
  11919. [HttpPost]
  11920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11921. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11922. {
  11923. int groupId = dto.DiId,
  11924. currUserId = dto.CurrUserId;
  11925. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11926. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11927. //验证报价数据是否存在
  11928. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11929. if (isNull != null)
  11930. {
  11931. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11932. if (!info1.Rates.Any())
  11933. {
  11934. var rates = await GeneralMethod.EnterExitCostInitRate();
  11935. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11936. info1.Rates = rates.ToArray();
  11937. }
  11938. return Ok(JsonView(info1));
  11939. }
  11940. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11941. result.GroupId = groupId;
  11942. //处理报价名称
  11943. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11944. if (groupInfo != null)
  11945. {
  11946. var visitCountry = groupInfo.VisitCountry;
  11947. if (!string.IsNullOrEmpty(visitCountry))
  11948. {
  11949. string quoteName = string.Empty;
  11950. if (visitCountry.Contains("|"))
  11951. {
  11952. var countrys = visitCountry.Split("|");
  11953. quoteName = string.Join("、", countrys);
  11954. }
  11955. else quoteName = visitCountry;
  11956. quoteName += $"团组报价表";
  11957. result.Name = quoteName;
  11958. }
  11959. }
  11960. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11961. if (info.Code != StatusCodes.Status200OK)
  11962. {
  11963. if (!result.Rates.Any())
  11964. {
  11965. var rates = await GeneralMethod.EnterExitCostInitRate();
  11966. result.Rates = rates.ToArray();
  11967. }
  11968. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11969. }
  11970. var infoView = info.Data as EnterExitCostInfoView;
  11971. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11972. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11973. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11974. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11975. var eecRates = infoView.Currencys;
  11976. //默认添加人名币
  11977. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  11978. {
  11979. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11980. }
  11981. //处理团组人数
  11982. int pplNum = 1;
  11983. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11984. var views = new List<QuoteSubItemInfo>();
  11985. #region 数据填充
  11986. var intTravelCosts = new List<QuoteSubItemInfo>();
  11987. #region 机票费用 1354
  11988. int intTravelIndex = 1;
  11989. if (infoView.SumJJC == 1)
  11990. {
  11991. intTravelCosts.Add(new QuoteSubItemInfo
  11992. {
  11993. ItemId = 1354,
  11994. Index = intTravelIndex,
  11995. FeeName = "经济舱",
  11996. UnitPrice = infoView.AirJJ,
  11997. Currency = "CNY",
  11998. Quantity = 1,
  11999. PplNum = 1,
  12000. TotalAmt = infoView.AirJJ,
  12001. Remark = "",
  12002. });
  12003. intTravelIndex++;
  12004. }
  12005. if (infoView.SumGWC == 1)
  12006. {
  12007. intTravelCosts.Add(new QuoteSubItemInfo
  12008. {
  12009. ItemId = 1354,
  12010. Index = intTravelIndex,
  12011. FeeName = "公务舱",
  12012. UnitPrice = infoView.AirGW,
  12013. Currency = "CNY",
  12014. Quantity = 1,
  12015. PplNum = 1,
  12016. TotalAmt = infoView.AirGW,
  12017. Remark = "",
  12018. });
  12019. intTravelIndex++;
  12020. }
  12021. if (infoView.SumTDC == 1)
  12022. {
  12023. intTravelCosts.Add(new QuoteSubItemInfo
  12024. {
  12025. ItemId = 1354,
  12026. Index = intTravelIndex,
  12027. FeeName = "头等舱",
  12028. UnitPrice = infoView.AirTD,
  12029. Currency = "CNY",
  12030. Quantity = 1,
  12031. PplNum = 1,
  12032. TotalAmt = infoView.AirTD,
  12033. Remark = "",
  12034. });
  12035. intTravelIndex++;
  12036. }
  12037. intTravelCosts.Add(new QuoteSubItemInfo
  12038. {
  12039. ItemId = 1354,
  12040. Index = intTravelIndex,
  12041. FeeName = "城市间交通费用",
  12042. UnitPrice = infoView.CityTranffic,
  12043. Currency = "CNY",
  12044. Quantity = 1,
  12045. PplNum = pplNum,
  12046. TotalAmt = infoView.CityTranffic * pplNum,
  12047. Remark = "",
  12048. });
  12049. views.AddRange(intTravelCosts);
  12050. #endregion
  12051. var accomCosts = new List<QuoteSubItemInfo>();
  12052. #region 住宿费 1355
  12053. if (infoView.QuarterageData.Any())
  12054. {
  12055. int accomIndex = 1;
  12056. int accomItemTypeId = 1355;
  12057. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  12058. foreach (var item in groupData)
  12059. {
  12060. string feeName = string.Empty;
  12061. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12062. if (countryInfo != null)
  12063. {
  12064. feeName = countryInfo.Country;
  12065. var city = countryInfo.City;
  12066. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12067. {
  12068. feeName += $"-{city}";
  12069. }
  12070. }
  12071. var hotelInfo = item.FirstOrDefault();
  12072. if (hotelInfo == null) continue;
  12073. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  12074. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12075. int quantity = item.ToList().Count;
  12076. accomCosts.Add(new QuoteSubItemInfo
  12077. {
  12078. ItemId = accomItemTypeId,
  12079. Index = accomIndex,
  12080. FeeName = feeName,
  12081. UnitPrice = hotelInfo.Cost,
  12082. Currency = thisCurrency,
  12083. Quantity = quantity,
  12084. PplNum = pplNum,
  12085. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  12086. Remark = "",
  12087. });
  12088. accomIndex++;
  12089. }
  12090. views.AddRange(accomCosts);
  12091. }
  12092. #endregion
  12093. var mealCosts = new List<QuoteSubItemInfo>();
  12094. #region 餐饮费 1356
  12095. if (infoView.BoardWagesData.Any())
  12096. {
  12097. var mealIndex = 1;
  12098. int mealItemTypeId = 1356;
  12099. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12100. foreach (var item in groupData)
  12101. {
  12102. string feeName = string.Empty;
  12103. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12104. if (countryInfo != null)
  12105. {
  12106. feeName = countryInfo.Country;
  12107. var city = countryInfo.City;
  12108. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12109. {
  12110. feeName += $"-{city}";
  12111. }
  12112. }
  12113. var mealInfo = item.FirstOrDefault();
  12114. if (mealInfo == null) continue;
  12115. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12116. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12117. int quantity = item.ToList().Count;
  12118. mealCosts.Add(new QuoteSubItemInfo
  12119. {
  12120. ItemId = mealItemTypeId,
  12121. Index = mealIndex,
  12122. FeeName = feeName,
  12123. UnitPrice = mealInfo.Cost,
  12124. Currency = thisCurrency,
  12125. Quantity = quantity,
  12126. PplNum = pplNum,
  12127. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12128. Remark = "",
  12129. });
  12130. mealIndex++;
  12131. }
  12132. views.AddRange(mealCosts);
  12133. }
  12134. #endregion
  12135. var miscCosts = new List<QuoteSubItemInfo>();
  12136. #region 公杂费 1364
  12137. if (infoView.MiscellaneousFeeData.Any())
  12138. {
  12139. var miscIndex = 1;
  12140. int miscItemTypeId = 1364;
  12141. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12142. foreach (var item in groupData)
  12143. {
  12144. string feeName = string.Empty;
  12145. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12146. if (countryInfo != null)
  12147. {
  12148. feeName = countryInfo.Country;
  12149. var city = countryInfo.City;
  12150. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12151. {
  12152. feeName += $"-{city}";
  12153. }
  12154. }
  12155. var miscInfo = item.FirstOrDefault();
  12156. if (miscInfo == null) continue;
  12157. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12158. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12159. int quantity = item.ToList().Count;
  12160. miscCosts.Add(new QuoteSubItemInfo
  12161. {
  12162. ItemId = miscItemTypeId,
  12163. Index = miscIndex,
  12164. FeeName = feeName,
  12165. UnitPrice = miscInfo.Cost,
  12166. Currency = thisCurrency,
  12167. Quantity = quantity,
  12168. PplNum = pplNum,
  12169. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12170. Remark = "",
  12171. });
  12172. miscIndex++;
  12173. }
  12174. views.AddRange(miscCosts);
  12175. }
  12176. #endregion
  12177. #region 签证+保险 1362
  12178. int visaInsIndex = 1;
  12179. int visaInsItemTypeId = 1362;
  12180. if (infoView.Visa > 0)
  12181. {
  12182. views.Add(new QuoteSubItemInfo()
  12183. {
  12184. ItemId = visaInsItemTypeId,
  12185. Index = visaInsIndex,
  12186. FeeName = $"签证",
  12187. UnitPrice = infoView.Visa,
  12188. Currency = $"CNY",
  12189. Quantity = 1,
  12190. PplNum = pplNum,
  12191. TotalAmt = infoView.Visa * pplNum,
  12192. Remark = "",
  12193. });
  12194. visaInsIndex++;
  12195. }
  12196. if (infoView.Safe > 0)
  12197. {
  12198. views.Add(new QuoteSubItemInfo()
  12199. {
  12200. ItemId = visaInsItemTypeId,
  12201. Index = visaInsIndex,
  12202. FeeName = $"保险",
  12203. UnitPrice = infoView.Safe,
  12204. Currency = $"CNY",
  12205. Quantity = 1,
  12206. PplNum = pplNum,
  12207. TotalAmt = infoView.Safe * pplNum,
  12208. Remark = "",
  12209. });
  12210. }
  12211. #endregion
  12212. #region 服务费 1363
  12213. int serviceFeeIndex = 1;
  12214. int serviceFeeItemTypeId = 1363;
  12215. if (infoView.Service > 0)
  12216. {
  12217. views.Add(new QuoteSubItemInfo()
  12218. {
  12219. ItemId = serviceFeeItemTypeId,
  12220. Index = serviceFeeIndex,
  12221. FeeName = $"服务费",
  12222. UnitPrice = infoView.Service,
  12223. Currency = $"CNY",
  12224. Quantity = 1,
  12225. PplNum = pplNum,
  12226. TotalAmt = infoView.Service * pplNum,
  12227. Remark = "",
  12228. });
  12229. }
  12230. #endregion
  12231. #endregion
  12232. if (result.FeeItems.Any())
  12233. {
  12234. result.FeeItems.Select(x =>
  12235. {
  12236. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12237. if (feeInfos.Any()) x.Infos = feeInfos;
  12238. return x;
  12239. }
  12240. ).OrderBy(x => x.Index)
  12241. .ToList();
  12242. if (!result.Rates.Any())
  12243. {
  12244. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12245. else
  12246. {
  12247. var rates = await GeneralMethod.EnterExitCostInitRate();
  12248. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12249. result.Rates = rates.ToArray();
  12250. }
  12251. }
  12252. }
  12253. return Ok(JsonView(result));
  12254. }
  12255. /// <summary>
  12256. /// 团组模块 - 出入境费用报价表 - Info
  12257. /// </summary>
  12258. /// <returns></returns>
  12259. [HttpPost]
  12260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12261. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12262. {
  12263. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12264. if (!info.Rates.Any())
  12265. {
  12266. var rates = await GeneralMethod.EnterExitCostInitRate();
  12267. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12268. info.Rates = rates.ToArray();
  12269. }
  12270. return Ok(JsonView(info));
  12271. }
  12272. /// <summary>
  12273. /// 团组模块 - 出入境费用报价表 - OP
  12274. /// </summary>
  12275. /// <returns></returns>
  12276. [HttpPost]
  12277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12278. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12279. {
  12280. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12281. }
  12282. /// <summary>
  12283. /// 团组模块 - 出入境费用报价表 - 删除 项
  12284. /// </summary>
  12285. /// <returns></returns>
  12286. [HttpPost]
  12287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12288. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12289. {
  12290. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12291. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12292. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12293. }
  12294. /// <summary>
  12295. /// 团组模块 - 出入境费用报价表 - 导出
  12296. /// </summary>
  12297. /// <returns></returns>
  12298. [HttpPost]
  12299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12300. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12301. {
  12302. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12303. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12304. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12305. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12306. var rates = info.Rates;
  12307. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12308. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12309. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12310. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12311. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12312. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12313. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12314. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12315. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12316. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12317. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12318. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12319. //获取模板
  12320. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12321. var designer = new WorkbookDesigner();
  12322. designer.Workbook = new Workbook(tempPath);
  12323. designer.SetDataSource("QuoteName", info.Name);
  12324. designer.SetDataSource("CompanyTitle", "公司名称");
  12325. designer.SetDataSource("CompanyLabel", "");
  12326. #region 国际旅费
  12327. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12328. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12329. {
  12330. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12331. var label = new StringBuilder();
  12332. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12333. if (infos.Any())
  12334. {
  12335. label.Append(infos.Sum(x => x.PplNum));
  12336. label.Append("人全程机票:");
  12337. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12338. label.AppendLine("元");
  12339. }
  12340. foreach (var item in intTravelCosts.Infos)
  12341. {
  12342. label.Append(item.FeeName);
  12343. label.Append(":");
  12344. label.Append(item.UnitPrice.TruncDecimals(2));
  12345. label.Append("元/人*");
  12346. label.Append(item.PplNum);
  12347. label.AppendLine("人");
  12348. }
  12349. if (label.HasValue())
  12350. {
  12351. label.Append("\r\n以上小计:");
  12352. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12353. label.Append("元");
  12354. }
  12355. designer.SetDataSource("IntTravelLabel", label.ToString());
  12356. }
  12357. #endregion
  12358. #region 住宿费
  12359. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12360. if (accomCosts != null && accomCosts.Infos.Any())
  12361. {
  12362. string currencyName = string.Empty,
  12363. countryName = string.Empty;
  12364. decimal rate = 1.0000M;
  12365. var label = new StringBuilder();
  12366. label.AppendLine("全程五星酒店,每人1间房");
  12367. foreach (var item in accomCosts.Infos)
  12368. {
  12369. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12370. string name = string.Empty, thisCountryName = string.Empty;
  12371. if (item.FeeName.Contains('-'))
  12372. {
  12373. var feeName = item.FeeName.Split('-');
  12374. thisCountryName = feeName[0];
  12375. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12376. name = feeName[1];
  12377. }
  12378. else name = item.FeeName;
  12379. string thisFeeName = string.Empty;
  12380. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12381. else thisFeeName = $"\r\n{name}:";
  12382. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12383. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12384. rate = rateInfo?.Rate ?? 1.0000M;
  12385. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12386. label.AppendLine(subLabel);
  12387. }
  12388. if (label.HasValue())
  12389. {
  12390. //以上小计:52440元(美金汇率:7.5 )
  12391. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12392. label.AppendLine(subLabel);
  12393. }
  12394. designer.SetDataSource("AccomLabel", label.ToString());
  12395. }
  12396. #endregion
  12397. #region 餐饮费
  12398. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12399. if (mealCosts != null && mealCosts.Infos.Any())
  12400. {
  12401. string currencyName = string.Empty;
  12402. decimal rate = 1.0000M;
  12403. var label = new StringBuilder();
  12404. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12405. foreach (var item in mealCosts.Infos)
  12406. {
  12407. string name = string.Empty;
  12408. if (item.FeeName.Contains('-'))
  12409. {
  12410. var feeName = item.FeeName.Split('-');
  12411. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12412. }
  12413. else name = $"\r\n{item.FeeName}:";
  12414. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12415. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12416. rate = rateInfo?.Rate ?? 1.0000M;
  12417. label.Append(name);
  12418. label.Append(item.UnitPrice.TruncDecimals(2));
  12419. label.Append(currencyName);
  12420. label.Append("/天*");
  12421. label.Append(item.Quantity.ToString("#0"));
  12422. label.Append('*');
  12423. label.Append(item.PplNum);
  12424. label.Append("人\r\n");
  12425. }
  12426. if (label.HasValue())
  12427. {
  12428. label.Append("\r\n以上小计:");
  12429. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12430. label.Append("元\r\n(");
  12431. label.Append("汇率:");
  12432. label.Append(rate.TruncDecimals(4));
  12433. label.Append(')');
  12434. }
  12435. designer.SetDataSource("MealLabel", label.ToString());
  12436. }
  12437. #endregion
  12438. #region 车辆安排
  12439. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12440. if (vehArranges != null && vehArranges.Infos.Any())
  12441. {
  12442. string currencyName = string.Empty;
  12443. //decimal rate = 1.0000M;
  12444. var label = new StringBuilder();
  12445. foreach (var item in vehArranges.Infos)
  12446. {
  12447. label.AppendLine();
  12448. label.AppendLine();
  12449. label.Append(item.FeeName);
  12450. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12451. }
  12452. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12453. }
  12454. #endregion
  12455. #region 邀请函发放对象
  12456. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12457. designer.SetDataSource("InviteToContent", "");
  12458. #endregion
  12459. #region 邀请函费
  12460. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12461. var is_label = new StringBuilder();
  12462. if (inviteCosts != null && inviteCosts.Infos.Any())
  12463. {
  12464. string currencyName = string.Empty;
  12465. decimal rate = 1.0000M;
  12466. foreach (var item in inviteCosts.Infos)
  12467. {
  12468. //乌兹别克斯坦:2000美金
  12469. currencyName = item.Currency;
  12470. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12471. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12472. is_label.AppendLine(label);
  12473. }
  12474. if (is_label.HasValue())
  12475. {
  12476. //以上小计:28500元(美金汇率:7.5)
  12477. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12478. is_label.AppendLine(label);
  12479. }
  12480. }
  12481. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12482. #endregion
  12483. #region 邀请函发放时间
  12484. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12485. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12486. #endregion
  12487. #region 公务活动(含翻译)
  12488. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12489. var oa_label = new StringBuilder();
  12490. if (officialActs != null && officialActs.Infos.Any())
  12491. {
  12492. string currencyName = string.Empty;
  12493. decimal rate = 1.0000M;
  12494. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12495. foreach (var item in officialActs.Infos)
  12496. {
  12497. //乌兹别克斯坦:1000美金/场
  12498. currencyName = item.Currency;
  12499. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12500. string label_remark = string.Empty;
  12501. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12502. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12503. }
  12504. label_content += "*总费用中未含超出公务活动价格";
  12505. //8场公务活动(以上小计:60000元)
  12506. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12507. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12508. oa_label.AppendLine(label_title);
  12509. oa_label.AppendLine(label_content);
  12510. }
  12511. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12512. #endregion
  12513. #region 签证+保险
  12514. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12515. var vi_label = new StringBuilder();
  12516. if (visaIns != null && visaIns.Infos.Any())
  12517. {
  12518. foreach (var item in visaIns.Infos)
  12519. {
  12520. //签证:500元/人
  12521. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12522. vi_label.AppendLine(label);
  12523. }
  12524. if (vi_label.HasValue())
  12525. {
  12526. //以上小计:6000元
  12527. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12528. vi_label.AppendLine(label);
  12529. }
  12530. }
  12531. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12532. #endregion
  12533. #region 服务费
  12534. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12535. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12536. #endregion
  12537. #region 公杂费
  12538. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12539. var pm_label = new StringBuilder();
  12540. if (pubMiscs != null && pubMiscs.Infos.Any())
  12541. {
  12542. string currencyName = string.Empty,
  12543. countryName = string.Empty;
  12544. decimal rate = 1.0000M;
  12545. foreach (var item in pubMiscs.Infos)
  12546. {
  12547. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12548. string name = string.Empty, thisCountryName = string.Empty;
  12549. if (item.FeeName.Contains('-'))
  12550. {
  12551. var feeName = item.FeeName.Split('-');
  12552. thisCountryName = feeName[0];
  12553. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12554. name = feeName[1];
  12555. }
  12556. else name = item.FeeName;
  12557. string thisFeeName = string.Empty;
  12558. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12559. else thisFeeName = $"\r\n{name}:";
  12560. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12561. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12562. rate = rateInfo?.Rate ?? 1.0000M;
  12563. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12564. pm_label.AppendLine(label);
  12565. }
  12566. if (pm_label.HasValue())
  12567. {
  12568. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12569. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12570. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12571. pm_label.AppendLine(string.Format("部分发放成员"));
  12572. }
  12573. }
  12574. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12575. #endregion
  12576. #region 税费
  12577. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12578. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12579. #endregion
  12580. #region 合计(单位:元)
  12581. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12582. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12583. #endregion
  12584. #region 汇率 Remark
  12585. var rate_label = new StringBuilder();
  12586. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12587. foreach (var item in rateGroups)
  12588. {
  12589. //美元汇率按\r\n1:7.5
  12590. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12591. rate_label.AppendLine(label);
  12592. }
  12593. designer.SetDataSource("RateLabel", rate_label.ToString());
  12594. #endregion
  12595. designer.Process();
  12596. //文件名
  12597. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12598. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12599. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12600. return Ok(JsonView(true, "成功", url));
  12601. }
  12602. #endregion
  12603. #region 签证费用录入
  12604. /// <summary>
  12605. /// 根据diid查询签证费用列表
  12606. /// </summary>
  12607. /// <param name="dto"></param>
  12608. /// <returns></returns>
  12609. [HttpPost]
  12610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12611. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12612. {
  12613. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12614. if (groupData.Code != 0)
  12615. {
  12616. return Ok(JsonView(false, groupData.Msg));
  12617. }
  12618. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12619. }
  12620. /// <summary>
  12621. /// 根据签证费用Id查询单条数据及c表数据
  12622. /// </summary>
  12623. /// <param name="dto"></param>
  12624. /// <returns></returns>
  12625. [HttpPost]
  12626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12627. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12628. {
  12629. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12630. if (groupData.Code != 0)
  12631. {
  12632. return Ok(JsonView(false, groupData.Msg));
  12633. }
  12634. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12635. }
  12636. /// <summary>
  12637. /// 签证费用删除
  12638. /// </summary>
  12639. /// <param name="dto"></param>
  12640. /// <returns></returns>
  12641. [HttpPost]
  12642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12643. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12644. {
  12645. _sqlSugar.BeginTran();
  12646. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12647. if (!res)
  12648. {
  12649. _sqlSugar.RollbackTran();
  12650. return Ok(JsonView(false, "删除失败"));
  12651. }
  12652. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12653. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12654. .SetColumns(a => new Grp_CreditCardPayment()
  12655. {
  12656. IsDel = 1,
  12657. DeleteUserId = dto.DeleteUserId,
  12658. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12659. })
  12660. .ExecuteCommand();
  12661. if (resSub < 1)
  12662. {
  12663. _sqlSugar.RollbackTran();
  12664. return Ok(JsonView(false, "删除失败"));
  12665. }
  12666. _sqlSugar.CommitTran();
  12667. return Ok(JsonView(true, "删除成功!"));
  12668. }
  12669. /// <summary>
  12670. /// 签证费用录入下拉框初始化
  12671. /// </summary>
  12672. /// <returns></returns>
  12673. [HttpPost]
  12674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12675. public async Task<IActionResult> VisaPriceAddSelect()
  12676. {
  12677. //支付方式
  12678. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12679. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12680. //币种
  12681. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12682. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12683. //乘客类型
  12684. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12685. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12686. //卡类型
  12687. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12688. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12689. //代办费类型
  12690. var agencyFeeTypeData = new List<dynamic>() {
  12691. new { id = 0 , Text = "未选择" },
  12692. new { id = 1 , Text = "小公务" },
  12693. new { id = 2 , Text = "大公务" },
  12694. };
  12695. //签证费用标准国家Data
  12696. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12697. var data = new
  12698. {
  12699. Payment = _Payment,
  12700. CurrencyList = _CurrencyList,
  12701. PassengerType = _PassengerType,
  12702. BankCard = _BankCard,
  12703. AgencyFeeType = agencyFeeTypeData,
  12704. CountryFeeData = visaCountryFeeData
  12705. };
  12706. return Ok(JsonView(true, "查询成功!", data));
  12707. }
  12708. /// <summary>
  12709. /// 签证费用录入操作(Status:1.新增,2.修改)
  12710. /// </summary>
  12711. /// <param name="dto"></param>
  12712. /// <returns></returns>
  12713. [HttpPost]
  12714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12715. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12716. {
  12717. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12718. if (groupData.Code != 0)
  12719. {
  12720. return Ok(JsonView(false, groupData.Msg));
  12721. }
  12722. #region 应用推送
  12723. try
  12724. {
  12725. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12726. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12727. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12728. //2024-10-21 新增LZ UID
  12729. var userIds = new List<int>() { 21 };
  12730. string title = $"系统通知";
  12731. string content = "";
  12732. var diId = dto.DiId;
  12733. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12734. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12735. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12736. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12737. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12738. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12739. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12740. }
  12741. catch (Exception ex)
  12742. {
  12743. }
  12744. #endregion
  12745. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12746. }
  12747. #endregion
  12748. #region 签证提成录入
  12749. /// <summary>
  12750. /// 签证提成录入
  12751. /// 基础数据
  12752. /// </summary>
  12753. /// <returns></returns>
  12754. [HttpGet]
  12755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12756. public async Task<IActionResult> VisaCommissionInit()
  12757. {
  12758. return Ok(await _visaCommissionRep.Init());
  12759. }
  12760. /// <summary>
  12761. /// 签证提成录入
  12762. /// Item
  12763. /// </summary>
  12764. /// <param name="_dto"></param>
  12765. /// <returns></returns>
  12766. [HttpPost]
  12767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12768. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12769. {
  12770. var validator = new VisaCommissionItemDtoValidator();
  12771. var validatorRes = await validator.ValidateAsync(_dto);
  12772. if (!validatorRes.IsValid)
  12773. {
  12774. var sb = new StringBuilder();
  12775. foreach (var item in validatorRes.Errors)
  12776. {
  12777. sb.AppendLine(item.ErrorMessage);
  12778. }
  12779. return Ok(JsonView(false, sb.ToString()));
  12780. }
  12781. return Ok(await _visaCommissionRep.Item(_dto));
  12782. }
  12783. /// <summary>
  12784. /// 签证提成录入
  12785. /// Save
  12786. /// </summary>
  12787. /// <param name="_dto"></param>
  12788. /// <returns></returns>
  12789. [HttpPost]
  12790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12791. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12792. {
  12793. //参数验证
  12794. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12795. foreach (var item in _dto.Items)
  12796. {
  12797. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12798. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12799. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12800. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12801. }
  12802. return Ok(await _visaCommissionRep.Save(_dto));
  12803. }
  12804. /// <summary>
  12805. /// 签证提成录入
  12806. /// Create
  12807. /// </summary>
  12808. /// <param name="_dto"></param>
  12809. /// <returns></returns>
  12810. [HttpPost]
  12811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12812. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12813. {
  12814. var validator = new VisaCommissionCreateDtoValidator();
  12815. var validatorRes = await validator.ValidateAsync(_dto);
  12816. if (!validatorRes.IsValid)
  12817. {
  12818. var sb = new StringBuilder();
  12819. foreach (var item in validatorRes.Errors)
  12820. {
  12821. sb.AppendLine(item.ErrorMessage);
  12822. }
  12823. return Ok(JsonView(false, sb.ToString()));
  12824. }
  12825. return Ok(await _visaCommissionRep.Create(_dto));
  12826. }
  12827. /// <summary>
  12828. /// 签证提成录入
  12829. /// Put(编辑)
  12830. /// </summary>
  12831. /// <param name="id"></param>
  12832. /// <param name="_dto"></param>
  12833. /// <returns></returns>
  12834. [HttpPut]
  12835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12836. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12837. {
  12838. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12839. var validator = new VisaCommissionCreateDtoValidator();
  12840. var validatorRes = await validator.ValidateAsync(_dto);
  12841. if (!validatorRes.IsValid)
  12842. {
  12843. var sb = new StringBuilder();
  12844. foreach (var item in validatorRes.Errors)
  12845. {
  12846. sb.AppendLine(item.ErrorMessage);
  12847. }
  12848. return Ok(JsonView(false, sb.ToString()));
  12849. }
  12850. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12851. }
  12852. /// <summary>
  12853. /// 签证提成录入
  12854. /// Del
  12855. /// </summary>
  12856. /// <param name="id"></param>
  12857. /// <param name="currUserId"></param>
  12858. /// <returns></returns>
  12859. [HttpPost]
  12860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12861. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12862. {
  12863. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12864. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12865. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12866. }
  12867. #endregion
  12868. #region op费用录入
  12869. /// <summary>
  12870. /// 根据diid查询op费用列表
  12871. /// </summary>
  12872. /// <param name="dto"></param>
  12873. /// <returns></returns>
  12874. [HttpPost]
  12875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12876. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12877. {
  12878. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12879. if (groupData.Code != 0)
  12880. {
  12881. return Ok(JsonView(false, groupData.Msg));
  12882. }
  12883. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12884. }
  12885. /// <summary>
  12886. /// 根据op费用Id查询单条数据及c表数据
  12887. /// </summary>
  12888. /// <param name="dto"></param>
  12889. /// <returns></returns>
  12890. [HttpPost]
  12891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12892. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12893. {
  12894. try
  12895. {
  12896. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12897. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12898. var data = new
  12899. {
  12900. CarTouristGuideGround = _groupData,
  12901. CreditCardPayment = _creditCardPayment
  12902. };
  12903. return Ok(JsonView(true, "查询成功!", data));
  12904. }
  12905. catch (Exception ex)
  12906. {
  12907. return Ok(JsonView(false, "程序错误!"));
  12908. }
  12909. }
  12910. /// <summary>
  12911. /// op费用删除
  12912. /// </summary>
  12913. /// <param name="dto"></param>
  12914. /// <returns></returns>
  12915. [HttpPost]
  12916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12917. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12918. {
  12919. try
  12920. {
  12921. _sqlSugar.BeginTran();
  12922. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12923. if (!res)
  12924. {
  12925. return Ok(JsonView(false, "删除失败"));
  12926. }
  12927. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12928. {
  12929. IsDel = 1,
  12930. DeleteUserId = dto.DeleteUserId,
  12931. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12932. }).ExecuteCommandAsync();
  12933. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12934. {
  12935. IsDel = 1,
  12936. DeleteUserId = dto.DeleteUserId,
  12937. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12938. }).ExecuteCommandAsync();
  12939. #region 删除超支相关数据
  12940. //删除导入的超支数据
  12941. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12942. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12943. {
  12944. IsDel = 1,
  12945. DeleteUserId = dto.DeleteUserId,
  12946. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12947. }).ExecuteCommand();
  12948. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12949. {
  12950. IsDel = 1,
  12951. DeleteUserId = dto.DeleteUserId,
  12952. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12953. }).ExecuteCommand();
  12954. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12955. {
  12956. IsDel = 1,
  12957. DeleteUserId = dto.DeleteUserId,
  12958. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12959. }).ExecuteCommand();
  12960. #endregion
  12961. _sqlSugar.CommitTran();
  12962. return Ok(JsonView(true, "删除成功!"));
  12963. }
  12964. catch (Exception ex)
  12965. {
  12966. _sqlSugar.RollbackTran();
  12967. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12968. }
  12969. }
  12970. /// <summary>
  12971. /// op费用录入操作(Status:1.新增,2.修改)
  12972. /// </summary>
  12973. /// <param name="dto"></param>
  12974. /// <returns></returns>
  12975. [HttpPost]
  12976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12977. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12978. {
  12979. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12980. if (groupData.Code != 0)
  12981. {
  12982. return Ok(JsonView(false, groupData.Msg));
  12983. }
  12984. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12985. }
  12986. /// <summary>
  12987. /// 填写费用详细页面初始化绑定
  12988. /// </summary>
  12989. /// <param name="dto"></param>
  12990. /// <returns></returns>
  12991. [HttpPost]
  12992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12993. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12994. {
  12995. try
  12996. {
  12997. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12998. if (groupData.Code != 0)
  12999. {
  13000. return Ok(JsonView(false, groupData.Msg));
  13001. }
  13002. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13003. }
  13004. catch (Exception ex)
  13005. {
  13006. return Ok(JsonView(false, ex.Message));
  13007. }
  13008. }
  13009. /// <summary>
  13010. /// 根据op费用Id查询详细数据
  13011. /// </summary>
  13012. /// <param name="dto"></param>
  13013. /// <returns></returns>
  13014. [HttpPost]
  13015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13016. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13017. {
  13018. try
  13019. {
  13020. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13021. if (groupData.Code != 0)
  13022. {
  13023. return Ok(JsonView(false, groupData.Msg));
  13024. }
  13025. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13026. }
  13027. catch (Exception ex)
  13028. {
  13029. return Ok(JsonView(false, ex.Message));
  13030. }
  13031. }
  13032. /// <summary>
  13033. /// OP费用录入填写详情
  13034. /// </summary>
  13035. /// <param name="dto"></param>
  13036. /// <returns></returns>
  13037. [HttpPost]
  13038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13039. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  13040. {
  13041. try
  13042. {
  13043. #region 参数校验
  13044. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  13045. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  13046. if (di == null) return Ok(JsonView(false, "团组错误!"));
  13047. #endregion
  13048. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  13049. if (groupData.Code != 0)
  13050. {
  13051. return Ok(JsonView(false, groupData.Msg));
  13052. }
  13053. //自动审核
  13054. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  13055. #region 应用推送
  13056. try
  13057. {
  13058. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13059. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13060. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13061. //2024-10-21 新增LZ UID
  13062. var userIds = new List<int>() { 21 };
  13063. string title = $"系统通知";
  13064. var diId = dto.DiId;
  13065. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13066. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13067. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  13068. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13069. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  13070. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13071. }
  13072. catch (Exception ex)
  13073. {
  13074. }
  13075. #endregion
  13076. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13077. }
  13078. catch (Exception ex)
  13079. {
  13080. return Ok(JsonView(false, ex.Message));
  13081. }
  13082. }
  13083. /// <summary>
  13084. /// 获取三公详细所有城市
  13085. /// </summary>
  13086. /// <returns></returns>
  13087. [HttpGet]
  13088. public IActionResult OpCarCityResult()
  13089. {
  13090. var jw = JsonView(false);
  13091. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13092. {
  13093. x.Id,
  13094. x.Country,
  13095. x.City,
  13096. }).ToList();
  13097. if (data.Count > 0)
  13098. {
  13099. jw = JsonView(true, "获取成功!", data);
  13100. }
  13101. else
  13102. {
  13103. jw.Msg = "城市数据为空!";
  13104. jw.Data = Array.Empty<string>();
  13105. }
  13106. return Ok(jw);
  13107. }
  13108. /// <summary>
  13109. /// 导出地接费用明细
  13110. /// </summary>
  13111. /// <param name="dto"></param>
  13112. /// <returns></returns>
  13113. [HttpPost]
  13114. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13115. {
  13116. var jw = JsonView(false);
  13117. if (dto.Diid < 1)
  13118. {
  13119. jw.Msg = "请输入正确的diid!";
  13120. return Ok(jw);
  13121. }
  13122. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13123. if (group == null)
  13124. {
  13125. jw.Msg = "未找到团组信息!";
  13126. return Ok(jw);
  13127. }
  13128. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13129. if (localGuideArr.Count == 0)
  13130. {
  13131. jw.Msg = "该团组暂无地接信息!";
  13132. return Ok(jw);
  13133. }
  13134. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13135. var overspendSoure = new Dictionary<int, int>
  13136. {
  13137. { 91, 982 }, //车
  13138. { 92 , 1059} ,//导游
  13139. { 994 , 1073}, //翻译
  13140. { 988 , 1074 }, //早餐
  13141. { 93 , 1075 }, //午餐
  13142. { 989 , 1076 }, //晚餐
  13143. };
  13144. var Zips = new Dictionary<string, Stream>();
  13145. foreach (var groupArr in localGroup)
  13146. {
  13147. var keyValue = groupArr.Key;
  13148. if (int.TryParse(keyValue, out int cityid))
  13149. {
  13150. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13151. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13152. }
  13153. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13154. foreach (var item in groupArr)
  13155. {
  13156. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13157. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13158. new Grp_CarTouristGuideGroundReservationsContentExtend
  13159. {
  13160. Count = a.Count,
  13161. CreateTime = a.CreateTime,
  13162. CreateUserId = a.CreateUserId,
  13163. CTGGRId = a.CTGGRId,
  13164. Currency = a.Currency,
  13165. DatePrice = a.DatePrice,
  13166. DeleteTime = a.DeleteTime,
  13167. DeleteUserId = a.DeleteUserId,
  13168. DiId = a.DiId,
  13169. Id = a.Id,
  13170. IsDel = a.IsDel,
  13171. Price = a.Price,
  13172. PriceContent = a.PriceContent,
  13173. Remark = a.Remark,
  13174. SId = a.SId,
  13175. SidName = b.Name,
  13176. Units = a.Units,
  13177. }
  13178. ).ToList();
  13179. if (content.Count > 0)
  13180. {
  13181. contentArr.Add(content);
  13182. }
  13183. }
  13184. //open excel
  13185. //set excel
  13186. //save excel
  13187. try
  13188. {
  13189. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13190. IWorkbook workbook;
  13191. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13192. {
  13193. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13194. }
  13195. else
  13196. {
  13197. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13198. }
  13199. ISheet sheet = workbook.GetSheetAt(0);
  13200. var rowStartIndex = 2;
  13201. var clounmCount = 10;
  13202. var initStyleRow = sheet.GetRow(2);
  13203. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13204. //var overspendArrDetail =
  13205. var existsId = new List<CarCompare>();
  13206. var lastElem = arr.Last();
  13207. var thisSid = -1;
  13208. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13209. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13210. {
  13211. Name = "未知币种!",
  13212. Remark = "未知币种!",
  13213. };
  13214. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13215. Action cloneRowFn = () =>
  13216. {
  13217. rowStartIndex++;
  13218. var cloneRow = sheet.CreateRow(rowStartIndex);
  13219. // 复制样式
  13220. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13221. {
  13222. ICell sourceCell = initStyleRow.GetCell(i);
  13223. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13224. // 确保单元格存在样式
  13225. if (sourceCell.CellStyle != null)
  13226. {
  13227. targetCell.CellStyle = sourceCell.CellStyle;
  13228. }
  13229. }
  13230. };
  13231. var mergeRow = () =>
  13232. {
  13233. for (int i = 2; i < sheet.LastRowNum; i++)
  13234. {
  13235. var row = sheet.GetRow(i);
  13236. var cellFirst = row.GetCell(0);
  13237. var thisIndex = i + 1;
  13238. while (thisIndex < sheet.LastRowNum)
  13239. {
  13240. var nextRow = sheet.GetRow(thisIndex);
  13241. var nextCellFirst = nextRow.GetCell(0);
  13242. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13243. {
  13244. thisIndex++;
  13245. }
  13246. else
  13247. {
  13248. break;
  13249. }
  13250. }
  13251. thisIndex--;
  13252. if (thisIndex != i)
  13253. {
  13254. //合并row
  13255. var cellRangeAddress = new CellRangeAddress(
  13256. i, // 起始行索引(0-based)
  13257. thisIndex, // 结束行索引(0-based)
  13258. 0, // 起始列索引(0-based)
  13259. 0 // 结束列索引(0-based)
  13260. );
  13261. sheet.AddMergedRegion(cellRangeAddress);
  13262. i = thisIndex;
  13263. }
  13264. }
  13265. };
  13266. var chaoshiNumber = 0;
  13267. var totalNumber = 0.00M;
  13268. string lastStr = "";
  13269. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13270. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13271. {
  13272. b.IsAuditGM,
  13273. x.Id,
  13274. x.Area,
  13275. b.PayPercentage,
  13276. b.PayMoney,
  13277. }).ToList();
  13278. string yesPayment = "", noPayment = "";
  13279. foreach (var item in queryCarArrByCityAndDiid)
  13280. {
  13281. if (item.IsAuditGM == 1)
  13282. {
  13283. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13284. }
  13285. else
  13286. {
  13287. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13288. }
  13289. }
  13290. lastStr = yesPayment + noPayment;
  13291. foreach (var item in arr)
  13292. {
  13293. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13294. {
  13295. if (thisSid != item.SId)
  13296. {
  13297. if (thisSid == -1)
  13298. {
  13299. thisSid = item.SId;
  13300. }
  13301. else
  13302. {
  13303. //合并小计行
  13304. //创建合并区域的实例
  13305. var cellRangeAddress = new CellRangeAddress(
  13306. rowStartIndex, // 起始行索引(0-based)
  13307. rowStartIndex, // 结束行索引(0-based)
  13308. 0, // 起始列索引(0-based)
  13309. 3 // 结束列索引(0-based)
  13310. );
  13311. sheet.AddMergedRegion(cellRangeAddress);
  13312. var CellStyle = workbook.CreateCellStyle();
  13313. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13314. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13315. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13316. for (int i = 0; i <= clounmCount; i++)
  13317. {
  13318. if (i > 6)
  13319. {
  13320. var CellStyle1 = workbook.CreateCellStyle();
  13321. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13322. IFont Font = workbook.CreateFont(); // 创建字体
  13323. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13324. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13325. CellStyle1.SetFont(Font);
  13326. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13327. }
  13328. else
  13329. {
  13330. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13331. }
  13332. }
  13333. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13334. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13335. //超时合计
  13336. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13337. //超时数
  13338. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13339. //超时合计费用
  13340. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13341. thisSid = item.SId;
  13342. cloneRowFn();
  13343. chaoshiNumber = 0;
  13344. totalNumber = 0;
  13345. }
  13346. }
  13347. IRow row = sheet.GetRow(rowStartIndex);
  13348. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13349. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13350. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13351. if (isOpenOverspendSoure)
  13352. {
  13353. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13354. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13355. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13356. }
  13357. for (int i = 0; i <= clounmCount; i++)
  13358. {
  13359. var cell = row.GetCell(i);
  13360. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13361. if (cell == null)
  13362. {
  13363. cell = row.CreateCell(i);
  13364. }
  13365. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13366. fontRed.CloneStyleFrom(cell.CellStyle);
  13367. IFont Font = workbook.CreateFont(); // 创建字体
  13368. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13369. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13370. fontRed.SetFont(Font);
  13371. byte[] rgb = new byte[3] { 255, 242, 204 };
  13372. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13373. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13374. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13375. if (workbook is XSSFWorkbook)
  13376. {
  13377. BackgroundColor255_242_204.FillForegroundColor = 0;
  13378. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13379. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13380. }
  13381. else
  13382. {
  13383. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13384. }
  13385. if (i == 1 || i > 6)
  13386. {
  13387. if (i > 6)
  13388. {
  13389. fontRed.FillForegroundColor = 0;
  13390. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13391. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13392. }
  13393. cell.CellStyle = fontRed;
  13394. }
  13395. if (i > 2 && i < 7)
  13396. {
  13397. cell.CellStyle = BackgroundColor255_242_204;
  13398. }
  13399. cell.SetCellValue(setCellValue); //写入单元格
  13400. }
  13401. if (overspendSoure.ContainsKey(thisSid))
  13402. {
  13403. var overspendId = overspendSoure[thisSid];
  13404. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13405. }
  13406. cloneRowFn();
  13407. existsId.Add(new CarCompare
  13408. {
  13409. DataPrice = item.DatePrice.ObjToDate(),
  13410. Sid = item.SId
  13411. });
  13412. }
  13413. if (item.Equals(lastElem))
  13414. {
  13415. //合并小计行
  13416. //创建合并区域的实例
  13417. var cellRangeAddress = new CellRangeAddress(
  13418. rowStartIndex, // 起始行索引(0-based)
  13419. rowStartIndex, // 结束行索引(0-based)
  13420. 0, // 起始列索引(0-based)
  13421. 3 // 结束列索引(0-based)
  13422. );
  13423. sheet.AddMergedRegion(cellRangeAddress);
  13424. var CellStyle = workbook.CreateCellStyle();
  13425. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13426. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13427. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13428. for (int i = 0; i <= clounmCount; i++)
  13429. {
  13430. if (i > 6)
  13431. {
  13432. var CellStyle1 = workbook.CreateCellStyle();
  13433. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13434. IFont Font = workbook.CreateFont(); // 创建字体
  13435. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13436. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13437. CellStyle1.SetFont(Font);
  13438. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13439. }
  13440. else
  13441. {
  13442. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13443. }
  13444. }
  13445. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13446. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13447. //超时合计
  13448. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13449. //超时数
  13450. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13451. //超时合计费用
  13452. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13453. cloneRowFn();
  13454. // 创建合并区域的实例
  13455. cellRangeAddress = new CellRangeAddress(
  13456. rowStartIndex, // 起始行索引(0-based)
  13457. rowStartIndex, // 结束行索引(0-based)
  13458. 0, // 起始列索引(0-based)
  13459. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13460. );
  13461. // 添加合并区域
  13462. sheet.AddMergedRegion(cellRangeAddress);
  13463. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13464. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13465. }
  13466. }
  13467. mergeRow();
  13468. // 保存修改后的Excel文件到新文件
  13469. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13470. // new FileStream(newFilePath, FileMode.CreateNew)
  13471. using (var stream = new MemoryStream())
  13472. {
  13473. workbook.Write(stream, true);
  13474. stream.Flush();
  13475. stream.Seek(0, SeekOrigin.Begin);
  13476. var memoryStream = new MemoryStream();
  13477. stream.CopyTo(memoryStream);
  13478. memoryStream.Seek(0, SeekOrigin.Begin);
  13479. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13480. }
  13481. workbook.Close();
  13482. workbook.Dispose();
  13483. }
  13484. catch (Exception ex)
  13485. {
  13486. jw.Msg = "出现异常!" + ex.Message;
  13487. return Ok(jw);
  13488. }
  13489. }
  13490. if (Zips.Count > 0)
  13491. {
  13492. var io = new IOOperatorHelper();
  13493. var byts = io.ConvertZipStream(Zips);
  13494. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13495. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13496. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13497. }
  13498. else
  13499. {
  13500. jw.Msg = "暂无生成文件!";
  13501. }
  13502. return Ok(jw);
  13503. }
  13504. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13505. {
  13506. string outStr = string.Empty;
  13507. switch (i)
  13508. {
  13509. case 0:
  13510. outStr = arr[0].SidName;
  13511. break;
  13512. case 1:
  13513. outStr = arr[0].DataPriceStr;
  13514. break;
  13515. case 2:
  13516. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13517. break;
  13518. case 4:
  13519. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13520. break;
  13521. case 7:
  13522. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13523. {
  13524. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13525. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13526. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13527. }
  13528. break;
  13529. case 8:
  13530. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13531. {
  13532. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13533. }
  13534. break;
  13535. case 9:
  13536. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13537. {
  13538. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13539. }
  13540. break;
  13541. case 10:
  13542. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13543. {
  13544. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13545. }
  13546. break;
  13547. }
  13548. return outStr;
  13549. }
  13550. #region OP行程单
  13551. /// <summary>
  13552. /// OP行程单初始化
  13553. /// </summary>
  13554. /// <param name="dto"></param>
  13555. /// <returns></returns>
  13556. [HttpPost]
  13557. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13558. {
  13559. var jw = JsonView(false);
  13560. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13561. var group = groupList.First();
  13562. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13563. if (group == null)
  13564. {
  13565. jw.Msg = "暂无团组!";
  13566. return Ok(jw);
  13567. }
  13568. group = groupList.Find(x => x.Id == diid);
  13569. if (group == null)
  13570. {
  13571. jw.Msg = "请输入正确的团组ID!";
  13572. return Ok(jw);
  13573. }
  13574. string city = string.Empty;
  13575. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13576. if (blackCode.Count > 0)
  13577. {
  13578. var black = blackCode.First();
  13579. black.BlackCode = black.BlackCode ?? "";
  13580. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13581. if (blackSp.Length > 0)
  13582. {
  13583. try
  13584. {
  13585. var cityArrCode = new List<string>(20);
  13586. foreach (var item in blackSp)
  13587. {
  13588. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13589. var IndexSelect = itemSp[2];
  13590. var cityArrCodeLength = cityArrCode.Count - 1;
  13591. var startCity = IndexSelect.Substring(0, 3);
  13592. if (cityArrCodeLength > 0)
  13593. {
  13594. var arrEndCity = cityArrCode[cityArrCodeLength];
  13595. if (arrEndCity != startCity)
  13596. {
  13597. cityArrCode.Add(startCity.ToUpper());
  13598. }
  13599. }
  13600. else
  13601. {
  13602. cityArrCode.Add(startCity.ToUpper());
  13603. }
  13604. var endCity = IndexSelect.Substring(3, 3);
  13605. cityArrCode.Add(endCity.ToUpper());
  13606. }
  13607. var cityThree = string.Empty;
  13608. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13609. cityThree = cityThree.TrimEnd(',');
  13610. if (string.IsNullOrWhiteSpace(cityThree))
  13611. {
  13612. throw new
  13613. Exception("error");
  13614. }
  13615. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13616. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13617. foreach (var item in cityArrCode)
  13618. {
  13619. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13620. if (find != null)
  13621. {
  13622. city += find.City + "/";
  13623. }
  13624. else
  13625. {
  13626. city += item + "三字码未收入/";
  13627. }
  13628. }
  13629. city = city.TrimEnd('/');
  13630. }
  13631. catch (Exception e)
  13632. {
  13633. city = "黑屏代码格式不正确!";
  13634. }
  13635. }
  13636. }
  13637. else
  13638. {
  13639. city = "未录入黑屏代码";
  13640. }
  13641. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13642. {
  13643. Date = x.Date,
  13644. Days = x.Days,
  13645. Diffgroup = x.Diffgroup,
  13646. Diid = x.Diid,
  13647. Traffic_First = x.Traffic_First,
  13648. Traffic_Second = x.Traffic_Second,
  13649. Trip = x.Trip,
  13650. WeekDay = x.WeekDay,
  13651. Id = x.Id
  13652. }).ToList();
  13653. jw.Data = new
  13654. {
  13655. groupList = groupList.Select(x => new
  13656. {
  13657. x.Id,
  13658. x.TeamName,
  13659. x.TourCode
  13660. }).ToList(),
  13661. groupInfo = new
  13662. {
  13663. group.VisitDays,
  13664. group.TourCode,
  13665. group.VisitPNumber,
  13666. group.TeamName,
  13667. city
  13668. },
  13669. OpTravelList
  13670. };
  13671. jw.Code = 200;
  13672. jw.Msg = "操作成功!";
  13673. return Ok(jw);
  13674. }
  13675. /// <summary>
  13676. /// 删除团组行程单
  13677. /// </summary>
  13678. /// <returns></returns>
  13679. [HttpPost]
  13680. public IActionResult DelTravel(DelOpTravelDto dto)
  13681. {
  13682. var jw = JsonView(false);
  13683. if (dto.UserId <= 0 || dto.Diid <= 0)
  13684. {
  13685. jw.Msg = "请输入正确的参数!";
  13686. return Ok(jw);
  13687. }
  13688. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13689. .SetColumns(x => new Grp_TravelList
  13690. {
  13691. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13692. DeleteUserId = dto.UserId,
  13693. IsDel = 1,
  13694. }).ExecuteCommand();
  13695. jw = JsonView(true);
  13696. return Ok(jw);
  13697. }
  13698. /// <summary>
  13699. /// 行程单保存
  13700. /// </summary>
  13701. /// <returns></returns>
  13702. [HttpPost]
  13703. public IActionResult TravelSave(TravelSaveDto dto)
  13704. {
  13705. var jw = JsonView(false);
  13706. if (dto.Arr.Count > 0)
  13707. {
  13708. try
  13709. {
  13710. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13711. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13712. .ToList();
  13713. _sqlSugar.BeginTran();
  13714. foreach (var item in dto.Arr)
  13715. {
  13716. if (item.Id == 0)
  13717. {
  13718. throw new Exception("请传入正确的Id");
  13719. }
  13720. //比较上一次的差异
  13721. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13722. if (findTravel != null)
  13723. {
  13724. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13725. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13726. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13727. }
  13728. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13729. .SetColumns(x => new Grp_TravelList
  13730. {
  13731. Trip = item.Trip
  13732. }).ExecuteCommand();
  13733. }
  13734. _sqlSugar.CommitTran();
  13735. jw = JsonView(true);
  13736. }
  13737. catch (Exception ex)
  13738. {
  13739. _sqlSugar.RollbackTran();
  13740. jw.Msg = "程序异常!" + ex.Message;
  13741. }
  13742. }
  13743. else
  13744. {
  13745. jw.Msg = "请传入正确的参数!";
  13746. }
  13747. return Ok(jw);
  13748. }
  13749. private static string CheckStr(string original, string changed)
  13750. {
  13751. // 创建diff_match_patch对象
  13752. var dmp = new diff_match_patch();
  13753. // 计算差异
  13754. List<Diff> diffs = dmp.diff_main(original, changed);
  13755. // 清理和合并差异
  13756. dmp.diff_cleanupSemantic(diffs);
  13757. // 使用StringBuilder构建最终的字符串
  13758. var finalString = new StringBuilder();
  13759. // 输出差异结果,并构建变动后的字符串
  13760. foreach (Diff diff in diffs)
  13761. {
  13762. switch (diff.operation)
  13763. {
  13764. case Operation.EQUAL:
  13765. // 相等的部分,直接添加到最终字符串
  13766. finalString.Append(diff.text);
  13767. break;
  13768. case Operation.INSERT:
  13769. // 插入的部分,添加标记并添加到最终字符串
  13770. finalString.Append("[++]" + diff.text + "[++]");
  13771. break;
  13772. case Operation.DELETE:
  13773. // 删除的部分,不添加到最终字符串
  13774. //finalString.Append("[++]" + diff.text + "[++]");
  13775. break;
  13776. }
  13777. }
  13778. // 输出变动后的字符串
  13779. return finalString.ToString();
  13780. }
  13781. private class tagContent
  13782. {
  13783. public DateTime Date { get; set; }
  13784. public string StartTag { get; set; }
  13785. public string EndTag { get; set; }
  13786. public string Content { get; set; }
  13787. public static int tagLength { get { return 3; } }
  13788. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13789. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13790. public bool IsFinally { get; set; }
  13791. }
  13792. private static List<string> ExtractContentBetweenTags(string input, string tag)
  13793. {
  13794. var results = new List<string>();
  13795. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13796. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13797. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13798. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13799. string[] strValueArr = new string[1];
  13800. foreach (System.Text.RegularExpressions.Match match in matches)
  13801. {
  13802. var strValue = match.Groups[1].Value;
  13803. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13804. }
  13805. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13806. return results;
  13807. }
  13808. /// <summary>
  13809. /// 导出行程单
  13810. /// </summary>
  13811. /// <param name="dto"></param>
  13812. /// <returns></returns>
  13813. [HttpPost]
  13814. public IActionResult ExportTravel(ExportTravelDto dto)
  13815. {
  13816. var jw = JsonView(false);
  13817. jw.Data = "";
  13818. int diid = 0;
  13819. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13820. if (Find == null)
  13821. {
  13822. jw.Msg = "请选择正确的团组!";
  13823. return Ok(jw);
  13824. }
  13825. else
  13826. {
  13827. diid = Find.Id;
  13828. }
  13829. //数据源
  13830. var _travelList = new List<Grp_TravelList>();
  13831. DataTable dtBlack = null;
  13832. try
  13833. {
  13834. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13835. }
  13836. catch (Exception)
  13837. {
  13838. jw.Msg = "机票黑屏代码有误!";
  13839. return Ok(jw);
  13840. }
  13841. string CityStr = string.Empty;
  13842. if (dtBlack.Rows.Count == 0)
  13843. {
  13844. jw.Msg = "机票黑屏代码有误!";
  13845. return Ok(jw);
  13846. }
  13847. else
  13848. {
  13849. foreach (DataRow row in dtBlack.Rows)
  13850. {
  13851. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13852. {
  13853. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13854. return Ok(jw);
  13855. }
  13856. }
  13857. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13858. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13859. }
  13860. // 指定的文字
  13861. var targetTextDic = new Dictionary<string, List<string>>();
  13862. //创建数据源Table
  13863. var dtSource = new DataTable();
  13864. dtSource.Columns.Add("Days", typeof(string));
  13865. dtSource.Columns.Add("Date", typeof(string));
  13866. dtSource.Columns.Add("Week", typeof(string));
  13867. dtSource.Columns.Add("Traffic", typeof(string));
  13868. dtSource.Columns.Add("Trip", typeof(string));
  13869. //获取数据,放到datatable
  13870. foreach (var item in _travelList)
  13871. {
  13872. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13873. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13874. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13875. .Replace("[++]", string.Empty);
  13876. DataRow dr = dtSource.NewRow();
  13877. dr["Days"] = item.Days;
  13878. dr["Date"] = item.Date;
  13879. dr["Week"] = item.WeekDay;
  13880. dr["Traffic"] = item.Traffic_First
  13881. + "\r\n"
  13882. + item.Traffic_Second;
  13883. dr["Trip"] = item.Trip;
  13884. dtSource.Rows.Add(dr);
  13885. }
  13886. var dic = new Dictionary<string, string>
  13887. {
  13888. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  13889. { "City", CityStr },
  13890. { "Days", Find.VisitDays.ToString() },
  13891. { "DeleCode", Find.TourCode },
  13892. { "Pnum", Find.VisitPNumber.ToString() }
  13893. };
  13894. //模板路径
  13895. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13896. //载入模板
  13897. Document doc = null;
  13898. DocumentBuilder builder = null;
  13899. try
  13900. {
  13901. //载入模板
  13902. doc = new Document(tempPath);
  13903. builder = new DocumentBuilder(doc);
  13904. }
  13905. catch (Exception)
  13906. {
  13907. jw.Msg = "模板位置不存在!";
  13908. return Ok(jw);
  13909. }
  13910. foreach (var key in dic.Keys)
  13911. {
  13912. Bookmark bookmark = doc.Range.Bookmarks[key];
  13913. if (bookmark != null)
  13914. {
  13915. builder.MoveToBookmark(key);
  13916. builder.Write(dic[key]);
  13917. }
  13918. }
  13919. //获取word里所有表格
  13920. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13921. //获取所填表格的序数
  13922. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13923. try
  13924. {
  13925. //循环赋值
  13926. for (int i = 0; i < dtSource.Rows.Count; i++)
  13927. {
  13928. builder.MoveToCell(0, i + 1, 0, 0);
  13929. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13930. builder.MoveToCell(0, i + 1, 1, 0);
  13931. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13932. builder.MoveToCell(0, i + 1, 2, 0);
  13933. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13934. var trip = dtSource.Rows[i]["Trip"].ToString();
  13935. builder.MoveToCell(0, i + 1, 3, 0);
  13936. builder.Write(trip);
  13937. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13938. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13939. // 获取特定索引的段落
  13940. Paragraph paragraph = (Paragraph)paragraphs[0];
  13941. Run run = paragraph.Runs[0];
  13942. Aspose.Words.Font font = run.Font;
  13943. font.Name = "黑体";
  13944. //设置双休红色
  13945. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13946. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13947. paragraph = (Paragraph)paragraphs[1];
  13948. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13949. {
  13950. run = paragraph.Runs[0];
  13951. font = run.Font;
  13952. font.Color = Color.Red;
  13953. }
  13954. }
  13955. }
  13956. catch (Exception ex)
  13957. {
  13958. }
  13959. //删除多余行
  13960. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13961. {
  13962. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13963. }
  13964. var targetTextList = new List<string>();
  13965. // 遍历文档中的表格
  13966. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13967. {
  13968. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13969. {
  13970. var cellIndex = 0;
  13971. foreach (Cell cell in row.Cells)
  13972. {
  13973. if (cellIndex == 1 && row.Cells.Count == 4)
  13974. {
  13975. foreach (var target in targetTextDic.Keys)
  13976. {
  13977. if (cell.GetText().Contains(target))
  13978. {
  13979. targetTextList = targetTextDic[target];
  13980. break;
  13981. }
  13982. }
  13983. }
  13984. // 遍历单元格中的所有段落
  13985. foreach (Paragraph paragraph in cell.Paragraphs)
  13986. {
  13987. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13988. var runs = new List<Run>();
  13989. foreach (Run run in paragraph.Runs)
  13990. {
  13991. runs.Add(run);
  13992. }
  13993. foreach (Run run in runs)
  13994. {
  13995. foreach (var targetText in targetTextList)
  13996. {
  13997. // 检查文字是否包含指定文字
  13998. if (run.Text.Contains(targetText))
  13999. {
  14000. // 将包含的部分设置为红色
  14001. HighlightText(run, targetText, Color.Red);
  14002. }
  14003. }
  14004. }
  14005. }
  14006. cellIndex++;
  14007. }
  14008. }
  14009. }
  14010. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  14011. if (!Directory.Exists(savePath))
  14012. {
  14013. try
  14014. {
  14015. Directory.CreateDirectory(savePath);
  14016. }
  14017. catch
  14018. {
  14019. }
  14020. }
  14021. string path = savePath + Find.TeamName + "出访日程";
  14022. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  14023. try
  14024. {
  14025. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  14026. string postfix = ".docx";
  14027. if (dto.IsPDF == 1)
  14028. {
  14029. saveFormat = Aspose.Words.SaveFormat.Pdf;
  14030. postfix = ".pdf";
  14031. }
  14032. doc.Save(path + postfix, saveFormat);
  14033. jw = JsonView(true, "导出成功", ftpPath + postfix);
  14034. }
  14035. catch (Exception)
  14036. {
  14037. jw = JsonView(false);
  14038. }
  14039. return Ok(jw);
  14040. }
  14041. /// <summary>
  14042. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  14043. /// </summary>
  14044. /// <param name="num"></param>
  14045. /// <returns></returns>
  14046. static string GetNum(string num)
  14047. {
  14048. string str = "";
  14049. switch (num)
  14050. {
  14051. case "1":
  14052. str = "一";
  14053. break;
  14054. case "2":
  14055. str = "二";
  14056. break;
  14057. case "3":
  14058. str = "三";
  14059. break;
  14060. case "4":
  14061. str = "四";
  14062. break;
  14063. case "5":
  14064. str = "五";
  14065. break;
  14066. case "6":
  14067. str = "六";
  14068. break;
  14069. case "7":
  14070. str = "七";
  14071. break;
  14072. case "8":
  14073. str = "八";
  14074. break;
  14075. case "9":
  14076. str = "九";
  14077. break;
  14078. case "10":
  14079. str = "十";
  14080. break;
  14081. case "11":
  14082. str = "十一";
  14083. break;
  14084. case "12":
  14085. str = "十二";
  14086. break;
  14087. case "一":
  14088. str = "1";
  14089. break;
  14090. case "二":
  14091. str = "2";
  14092. break;
  14093. case "三":
  14094. str = "3";
  14095. break;
  14096. case "四":
  14097. str = "4";
  14098. break;
  14099. case "五":
  14100. str = "5";
  14101. break;
  14102. case "六":
  14103. str = "6";
  14104. break;
  14105. case "七":
  14106. str = "7";
  14107. break;
  14108. case "八":
  14109. str = "8";
  14110. break;
  14111. case "九":
  14112. str = "9";
  14113. break;
  14114. case "十":
  14115. str = "10";
  14116. break;
  14117. case "十一":
  14118. str = "11";
  14119. break;
  14120. case "十二":
  14121. str = "12";
  14122. break;
  14123. }
  14124. return str;
  14125. }
  14126. /// <summary>
  14127. /// 高亮包含指定文字的部分
  14128. /// </summary>
  14129. /// <param name="run"></param>
  14130. /// <param name="targetText"></param>
  14131. /// <param name="color"></param>
  14132. static void HighlightText(Run run, string targetText, Color color)
  14133. {
  14134. string text = run.Text;
  14135. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14136. if (startIndex >= 0)
  14137. {
  14138. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14139. // 前部分
  14140. if (startIndex > 0)
  14141. {
  14142. Run beforeRun = (Run)run.Clone(true);
  14143. beforeRun.Text = text.Substring(0, startIndex);
  14144. parentParagraph.InsertBefore(beforeRun, run);
  14145. }
  14146. // 匹配部分
  14147. Run matchRun = (Run)run.Clone(true);
  14148. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14149. matchRun.Font.Color = color;
  14150. parentParagraph.InsertBefore(matchRun, run);
  14151. // 后部分
  14152. if (startIndex + targetText.Length < text.Length)
  14153. {
  14154. Run afterRun = (Run)run.Clone(true);
  14155. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14156. parentParagraph.InsertBefore(afterRun, run);
  14157. }
  14158. // 删除原始Run
  14159. run.Remove();
  14160. }
  14161. }
  14162. #endregion
  14163. #endregion
  14164. #region 团组成本
  14165. /// <summary>
  14166. /// 团组成本数据初始化
  14167. /// </summary>
  14168. /// <param name="dto"></param>
  14169. /// <returns></returns>
  14170. [HttpPost]
  14171. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14172. {
  14173. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14174. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14175. WHEN COUNT(*) >= 0 THEN 'True'
  14176. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14177. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14178. ").ToList(); //团组列表
  14179. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14180. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14181. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14182. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14183. if (groupinfoValue != null)
  14184. {
  14185. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14186. var spArr = new string[1] { countryArr };
  14187. if (countryArr.Contains("|"))
  14188. {
  14189. spArr = countryArr.Split("|");
  14190. }
  14191. else if (countryArr.Contains("、"))
  14192. {
  14193. spArr = countryArr.Split("、");
  14194. }
  14195. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14196. {
  14197. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14198. if (dbQueryCountry != null)
  14199. {
  14200. visaCountryInfoArr.Add(dbQueryCountry);
  14201. }
  14202. }
  14203. }
  14204. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14205. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14206. #region 屏蔽黑屏代码生成
  14207. //var create = _GroupCostRepository.
  14208. // CreateGroupCostByBlackCode(dto.Diid);
  14209. //if (groupCost.Count == 0 && create.Code == 0)
  14210. //{
  14211. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14212. //}
  14213. #endregion
  14214. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14215. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14216. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14217. groupCostMap = groupCostMap.Select(x =>
  14218. {
  14219. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14220. {
  14221. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14222. }
  14223. return x;
  14224. }).ToList();
  14225. //GroupCostParameter.Add(new
  14226. // Grp_GroupCostParameter());
  14227. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14228. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14229. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14230. return Ok(JsonView(new
  14231. {
  14232. groupList,
  14233. groupInfo,
  14234. groupChecks,
  14235. groupCost = groupCostMap,
  14236. hotelNumber,
  14237. GroupCostParameter = GroupCostParameterMap,
  14238. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14239. {
  14240. x.VisaCountry,
  14241. x.VisaPrice,
  14242. x.Id,
  14243. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14244. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14245. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14246. x.VisaTime, // 一般签证时间
  14247. }).ToList(),
  14248. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14249. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14250. hotelIsTrue,
  14251. groupModuleOperators
  14252. }));
  14253. }
  14254. /// <summary>
  14255. /// 团组成本信息保存
  14256. /// </summary>
  14257. /// <param name="dto"></param>
  14258. /// <returns></returns>
  14259. [HttpPost]
  14260. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14261. {
  14262. if (dto.Diid <= 0 || dto.Userid <= 0)
  14263. {
  14264. return Ok(JsonView(false));
  14265. }
  14266. JsonView jw = null;
  14267. bool isTrue = false;
  14268. #region 复制团组成本
  14269. //if (dto.Diid == 2581)
  14270. //{
  14271. // dto.Diid = 2599;
  14272. // dto.CheckBoxs.ForEach(x =>
  14273. // {
  14274. // x.Diid = 2599;
  14275. // });
  14276. // dto.GroupCosts.ForEach(x =>
  14277. // {
  14278. // x.Diid = 2599;
  14279. // });
  14280. // dto.CostTypeHotelNumbers.ForEach(x =>
  14281. // {
  14282. // x.Diid = 2599;
  14283. // });
  14284. // dto.GroupCostParameters.ForEach(x =>
  14285. // {
  14286. // x.DiId = 2599;
  14287. // });
  14288. //}
  14289. #endregion
  14290. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14291. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14292. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14293. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14294. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14295. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14296. try
  14297. {
  14298. _sqlSugar.BeginTran();
  14299. isTrue = await _GroupCostRepository.
  14300. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14301. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14302. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14303. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14304. _sqlSugar.CommitTran();
  14305. jw = JsonView(true, "保存成功!", isTrue);
  14306. }
  14307. catch (Exception)
  14308. {
  14309. _sqlSugar.RollbackTran();
  14310. jw = JsonView(false);
  14311. }
  14312. return Ok(jw);
  14313. }
  14314. /// <summary>
  14315. /// 复制团组成本信息
  14316. /// </summary>
  14317. /// <param name="dto"></param>
  14318. /// <returns></returns>
  14319. [HttpPost]
  14320. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14321. {
  14322. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14323. {
  14324. return Ok(JsonView(false, "参数有误!"));
  14325. }
  14326. #region 复制团组成本
  14327. dto.Diid = dto.ToGroupId;
  14328. dto.CheckBoxs.ForEach(x =>
  14329. {
  14330. x.Diid = dto.ToGroupId;
  14331. });
  14332. dto.GroupCosts.ForEach(x =>
  14333. {
  14334. x.Diid = dto.ToGroupId;
  14335. });
  14336. dto.CostTypeHotelNumbers.ForEach(x =>
  14337. {
  14338. x.Diid = dto.ToGroupId;
  14339. });
  14340. dto.GroupCostParameters.ForEach(x =>
  14341. {
  14342. x.DiId = dto.ToGroupId;
  14343. });
  14344. #endregion
  14345. JsonView jw = null;
  14346. bool isTrue = false;
  14347. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14348. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14349. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14350. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14351. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14352. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14353. try
  14354. {
  14355. _sqlSugar.BeginTran();
  14356. isTrue = await _GroupCostRepository.
  14357. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14358. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14359. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14360. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14361. _sqlSugar.CommitTran();
  14362. jw = JsonView(true, "保存成功!", isTrue);
  14363. }
  14364. catch (Exception)
  14365. {
  14366. _sqlSugar.RollbackTran();
  14367. jw = JsonView(false);
  14368. }
  14369. return Ok(jw);
  14370. }
  14371. /// <summary>
  14372. /// 司兼导数据
  14373. /// </summary>
  14374. /// <param name="dto"></param>
  14375. /// <returns></returns>
  14376. [HttpPost]
  14377. public IActionResult GetCarGuides(CarGuidesDto dto)
  14378. {
  14379. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14380. return Ok(JsonView(true, "获取成功!", Data));
  14381. }
  14382. /// <summary>
  14383. /// 导游数据
  14384. /// </summary>
  14385. /// <param name="dto"></param>
  14386. /// <returns></returns>
  14387. [HttpPost]
  14388. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14389. {
  14390. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14391. // 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
  14392. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14393. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14394. return Ok(JsonView(true, "获取成功!", Data));
  14395. }
  14396. /// <summary>
  14397. /// 成本车数据
  14398. /// </summary>
  14399. /// <param name="dto"></param>
  14400. /// <returns></returns>
  14401. [HttpPost]
  14402. public IActionResult GetCarInfo(CarGuidesDto dto)
  14403. {
  14404. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14405. return Ok(JsonView(true, "获取成功!", Data));
  14406. }
  14407. /// <summary>
  14408. /// 景点数据
  14409. /// </summary>
  14410. /// <param name="dto"></param>
  14411. /// <returns></returns>
  14412. [HttpPost]
  14413. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14414. {
  14415. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14416. return Ok(JsonView(true, "获取成功!", Data));
  14417. }
  14418. /// <summary>
  14419. /// 成本通知
  14420. /// </summary>
  14421. /// <param name="dto"></param>
  14422. /// <returns></returns>
  14423. [HttpPost]
  14424. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14425. {
  14426. if (dto.Diid < 0)
  14427. {
  14428. return Ok(JsonView(false));
  14429. }
  14430. JsonView jw;
  14431. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14432. if (GroupCostParameter != null)
  14433. {
  14434. int IsShare = 0;
  14435. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14436. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14437. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14438. string msg = string.Empty;
  14439. if (isTrue)
  14440. {
  14441. if (IsShare == 0)
  14442. {
  14443. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14444. }
  14445. else
  14446. {
  14447. #region 企微通知对应岗位用户
  14448. try
  14449. {
  14450. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14451. }
  14452. catch (Exception)
  14453. {
  14454. }
  14455. #endregion
  14456. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14457. }
  14458. jw = JsonView(isTrue, msg, new { IsShare });
  14459. }
  14460. else
  14461. {
  14462. msg = "修改失败!";
  14463. jw = JsonView(isTrue, msg);
  14464. }
  14465. }
  14466. else
  14467. {
  14468. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14469. }
  14470. return Ok(jw);
  14471. }
  14472. /// <summary>
  14473. /// 导出报价单
  14474. /// </summary>
  14475. /// <param name="dto"></param>
  14476. /// <returns></returns>
  14477. [HttpPost]
  14478. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14479. {
  14480. if (dto.Diid == 0)
  14481. {
  14482. return Ok(JsonView(false, "请传递团组id"));
  14483. }
  14484. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14485. if (deleInfo.Code != 0)
  14486. {
  14487. return Ok(JsonView(false, "团组信息查询失败!"));
  14488. }
  14489. var di = deleInfo.Data as DelegationInfoWebView;
  14490. if (di != null)
  14491. {
  14492. di.TeamName = di.TeamName.Replace("|", "、");
  14493. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14494. //文件名
  14495. string strFileName = di.TeamName + "-收款账单.doc";
  14496. //获取模板
  14497. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14498. //载入模板
  14499. Document doc = new Document(tmppath);
  14500. decimal TotalPrice = 0.00M;
  14501. string itemStr = string.Empty;
  14502. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14503. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14504. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14505. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14506. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14507. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14508. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14509. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14510. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14511. foreach (var cost in groupCostType)
  14512. {
  14513. var List = cost.ToList();
  14514. if (cost.Key == "A")
  14515. {
  14516. foreach (var ListItem in List)
  14517. {
  14518. if (ListItem.number > 0)
  14519. {
  14520. if (ListItem.code.Contains("TBR"))
  14521. {
  14522. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14523. }
  14524. else
  14525. {
  14526. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14527. }
  14528. TotalPrice += (ListItem.number * ListItem.price);
  14529. }
  14530. }
  14531. }
  14532. else
  14533. {
  14534. itemStr = itemStr.Insert(0, "A段\r\n");
  14535. itemStr += "B段\r\n";
  14536. foreach (var ListItem in List)
  14537. {
  14538. if (ListItem.number > 0)
  14539. {
  14540. if (ListItem.code.Contains("TBR"))
  14541. {
  14542. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14543. }
  14544. else
  14545. {
  14546. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14547. }
  14548. TotalPrice += (ListItem.number * ListItem.price);
  14549. }
  14550. }
  14551. }
  14552. }
  14553. #region 替换Word模板书签内容
  14554. Dictionary<string, string> marks = new Dictionary<string, string>();
  14555. marks.Add("To", di.ClientUnit);//付款方
  14556. marks.Add("ToTel", di.TellPhone);//付款方电话
  14557. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14558. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14559. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14560. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14561. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14562. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14563. marks.Add("PayItemContent", itemStr);//详细信息
  14564. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14565. #endregion
  14566. ////注
  14567. //if (doc.Range.Bookmarks["Attention"] != null)
  14568. //{
  14569. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14570. // mark.Text = frList[0].Attention;
  14571. //}
  14572. foreach (var item in marks.Keys)
  14573. {
  14574. if (doc.Range.Bookmarks[item] != null)
  14575. {
  14576. Bookmark mark = doc.Range.Bookmarks[item];
  14577. mark.Text = marks[item];
  14578. }
  14579. }
  14580. byte[] bytes = null;
  14581. using (MemoryStream stream = new MemoryStream())
  14582. {
  14583. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14584. bytes = stream.ToArray();
  14585. }
  14586. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14587. return Ok(JsonView(true, "", new
  14588. {
  14589. Data = bytes,
  14590. strFileName,
  14591. }));
  14592. }
  14593. else
  14594. {
  14595. return Ok(JsonView(false, "团组信息不存在!"));
  14596. }
  14597. }
  14598. /// <summary>
  14599. /// 导出团组成本
  14600. /// </summary>
  14601. /// <param name="dto"></param>
  14602. /// <returns></returns>
  14603. [HttpPost]
  14604. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14605. {
  14606. var jw = JsonView(false);
  14607. if (dto.Diid == 0)
  14608. {
  14609. return Ok(JsonView(false, "请传递团组id"));
  14610. }
  14611. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14612. if (deleInfo.Code != 0)
  14613. {
  14614. return Ok(JsonView(false, "团组信息查询失败!"));
  14615. }
  14616. var di = deleInfo.Data as DelegationInfoWebView;
  14617. if (di == null)
  14618. {
  14619. return Ok(JsonView(false, "团组信息查询失败!"));
  14620. }
  14621. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14622. WorkbookDesigner designer = new WorkbookDesigner();
  14623. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14624. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14625. for (int i = 0; i < List_GC.Count; i++)
  14626. {
  14627. GroupCost_Excel gc = new GroupCost_Excel();
  14628. gc.Id = List_GC[i].Id;
  14629. gc.Diid = List_GC[i].Diid.ToString();
  14630. gc.DAY = List_GC[i].DAY;
  14631. string week = "";
  14632. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14633. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14634. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14635. gc.ITIN = List_GC[i].ITIN;
  14636. gc.CarType = List_GC[i].CarType;
  14637. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  14638. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  14639. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  14640. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  14641. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  14642. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  14643. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  14644. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  14645. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  14646. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  14647. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  14648. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  14649. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14650. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14651. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  14652. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  14653. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  14654. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  14655. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  14656. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  14657. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  14658. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  14659. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  14660. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  14661. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  14662. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  14663. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  14664. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  14665. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  14666. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  14667. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  14668. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  14669. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  14670. List_GC1.Add(gc);
  14671. }
  14672. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14673. dt.TableName = "TB";
  14674. //报表标题等不用dt的值
  14675. designer.SetDataSource("TeamName", dto.title.TeamName);
  14676. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14677. designer.SetDataSource("Tax", dto.title.Tax);
  14678. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14679. designer.SetDataSource("Currency", dto.title.Currency);
  14680. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14681. designer.SetDataSource("Rate", dto.title.Rate);
  14682. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14683. var Aparams = hotels.Find(x => x.Type == "Default");
  14684. if (Aparams == null)
  14685. {
  14686. return Ok(jw);
  14687. }
  14688. //酒店数量
  14689. var txtSGRNumber = Aparams.SGR.ToString();
  14690. var txtTBRNumber = Aparams.TBR.ToString();
  14691. var txtJSESNumber = Aparams.JSES.ToString();
  14692. var txtSUITENumbe = Aparams.SUITE.ToString();
  14693. if (dto.costType == "B")
  14694. {
  14695. Aparams = hotels.Find(x => x.Type == "A");
  14696. var Bparams = hotels.Find(x => x.Type == "B");
  14697. if (Aparams == null || Bparams == null)
  14698. {
  14699. return Ok(jw);
  14700. }
  14701. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14702. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14703. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14704. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14705. }
  14706. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14707. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14708. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14709. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14710. var ws = designer.Workbook.Worksheets[0];
  14711. int Row = List_GC.Count;
  14712. int startIndex = 11;
  14713. int HideRows = 0;
  14714. List<int> hideRowsList = new List<int>();
  14715. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14716. #region A段left数据
  14717. var left = dto.leftInfo.Find(x => x.Type == "A");
  14718. if (left == null)
  14719. {
  14720. return Ok(jw);
  14721. }
  14722. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14723. if (leftBindData != null)
  14724. {
  14725. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14726. designer.SetDataSource("VisaRS", leftBindData.rs);
  14727. designer.SetDataSource("VisaXS", leftBindData.xs);
  14728. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14729. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14730. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14731. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14732. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14733. }
  14734. else
  14735. {
  14736. hideRowsList.Add(Row + startIndex + HideRows);
  14737. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14738. }
  14739. HideRows += 2;
  14740. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14741. if (leftBindData != null)
  14742. {
  14743. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14744. designer.SetDataSource("BXRS", leftBindData.rs);
  14745. designer.SetDataSource("BXXS", leftBindData.xs);
  14746. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14747. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14748. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14749. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14750. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14751. }
  14752. else
  14753. {
  14754. hideRowsList.Add(Row + startIndex + HideRows);
  14755. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14756. }
  14757. HideRows += 2;
  14758. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14759. if (leftBindData != null)
  14760. {
  14761. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14762. designer.SetDataSource("HSRS", leftBindData.rs);
  14763. designer.SetDataSource("HSXS", leftBindData.xs);
  14764. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14765. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14766. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14767. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14768. designer.SetDataSource("HSZLR", ((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("经济舱"));
  14777. if (leftBindData != null)
  14778. {
  14779. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14780. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14781. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14782. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14783. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14784. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14785. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14786. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14787. }
  14788. else
  14789. {
  14790. hideRowsList.Add(Row + startIndex + HideRows);
  14791. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14792. }
  14793. HideRows += 2;
  14794. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14795. if (leftBindData != null)
  14796. {
  14797. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14798. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14799. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14800. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14801. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14802. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14803. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14804. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14805. }
  14806. else
  14807. {
  14808. hideRowsList.Add(Row + startIndex + HideRows);
  14809. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14810. }
  14811. HideRows += 2;
  14812. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14813. if (leftBindData != null)
  14814. {
  14815. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14816. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14817. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14818. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14819. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14820. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14821. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14822. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14823. }
  14824. else
  14825. {
  14826. hideRowsList.Add(Row + startIndex + HideRows);
  14827. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14828. }
  14829. HideRows += 2;
  14830. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14831. if (leftBindData != null)
  14832. {
  14833. ////TBR
  14834. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14835. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14836. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14837. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14838. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14839. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14840. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14841. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14842. }
  14843. else
  14844. {
  14845. hideRowsList.Add(Row + startIndex + HideRows);
  14846. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14847. }
  14848. HideRows += 2;
  14849. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14850. if (leftBindData != null)
  14851. {
  14852. ////SGR
  14853. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14854. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14855. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14856. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14857. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14858. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14859. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14860. designer.SetDataSource("HotelSGRZLR", ((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("JSES"));
  14869. if (leftBindData != null)
  14870. {
  14871. ////JS/ES
  14872. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14873. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14874. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14875. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14876. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14877. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14878. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14879. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14880. }
  14881. else
  14882. {
  14883. hideRowsList.Add(Row + startIndex + HideRows);
  14884. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14885. }
  14886. HideRows += 2;
  14887. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14888. if (leftBindData != null)
  14889. {
  14890. ////SUITE
  14891. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14892. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14893. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14894. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14895. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14896. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14897. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14898. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14899. }
  14900. else
  14901. {
  14902. hideRowsList.Add(Row + startIndex + HideRows);
  14903. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14904. }
  14905. HideRows += 2;
  14906. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14907. if (leftBindData != null)
  14908. {
  14909. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14910. designer.SetDataSource("DJRS", leftBindData.rs);
  14911. designer.SetDataSource("DJXS", leftBindData.xs);
  14912. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14913. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14914. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14915. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14916. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14917. }
  14918. else
  14919. {
  14920. hideRowsList.Add(Row + startIndex + HideRows);
  14921. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14922. }
  14923. HideRows += 2;
  14924. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14925. if (leftBindData != null)
  14926. {
  14927. designer.SetDataSource("HCPCB", leftBindData.cb);
  14928. designer.SetDataSource("HCPRS", leftBindData.rs);
  14929. designer.SetDataSource("HCPXS", leftBindData.xs);
  14930. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14931. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14932. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14933. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14934. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14935. }
  14936. else
  14937. {
  14938. hideRowsList.Add(Row + startIndex + HideRows);
  14939. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14940. }
  14941. HideRows += 2;
  14942. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14943. if (leftBindData != null)
  14944. {
  14945. designer.SetDataSource("CPCB", leftBindData.cb);
  14946. designer.SetDataSource("CPRS", leftBindData.rs);
  14947. designer.SetDataSource("CPXS", leftBindData.xs);
  14948. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14949. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14950. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14951. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14952. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14953. }
  14954. else
  14955. {
  14956. hideRowsList.Add(Row + startIndex + HideRows);
  14957. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14958. }
  14959. HideRows += 2;
  14960. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14961. if (leftBindData != null)
  14962. {
  14963. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14964. designer.SetDataSource("GWRS", leftBindData.rs);
  14965. designer.SetDataSource("GWXS", leftBindData.xs);
  14966. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14967. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14968. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14969. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14970. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14971. }
  14972. else
  14973. {
  14974. hideRowsList.Add(Row + startIndex + HideRows);
  14975. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14976. }
  14977. HideRows += 2;
  14978. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14979. if (leftBindData != null)
  14980. {
  14981. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14982. designer.SetDataSource("LYJRS", leftBindData.rs);
  14983. designer.SetDataSource("LYJXS", leftBindData.xs);
  14984. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14985. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14986. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14987. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14988. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14989. }
  14990. else
  14991. {
  14992. hideRowsList.Add(Row + startIndex + HideRows);
  14993. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14994. }
  14995. #endregion
  14996. #region A段Right信息
  14997. var right = dto.rightInfo.Find(x => x.Type == "A");
  14998. if (right == null)
  14999. {
  15000. return Ok(jw);
  15001. }
  15002. HideRows += 4;
  15003. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15004. if (rightBindData != null)
  15005. {
  15006. //经济舱 + 双人间 TBR
  15007. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  15008. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  15009. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15010. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  15011. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15012. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15013. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15014. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15015. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15016. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15017. }
  15018. else
  15019. {
  15020. hideRowsList.Add(Row + startIndex + HideRows);
  15021. }
  15022. HideRows += 2;
  15023. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15024. if (rightBindData != null)
  15025. {
  15026. //经济舱 + 单人间 SGR
  15027. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  15028. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  15029. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15030. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  15031. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15032. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15033. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15034. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15035. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15036. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15037. }
  15038. else
  15039. {
  15040. hideRowsList.Add(Row + startIndex + HideRows);
  15041. }
  15042. HideRows += 2;
  15043. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15044. if (rightBindData != null)
  15045. {
  15046. //公务舱 + 单人间 SGR
  15047. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  15048. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  15049. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15050. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  15051. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15052. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15053. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15054. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15055. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15056. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15057. }
  15058. else
  15059. {
  15060. hideRowsList.Add(Row + startIndex + HideRows);
  15061. }
  15062. HideRows += 2;
  15063. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15064. if (rightBindData != null)
  15065. {
  15066. //公务舱 + 小套房 JSES
  15067. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  15068. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  15069. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15070. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  15071. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15072. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15073. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15074. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15075. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15076. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15077. }
  15078. else
  15079. {
  15080. hideRowsList.Add(Row + startIndex + HideRows);
  15081. }
  15082. HideRows += 2;
  15083. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15084. if (rightBindData != null)
  15085. {
  15086. //公务舱 + 小套房 JSES
  15087. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  15088. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  15089. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15090. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  15091. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15092. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15093. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15094. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15095. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15096. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15097. }
  15098. else
  15099. {
  15100. hideRowsList.Add(Row + startIndex + HideRows);
  15101. }
  15102. HideRows += 2;
  15103. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15104. if (rightBindData != null)
  15105. {
  15106. //经济舱 + 大套房
  15107. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15108. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15109. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15110. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15111. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15112. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15113. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15114. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15115. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15116. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15117. }
  15118. else
  15119. {
  15120. hideRowsList.Add(Row + startIndex + HideRows);
  15121. }
  15122. HideRows += 2;
  15123. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15124. if (rightBindData != null)
  15125. {
  15126. //头等舱 + 小套房 JSES
  15127. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15128. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15129. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15130. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15131. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15132. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15133. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15134. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15135. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15136. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15137. }
  15138. else
  15139. {
  15140. hideRowsList.Add(Row + startIndex + HideRows);
  15141. }
  15142. HideRows += 2;
  15143. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15144. if (rightBindData != null)
  15145. {
  15146. //头等舱 + 大套房
  15147. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15148. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15149. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15150. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15151. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15152. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15153. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15154. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15155. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15156. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15157. }
  15158. else
  15159. {
  15160. hideRowsList.Add(Row + startIndex + HideRows);
  15161. }
  15162. #endregion
  15163. #region B段标题清空
  15164. designer.SetDataSource("CostBDRCB", "");
  15165. designer.SetDataSource("CostBRS", "");
  15166. designer.SetDataSource("CostBXS", "");
  15167. designer.SetDataSource("CostBZCB", "");
  15168. designer.SetDataSource("CostBDRBJ", "");
  15169. designer.SetDataSource("CostBZBJ", "");
  15170. designer.SetDataSource("CostBDRLR", "");
  15171. designer.SetDataSource("CostBZLR", "");
  15172. designer.SetDataSource("CostBDRCBOM", "");
  15173. designer.SetDataSource("CostBRSOM", "");
  15174. designer.SetDataSource("CostBZCBOM", "");
  15175. designer.SetDataSource("CostBDRBJOM", "");
  15176. designer.SetDataSource("CostBZBJOM", "");
  15177. designer.SetDataSource("CostBDRLROM", "");
  15178. designer.SetDataSource("CostBZLROM", "");
  15179. #endregion
  15180. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15181. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15182. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15183. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15184. designer.SetDataSource("DJName", "地接(CNY)");
  15185. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15186. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15187. designer.SetDataSource("GWName", "公务(CNY)");
  15188. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15189. designer.SetDataSource("LYJName", "零用金(CNY)");
  15190. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15191. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15192. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15193. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15194. designer.SetDataSource("BXName", "保险(CNY)");
  15195. designer.SetDataSource("VisaName", "签证(CNY)");
  15196. #region B段基本数据
  15197. if (dto.costType == "B")
  15198. {
  15199. left = dto.leftInfo.Find(x => x.Type == "B");
  15200. if (left == null)
  15201. {
  15202. return Ok(jw);
  15203. }
  15204. #region B段left数据
  15205. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15206. if (leftBindData != null)
  15207. {
  15208. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15209. designer.SetDataSource("BHSRS", leftBindData.rs);
  15210. designer.SetDataSource("BHSXS", leftBindData.xs);
  15211. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15212. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15213. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15214. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15215. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15216. }
  15217. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15218. if (leftBindData != null)
  15219. {
  15220. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15221. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15222. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15223. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15224. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15225. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15226. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15227. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15228. }
  15229. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15230. if (leftBindData != null)
  15231. {
  15232. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15233. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15234. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15235. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15236. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15237. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15238. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15239. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15240. }
  15241. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15242. if (leftBindData != null)
  15243. {
  15244. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15245. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15246. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15247. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15248. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15249. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15250. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15251. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15252. }
  15253. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15254. if (leftBindData != null)
  15255. {
  15256. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15257. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15258. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15259. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15260. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15261. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15262. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15263. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15264. }
  15265. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15266. if (leftBindData != null)
  15267. {
  15268. designer.SetDataSource("BCPCB", leftBindData.cb);
  15269. designer.SetDataSource("BCPRS", leftBindData.rs);
  15270. designer.SetDataSource("BCPXS", leftBindData.xs);
  15271. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15272. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15273. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15274. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15275. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15276. }
  15277. //TBR
  15278. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15279. if (leftBindData != null)
  15280. {
  15281. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15282. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15283. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15284. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15285. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15286. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15287. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15288. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15289. }
  15290. //SGR
  15291. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15292. if (leftBindData != null)
  15293. {
  15294. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15295. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15296. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15297. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15298. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15299. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15300. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15301. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15302. }
  15303. //JS/ES
  15304. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15305. if (leftBindData != null)
  15306. {
  15307. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15308. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15309. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15310. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15311. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15312. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15313. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15314. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15315. }
  15316. //SUITE
  15317. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15318. if (leftBindData != null)
  15319. {
  15320. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15321. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15322. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15323. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15324. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15325. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15326. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15327. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15328. }
  15329. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15330. if (leftBindData != null)
  15331. {
  15332. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15333. designer.SetDataSource("BDJRS", leftBindData.rs);
  15334. designer.SetDataSource("BDJXS", leftBindData.xs);
  15335. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15336. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15337. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15338. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15339. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15340. }
  15341. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15342. if (leftBindData != null)
  15343. {
  15344. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15345. designer.SetDataSource("BGWRS", leftBindData.rs);
  15346. designer.SetDataSource("BGWXS", leftBindData.xs);
  15347. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15348. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15349. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15350. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15351. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15352. }
  15353. #region 优化方案
  15354. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15355. //excelBind.Add("零用金", new {
  15356. //cb="",
  15357. //rs="",
  15358. //xs ="",
  15359. //zcb = "",
  15360. //});
  15361. #endregion
  15362. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15363. if (leftBindData != null)
  15364. {
  15365. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15366. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15367. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15368. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15369. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15370. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15371. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15372. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15373. }
  15374. #endregion
  15375. #region B段Right信息
  15376. right = dto.rightInfo.Find(x => x.Type == "B");
  15377. if (right == null)
  15378. {
  15379. return Ok(jw);
  15380. }
  15381. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15382. if (rightBindData != null)
  15383. {
  15384. //经济舱 + 双人间 TBR
  15385. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15386. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15387. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15388. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15389. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15390. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15391. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15392. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15393. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15394. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15395. }
  15396. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15397. if (rightBindData != null)
  15398. {
  15399. //经济舱 + 单人间 SGR
  15400. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15401. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15402. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15403. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15404. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15405. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15406. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15407. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15408. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15409. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15410. }
  15411. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15412. if (rightBindData != null)
  15413. {
  15414. //公务舱 + 单人间 SGR
  15415. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15416. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15417. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15418. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15419. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15420. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15421. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15422. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15423. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15424. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15425. }
  15426. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15427. if (rightBindData != null)
  15428. {
  15429. //公务舱 + 小套房 JSES
  15430. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15431. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15432. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15433. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15434. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15435. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15436. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15437. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15438. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15439. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15440. }
  15441. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15442. if (rightBindData != null)
  15443. {
  15444. //公务舱 + 小套房 JSES
  15445. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15446. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15447. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15448. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15449. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15450. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15451. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15452. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15453. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15454. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15455. }
  15456. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15457. if (rightBindData != null)
  15458. {
  15459. //经济舱 + 大套房
  15460. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15461. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15462. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15463. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15464. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15465. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15466. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15467. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15468. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15469. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15470. }
  15471. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15472. if (rightBindData != null)
  15473. {
  15474. //头等舱 + 小套房 JSES
  15475. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15476. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15477. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15478. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15479. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15480. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15481. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15482. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15483. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15484. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15485. }
  15486. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15487. if (rightBindData != null)
  15488. {
  15489. //头等舱 + 大套房
  15490. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15491. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15492. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15493. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15494. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15495. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15496. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15497. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15498. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15499. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15500. }
  15501. #endregion
  15502. #region 标题
  15503. designer.SetDataSource("CostBDRCB", "单人成本");
  15504. designer.SetDataSource("CostBRS", "人数");
  15505. designer.SetDataSource("CostBXS", "系数");
  15506. designer.SetDataSource("CostBZCB", "总成本");
  15507. designer.SetDataSource("CostBDRBJ", "单人报价");
  15508. designer.SetDataSource("CostBZBJ", "总报价");
  15509. designer.SetDataSource("CostBDRLR", "单人利润");
  15510. designer.SetDataSource("CostBZLR", "总利润");
  15511. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15512. designer.SetDataSource("CostBRSOM", "人数");
  15513. designer.SetDataSource("CostBZCBOM", "总成本");
  15514. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15515. designer.SetDataSource("CostBZBJOM", "总报价");
  15516. designer.SetDataSource("CostBDRLROM", "单人利润");
  15517. designer.SetDataSource("CostBZLROM", "总利润");
  15518. #endregion
  15519. }
  15520. #endregion
  15521. designer.SetDataSource("TzZCB2", TzZCB2);
  15522. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15523. designer.SetDataSource("TzZLR2", TzZLR2);
  15524. string[] dataSourceKeys = new string[]
  15525. {
  15526. "VF",
  15527. "TGS",
  15528. "TGOF",
  15529. "TGM",
  15530. "TGA",
  15531. "TGTF",
  15532. "TGEF",
  15533. "CFM",
  15534. "CFOF",
  15535. "B",
  15536. "L",
  15537. "D",
  15538. "TBR",
  15539. "SGR",
  15540. "JSES",
  15541. "Suite",
  15542. "TV",
  15543. "1L",
  15544. "IF",
  15545. "EF",
  15546. "BRF",
  15547. "TE",
  15548. "TGT",
  15549. "DRVT",
  15550. "PC",
  15551. "TLF",
  15552. "ECT"
  15553. };
  15554. foreach (var item in dataSourceKeys)
  15555. {
  15556. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  15557. if (find != null)
  15558. {
  15559. designer.SetDataSource(item, find.text);
  15560. }
  15561. else
  15562. {
  15563. designer.SetDataSource(item, 0);
  15564. }
  15565. }
  15566. designer.SetDataSource(dt);
  15567. //根据数据源处理生成报表内容
  15568. designer.Process();
  15569. designer.Workbook.Worksheets[0].Name = "清单";
  15570. Worksheet sheet = designer.Workbook.Worksheets[0];
  15571. foreach (var Rowindex in hideRowsList)
  15572. {
  15573. ws.Cells.HideRows(Rowindex, 2);
  15574. }
  15575. byte[] bytes = null;
  15576. string strFileName = di.TeamName + "-团组-成本.xls";
  15577. using (MemoryStream stream = new MemoryStream())
  15578. {
  15579. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15580. bytes = stream.ToArray();
  15581. }
  15582. return Ok(JsonView(true, "", new
  15583. {
  15584. Data = bytes,
  15585. strFileName,
  15586. }));
  15587. }
  15588. /// <summary>
  15589. /// 导出客户报表
  15590. /// </summary>
  15591. /// <returns></returns>
  15592. [HttpPost]
  15593. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15594. {
  15595. var jw = JsonView(false);
  15596. if (dto.Diid == 0)
  15597. {
  15598. return Ok(JsonView(false, "请传递团组id"));
  15599. }
  15600. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15601. if (deleInfo.Code != 0)
  15602. {
  15603. return Ok(JsonView(false, "团组信息查询失败!"));
  15604. }
  15605. var di = deleInfo.Data as DelegationInfoWebView;
  15606. if (di == null)
  15607. {
  15608. return Ok(JsonView(false, "团组信息查询失败!"));
  15609. }
  15610. //文件名
  15611. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15612. //获取模板
  15613. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15614. //载入模板
  15615. Document doc = new Document(tmppath);
  15616. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15617. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15618. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15619. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15620. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15621. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15622. if (AParameter == null)
  15623. {
  15624. return Ok(JsonView(false, "系数不存在!"));
  15625. }
  15626. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15627. , TzAirDesc, TzZCost;
  15628. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15629. = TzAirDesc = TzZCost = string.Empty;
  15630. TzNumber = AParameter.CostTypenumber.ToString();
  15631. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15632. CarGuides1 = dto.CarGuides1;
  15633. Meal = dto.Meal;
  15634. SubsidizedMeals = dto.SubsidizedMeals;
  15635. NightRepair = dto.NightRepair;
  15636. AttractionsTickets = dto.AttractionsTickets;
  15637. MiscellaneousFees = dto.MiscellaneousFees;
  15638. ATip = dto.ATip;
  15639. TzHotelDesc = "";
  15640. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15641. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15642. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15643. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15644. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15645. TzAirDesc = "";
  15646. TzZCost = dto.TzZCost;
  15647. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15648. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15649. var index = 1;
  15650. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15651. foreach (var item in TzHotelDescArr)
  15652. {
  15653. if (AinfoArr != null)
  15654. {
  15655. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15656. if (Ainfo != null)
  15657. {
  15658. if (int.Parse(Ainfo.rs) <= 0)
  15659. {
  15660. continue;
  15661. }
  15662. var hotelText = string.Empty;
  15663. switch (item)
  15664. {
  15665. case "SGR":
  15666. hotelText = "单人间";
  15667. break;
  15668. case "JSES":
  15669. hotelText = "小套房";
  15670. break;
  15671. case "SUITE":
  15672. hotelText = "套房";
  15673. break;
  15674. case "TBR":
  15675. hotelText = "双人间";
  15676. break;
  15677. }
  15678. if (item != "TBR")
  15679. {
  15680. 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";
  15681. }
  15682. else
  15683. {
  15684. 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";
  15685. }
  15686. index++;
  15687. }
  15688. }
  15689. }
  15690. index = 1;
  15691. foreach (var item in TzAirDescArr)
  15692. {
  15693. if (AinfoArr != null)
  15694. {
  15695. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15696. if (Ainfo != null)
  15697. {
  15698. if (int.Parse(Ainfo.rs) <= 0)
  15699. {
  15700. continue;
  15701. }
  15702. 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";
  15703. index++;
  15704. }
  15705. }
  15706. }
  15707. if (dto.costType == "B")
  15708. {
  15709. if (BParameter == null)
  15710. {
  15711. return Ok(JsonView(false, "B段系数不存在!"));
  15712. }
  15713. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15714. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15715. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15716. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15717. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15718. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15719. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15720. foreach (var item in TzHotelDescArr)
  15721. {
  15722. if (AinfoArr != null)
  15723. {
  15724. TzHotelDesc += "B段信息 \r\n";
  15725. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15726. if (Ainfo != null)
  15727. {
  15728. if (int.Parse(Ainfo.rs) <= 0)
  15729. {
  15730. continue;
  15731. }
  15732. var hotelText = string.Empty;
  15733. switch (item)
  15734. {
  15735. case "SGR":
  15736. hotelText = "单人间";
  15737. break;
  15738. case "JSES":
  15739. hotelText = "小套房";
  15740. break;
  15741. case "SUITE":
  15742. hotelText = "套房";
  15743. break;
  15744. case "TBR":
  15745. hotelText = "双人间";
  15746. break;
  15747. }
  15748. if (item != "TBR")
  15749. {
  15750. 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";
  15751. }
  15752. else
  15753. {
  15754. 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";
  15755. }
  15756. index++;
  15757. }
  15758. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15759. }
  15760. }
  15761. index = 1;
  15762. foreach (var item in TzAirDescArr)
  15763. {
  15764. if (AinfoArr != null)
  15765. {
  15766. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15767. if (Ainfo != null)
  15768. {
  15769. if (int.Parse(Ainfo.rs) <= 0)
  15770. {
  15771. continue;
  15772. }
  15773. 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";
  15774. index++;
  15775. }
  15776. }
  15777. }
  15778. }
  15779. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15780. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15781. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15782. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15783. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15784. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15785. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15786. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15787. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15788. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15789. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15790. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15791. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15792. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15793. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15794. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15795. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15796. DickeyValue.Add("TzZCost", TzZCost);
  15797. foreach (var key in DickeyValue.Keys)
  15798. {
  15799. if (doc.Range.Bookmarks[key] != null)
  15800. {
  15801. Bookmark mark = doc.Range.Bookmarks[key];
  15802. mark.Text = DickeyValue[key];
  15803. }
  15804. }
  15805. byte[] bytes = null;
  15806. string strFileName = di.TeamName + "-客户报价.doc";
  15807. using (MemoryStream stream = new MemoryStream())
  15808. {
  15809. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15810. bytes = stream.ToArray();
  15811. }
  15812. return Ok(JsonView(true, "", new
  15813. {
  15814. Data = bytes,
  15815. strFileName,
  15816. }));
  15817. }
  15818. /// <summary>
  15819. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15820. /// </summary>
  15821. /// <param name="dto"></param>
  15822. /// <returns></returns>
  15823. [HttpPost]
  15824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15825. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15826. {
  15827. try
  15828. {
  15829. #region 参数验证
  15830. if (dto.DiId < 0)
  15831. {
  15832. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15833. }
  15834. List<int> cTableIds = new List<int>() {
  15835. 76 ,//酒店预订
  15836. 77 ,//行程
  15837. 79 ,//车/导游地接
  15838. 80 ,//签证
  15839. 81 ,//邀请/公务活
  15840. 82 ,//团组客户保险
  15841. 85 ,//机票预订
  15842. 98 ,//其他款项
  15843. 285 ,//收款退还
  15844. 751 ,//酒店早餐
  15845. 1015 // 超支费用
  15846. };
  15847. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15848. {
  15849. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15850. }
  15851. #endregion
  15852. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15853. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15854. if (_GroupCostParameters.Count <= 0)
  15855. {
  15856. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15857. }
  15858. if (_GroupCostParameters[0].IsShare == 0)
  15859. {
  15860. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15861. }
  15862. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15863. //处理date为空问题
  15864. if (_GroupCosts.Count > 0)
  15865. {
  15866. for (int i = 0; i < _GroupCosts.Count; i++)
  15867. {
  15868. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15869. {
  15870. if (i > 0)
  15871. {
  15872. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15873. }
  15874. }
  15875. }
  15876. }
  15877. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15878. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15879. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15880. string currCode = "";
  15881. #region currCode 验证
  15882. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15883. if (isInt)
  15884. {
  15885. var currData = currDatas.Find(it => it.Id == intCurrency);
  15886. if (currData != null)
  15887. {
  15888. currCode = currData.Name;
  15889. }
  15890. }
  15891. else
  15892. {
  15893. currCode = _GroupCostParameters[0].Currency.Trim();
  15894. }
  15895. #endregion
  15896. //op,酒店单段模式存储
  15897. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15898. {
  15899. CurrencyCode = currCode,
  15900. Rate = _GroupCostParameters[0].Rate,
  15901. CostType = _GroupCostParameters[0].CostType,
  15902. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15903. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15904. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15905. };
  15906. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15907. if (_GroupCostParameters.Count == 2)
  15908. {
  15909. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15910. }
  15911. foreach (var item in _GroupCostParameters)
  15912. {
  15913. decimal _rate = 1;
  15914. decimal _rate1 = item.Rate;
  15915. decimal _scale = 1;
  15916. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15917. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15918. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15919. //if (userInfo != null)
  15920. //{
  15921. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15922. // {
  15923. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15924. // {
  15925. // _scale = 1.00M;
  15926. // }
  15927. // }
  15928. //}
  15929. #endregion
  15930. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15931. {
  15932. CurrencyCode = currCode,
  15933. Rate = _rate1,
  15934. CostType = item.CostType,
  15935. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15936. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15937. CostTypeNumber = item.CostTypenumber
  15938. };
  15939. if (_GroupCostParameters.Count > 1)
  15940. {
  15941. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15942. }
  15943. else
  15944. {
  15945. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15946. }
  15947. if (dto.CTable == 79)//
  15948. {
  15949. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15950. modulePromptInfo.TotalCost = item.DJCB;
  15951. }
  15952. List<string> costTypes = new List<string>() { "A", "B" };
  15953. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15954. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15955. if (_GroupCostsDuplicates.Count() == 1)
  15956. {
  15957. _GroupCostsTypeData = _GroupCosts;
  15958. }
  15959. else
  15960. {
  15961. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15962. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15963. }
  15964. /*
  15965. * 76 酒店预订
  15966. * 77 行程
  15967. * 79 车/导游地接
  15968. * 80 签证
  15969. * 81 邀请/公务活动
  15970. * 82 团组客户保险
  15971. * 85 机票预订
  15972. * 98 其他款项
  15973. * 285 收款退还
  15974. * 751 酒店早餐
  15975. * 1015 超支费用
  15976. */
  15977. switch (dto.CTable)
  15978. {
  15979. case 76: // 酒店预订
  15980. _ModuleSubPromptInfo.AddRange(
  15981. _GroupCostsTypeData.Select(it => new
  15982. {
  15983. it.DAY,
  15984. it.Date,
  15985. it.ACCON,
  15986. it.ITIN,
  15987. it.SGR,
  15988. it.TBR,
  15989. it.JS_ES,
  15990. it.Suite
  15991. })
  15992. );
  15993. break;
  15994. case 79: // 车/导游地接
  15995. _ModuleSubPromptInfo.AddRange(
  15996. _GroupCostsTypeData.Select(it => new
  15997. {
  15998. Date = it.Date, //日期
  15999. CarFee = it.CarCost * _rate * _scale, //车费用
  16000. CarType = it.CarType, //车型
  16001. DriverFee = it.CFS * _rate * _scale, //司机工资
  16002. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  16003. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  16004. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  16005. GuideFee = it.TGS * _rate * _scale, //导游费用
  16006. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  16007. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  16008. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  16009. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  16010. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  16011. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  16012. Breakfast = it.B * _rate * _scale, //早餐费
  16013. Lunch = it.L * _rate * _scale, //午餐费
  16014. Dinner = it.D * _rate * _scale, //晚餐费
  16015. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  16016. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  16017. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  16018. TicketFee = it.EF * _rate * _scale, //门票费
  16019. TicketRemark = it.EFR, //门票费描述
  16020. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  16021. TravelSupplies = it.TE * _rate * _scale, //出行物资
  16022. SpentCash = it.PC * _rate * _scale, //零用金
  16023. LeadersFee = it.TLF * _rate * _scale, //领队费
  16024. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  16025. })
  16026. );
  16027. break;
  16028. case 85: // 机票
  16029. List<dynamic> datas = new List<dynamic>();
  16030. datas.Add(
  16031. new
  16032. {
  16033. AirType = "经济舱",
  16034. AirNum = item.JJCRS,
  16035. AirDRCB = item.JJCCB,
  16036. AirZCB = (item.JJCRS * item.JJCCB)
  16037. }
  16038. );
  16039. datas.Add(
  16040. new
  16041. {
  16042. AirType = "公务舱",
  16043. AirNum = item.GWCRS,
  16044. AirDRCB = item.GWCCB,
  16045. AirZCB = (item.GWCRS * item.GWCCB)
  16046. }
  16047. );
  16048. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16049. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  16050. modulePromptInfo.Data = new
  16051. {
  16052. airFeeData = datas,
  16053. airInitData = initDatas
  16054. };
  16055. _ModulePromptInfos.Add(modulePromptInfo);
  16056. break;
  16057. default:
  16058. break;
  16059. }
  16060. }
  16061. if (dto.CTable != 85)
  16062. {
  16063. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  16064. _ModulePromptInfos.Add(_ModulePromptInfo);
  16065. }
  16066. _view.ModulePromptInfos = _ModulePromptInfos;
  16067. return Ok(JsonView(true, "操作成功!", _view));
  16068. }
  16069. catch (Exception ex)
  16070. {
  16071. return Ok(JsonView(false, ex.Message));
  16072. }
  16073. }
  16074. /// <summary>
  16075. /// 根据黑屏代码重新生成行程
  16076. /// </summary>
  16077. /// <param name="dto"></param>
  16078. /// <returns></returns>
  16079. [HttpPost]
  16080. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  16081. {
  16082. var jw = JsonView(false, "Error");
  16083. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  16084. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  16085. .Select(x => new
  16086. {
  16087. x.Id,
  16088. x.Title
  16089. })
  16090. .ToList();
  16091. if (Create.Any())
  16092. {
  16093. jw.Msg = "获取成功!";
  16094. jw.Code = 200;
  16095. jw.Data = new
  16096. {
  16097. BlackCodeListSelect = Create,
  16098. blackCodeIsTrue = true
  16099. };
  16100. }
  16101. else
  16102. {
  16103. jw.Code = 400;
  16104. jw.Data = new
  16105. {
  16106. BlackCodeListSelect = Create,
  16107. blackCodeIsTrue = false,
  16108. };
  16109. }
  16110. return Ok(jw);
  16111. }
  16112. /// <summary>
  16113. /// 根据黑屏代码Id重新生成行程
  16114. /// </summary>
  16115. /// <param name="dto"></param>
  16116. /// <returns></returns>
  16117. [HttpPost]
  16118. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16119. {
  16120. var jw = JsonView(false, "Error");
  16121. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16122. if (result.Code == 0)
  16123. {
  16124. jw.Msg = "获取成功!";
  16125. jw.Code = 200;
  16126. jw.Data = new
  16127. {
  16128. groupCost = result.Data,
  16129. blackCodeIsTrue = true
  16130. };
  16131. }
  16132. else
  16133. {
  16134. jw.Code = 400;
  16135. jw.Data = new
  16136. {
  16137. groupCost = result.Data,
  16138. blackCodeIsTrue = false,
  16139. };
  16140. }
  16141. return Ok(jw);
  16142. }
  16143. /// <summary>
  16144. /// 成本获取OP历史车费用
  16145. /// </summary>
  16146. /// <param name="dto"></param>
  16147. /// <returns></returns>
  16148. [HttpPost]
  16149. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16150. {
  16151. var jw = JsonView(false);
  16152. try
  16153. {
  16154. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16155. //获取现有所有车的数据
  16156. if (!dto.Param.IsNullOrWhiteSpace())
  16157. {
  16158. string sql = $@"
  16159. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16160. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16161. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16162. 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
  16163. AND gctggr.ServiceEndTime is not NULL
  16164. ORDER by gctggrc.id DESC
  16165. ";
  16166. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16167. var numeberResult = await Task.Run(() =>
  16168. {
  16169. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16170. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16171. return numberArr;
  16172. });
  16173. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16174. foreach (var item in numeberResult)
  16175. {
  16176. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16177. {
  16178. Country = "数据异常!",
  16179. City = string.Empty,
  16180. };
  16181. item.Area = find.Country + " " + find.City;
  16182. }
  16183. dbResult.AddRange(numeberResult);
  16184. if (dto.Param.Contains("、"))
  16185. {
  16186. var sp = dto.Param.Split("、");
  16187. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16188. .Where(x =>
  16189. {
  16190. return System.Array.Exists(sp, e =>
  16191. {
  16192. bool where = false;
  16193. if (x.Area != null)
  16194. {
  16195. where = x.Area.Contains(e);
  16196. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16197. {
  16198. return false;
  16199. }
  16200. }
  16201. if (x.PriceName != null && !where)
  16202. {
  16203. where = x.PriceName.Contains(e);
  16204. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16205. {
  16206. return false;
  16207. }
  16208. }
  16209. return where;
  16210. });
  16211. }).ToList();
  16212. }
  16213. else
  16214. {
  16215. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16216. .Where(x =>
  16217. {
  16218. bool where = false;
  16219. if (x.Area != null)
  16220. {
  16221. where = x.Area.Contains(dto.Param);
  16222. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16223. {
  16224. return false;
  16225. }
  16226. }
  16227. if (x.PriceName != null && !where)
  16228. {
  16229. where = x.PriceName.Contains(dto.Param);
  16230. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16231. {
  16232. return false;
  16233. }
  16234. }
  16235. return where;
  16236. }
  16237. )
  16238. .ToList();
  16239. }
  16240. }
  16241. var view = dbResult.Select(x =>
  16242. {
  16243. decimal dp = 0.00M;
  16244. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16245. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16246. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16247. {
  16248. if (startB && endB)
  16249. {
  16250. var timesp = endD.Subtract(startD);
  16251. if ((timesp.Days + 1) != 0)
  16252. {
  16253. dp = x.Price / (timesp.Days + 1);
  16254. }
  16255. }
  16256. }
  16257. else
  16258. {
  16259. dp = x.Price;
  16260. }
  16261. return new
  16262. {
  16263. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16264. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16265. x.Area,
  16266. x.id,
  16267. price = x.Price.ToString("F2"),
  16268. x.PriceName,
  16269. x.PriceContent,
  16270. x.TeamName,
  16271. x.DatePrice,
  16272. dayPrice = dp.ToString("F2"),
  16273. };
  16274. }).OrderByDescending(x => x.id).ToList();
  16275. jw = JsonView(true, "获取成功!", view);
  16276. }
  16277. catch (Exception e)
  16278. {
  16279. jw = JsonView(false, e.Message);
  16280. }
  16281. return Ok(jw);
  16282. }
  16283. [HttpPost]
  16284. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16285. {
  16286. var jw = JsonView(true);
  16287. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16288. #region SQL语句
  16289. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16290. //{
  16291. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16292. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16293. // WHEN COUNT(*) >= 0 THEN 'True'
  16294. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16295. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16296. // ")
  16297. // .ToList();
  16298. //}
  16299. //else
  16300. //{
  16301. // string likeKey = string.Empty;
  16302. // foreach (var item in dto.Keyword)
  16303. // {
  16304. // likeKey += "%" + item;
  16305. // }
  16306. // likeKey += "%";
  16307. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16308. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16309. // WHEN COUNT(*) >= 0 THEN 'True'
  16310. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16311. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16312. // ")
  16313. // .ToList();
  16314. //}
  16315. #endregion
  16316. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16317. {
  16318. @KeyWord = dto.Keyword
  16319. });
  16320. if (table != null && table.Rows.Count > 0)
  16321. {
  16322. foreach (DataRow row in table.Rows)
  16323. {
  16324. matches.Add(new DelegationInfoAndIsTrueView
  16325. {
  16326. Id = row.Field<int>("Id"),
  16327. GroupName = row.Field<string>("GroupName"),
  16328. isTrue = row.Field<string>("isTrue")
  16329. });
  16330. }
  16331. }
  16332. if (matches.Any())
  16333. {
  16334. jw.Data = matches;
  16335. }
  16336. else
  16337. {
  16338. jw.Code = 201;
  16339. jw.Msg = "empty list";
  16340. jw.Data = new List<string>(1);
  16341. }
  16342. return Ok(jw);
  16343. }
  16344. /// <summary>
  16345. /// 报价Word下载
  16346. /// </summary>
  16347. /// <param name="dto"></param>
  16348. /// <returns></returns>
  16349. [HttpPost]
  16350. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16351. {
  16352. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16353. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16354. if (di == null)
  16355. {
  16356. return Ok(JsonView(false, "团组不存在!"));
  16357. }
  16358. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16359. if (mainPrice == null || mainPrice.IsShare == 0)
  16360. {
  16361. return Ok(JsonView(false, "团组成本不存在!"));
  16362. }
  16363. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16364. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16365. if (costTypeHotelNumbers == null)
  16366. {
  16367. return Ok(JsonView(false, "团组成本不存在!"));
  16368. }
  16369. //文件名
  16370. string strFileName = di.TeamName + "-收款账单.doc";
  16371. //获取模板
  16372. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16373. //载入模板
  16374. Document doc = new Document(tmppath);
  16375. decimal allPrice = 0.00M;
  16376. string itemStr = string.Empty;
  16377. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16378. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16379. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16380. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16381. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16382. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16383. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16384. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16385. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16386. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16387. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16388. {
  16389. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16390. ("BXRS", "BXCB", "BXXS", "bx"),
  16391. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16392. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16393. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16394. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16395. ("CPRS", "CPCB", "CPXS", "cp"),
  16396. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16397. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16398. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16399. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16400. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16401. ("DJRS", "DJCB", "DJXS", "dj"),
  16402. ("GWRS", "GWCB", "GWXS", "gw"),
  16403. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16404. };
  16405. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16406. var rightSum = 0.00M;
  16407. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16408. {
  16409. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16410. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16411. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16412. if (prefix == "tbr")
  16413. {
  16414. rsValue *= 2;
  16415. cbValue /= 2;
  16416. }
  16417. if (OtherCostPropertyBJ.Contains(prefix))
  16418. {
  16419. rightSum += cbValue * xsValue;
  16420. }
  16421. }
  16422. var hotelRooms = new Dictionary<string, int>
  16423. {
  16424. { "SGR", costTypeHotelNumbers.SGR },
  16425. { "TBR", costTypeHotelNumbers.TBR },
  16426. { "JSES", costTypeHotelNumbers.JSES },
  16427. { "SUITE", costTypeHotelNumbers.SUITE }
  16428. };
  16429. var flights = new Dictionary<string, int>
  16430. {
  16431. { "经济舱", mainPrice.JJCRS },
  16432. { "公务舱", mainPrice.GWCRS },
  16433. { "头等舱", mainPrice.TDCRS }
  16434. };
  16435. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16436. {
  16437. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16438. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16439. { "头等舱", new[] { "SUITE", "JSES" } }
  16440. };
  16441. var result = new Dictionary<string, int>();
  16442. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16443. foreach (var flight in flights.Keys)
  16444. {
  16445. // 获取当前舱位的匹配规则
  16446. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16447. {
  16448. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16449. }
  16450. }
  16451. #region right计算
  16452. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16453. {
  16454. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16455. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16456. airHotelPriceList.Add(new
  16457. AirHotelPrice
  16458. {
  16459. Name = "经济舱TBR",
  16460. Price = rightSum + air + hotel,
  16461. Count = result["经济舱TBR"] * 2
  16462. });
  16463. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16464. }
  16465. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16466. {
  16467. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16468. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16469. airHotelPriceList.Add(new
  16470. AirHotelPrice
  16471. {
  16472. Name = "经济舱SGR",
  16473. Price = rightSum + air + hotel,
  16474. Count = result["经济舱SGR"]
  16475. });
  16476. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16477. }
  16478. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16479. {
  16480. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16481. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16482. airHotelPriceList.Add(new
  16483. AirHotelPrice
  16484. {
  16485. Name = "公务舱SGR",
  16486. Price = rightSum + air + hotel,
  16487. Count = result["公务舱SGR"]
  16488. });
  16489. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16490. }
  16491. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16492. {
  16493. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16494. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16495. airHotelPriceList.Add(new
  16496. AirHotelPrice
  16497. {
  16498. Name = "公务舱JSES",
  16499. Price = rightSum + air + hotel,
  16500. Count = result["公务舱JSES"]
  16501. });
  16502. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16503. }
  16504. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16505. {
  16506. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16507. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16508. airHotelPriceList.Add(new
  16509. AirHotelPrice
  16510. {
  16511. Name = "公务舱SUITE",
  16512. Price = rightSum + air + hotel,
  16513. Count = result["公务舱SUITE"]
  16514. });
  16515. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16516. }
  16517. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16518. {
  16519. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16520. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16521. airHotelPriceList.Add(new
  16522. AirHotelPrice
  16523. {
  16524. Name = "经济舱SUITE",
  16525. Price = rightSum + air + hotel,
  16526. Count = result["经济舱SUITE"]
  16527. });
  16528. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16529. }
  16530. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16531. {
  16532. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16533. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16534. airHotelPriceList.Add(new
  16535. AirHotelPrice
  16536. {
  16537. Name = "头等舱JSES",
  16538. Price = rightSum + air + hotel,
  16539. Count = result["头等舱JSES"]
  16540. });
  16541. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16542. }
  16543. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16544. {
  16545. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16546. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16547. airHotelPriceList.Add(new
  16548. AirHotelPrice
  16549. {
  16550. Name = "头等舱SUITE",
  16551. Price = rightSum + air + hotel,
  16552. Count = result["头等舱SUITE"]
  16553. });
  16554. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16555. }
  16556. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16557. {
  16558. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16559. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16560. airHotelPriceList.Add(new
  16561. AirHotelPrice
  16562. {
  16563. Name = "经济舱JSES",
  16564. Price = rightSum + air + hotel,
  16565. Count = result["经济舱JSES"]
  16566. });
  16567. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16568. }
  16569. #endregion
  16570. foreach (var item in airSouer.Keys)
  16571. {
  16572. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16573. if (find != null && find.Count > 0)
  16574. {
  16575. if (item.Contains("TBR"))
  16576. {
  16577. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16578. }
  16579. else
  16580. {
  16581. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16582. }
  16583. }
  16584. }
  16585. #region 替换Word模板书签内容
  16586. Dictionary<string, string> marks = new Dictionary<string, string>();
  16587. marks.Add("To", di.ClientUnit);//付款方
  16588. marks.Add("ToTel", di.TellPhone);//付款方电话
  16589. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16590. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16591. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16592. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16593. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16594. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16595. marks.Add("PayItemContent", itemStr);//详细信息
  16596. marks.Add("Total", allPrice.ToString("F2"));//合计
  16597. #endregion
  16598. foreach (var item in marks.Keys)
  16599. {
  16600. if (doc.Range.Bookmarks[item] != null)
  16601. {
  16602. Bookmark mark = doc.Range.Bookmarks[item];
  16603. mark.Text = marks[item];
  16604. }
  16605. }
  16606. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16607. doc.Save(savePaht);
  16608. var jw = new JsonView();
  16609. jw.Msg = "生成成功!";
  16610. jw.Code = 200;
  16611. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16612. return Ok(jw);
  16613. }
  16614. /// <summary>
  16615. /// 详细报价费用Excel下载
  16616. /// </summary>
  16617. /// <param name="dto"></param>
  16618. /// <returns></returns>
  16619. [HttpPost]
  16620. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16621. {
  16622. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16623. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16624. if (di == null)
  16625. {
  16626. return Ok(JsonView(false, "团组不存在!"));
  16627. }
  16628. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16629. if (mainPrice == null || mainPrice.IsShare == 0)
  16630. {
  16631. return Ok(JsonView(false, "团组成本不存在!"));
  16632. }
  16633. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16634. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16635. if (costTypeHotelNumbers == null)
  16636. {
  16637. return Ok(JsonView(false, "团组成本不存在!"));
  16638. }
  16639. WorkbookDesigner designer = new WorkbookDesigner();
  16640. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16641. List<int> hideRowsList = new List<int>();
  16642. int conterStartIndex = 3;
  16643. int rowIndex = conterStartIndex;
  16644. designer.SetDataSource("GroupName", di.TeamName);
  16645. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16646. {
  16647. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16648. ("BXRS", "BXCB", "BXXS", "bx"),
  16649. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16650. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16651. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16652. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16653. ("CPRS", "CPCB", "CPXS", "cp") ,
  16654. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16655. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16656. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16657. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16658. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16659. ("DJRS", "DJCB", "DJXS", "dj") ,
  16660. ("GWRS", "GWCB", "GWXS", "gw") ,
  16661. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16662. };
  16663. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16664. var rightSum = 0.00M;
  16665. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16666. {
  16667. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16668. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16669. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16670. if (prefix == "tbr")
  16671. {
  16672. rsValue *= 2;
  16673. cbValue /= 2;
  16674. }
  16675. if (OtherCostPropertyBJ.Contains(prefix))
  16676. {
  16677. rightSum += cbValue * xsValue;
  16678. }
  16679. if (rsValue == 0)
  16680. {
  16681. hideRowsList.Add(rowIndex);
  16682. }
  16683. else
  16684. {
  16685. designer.SetDataSource($"{prefix}rs", rsValue);
  16686. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16687. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16688. }
  16689. rowIndex += 2;
  16690. }
  16691. var hotelRooms = new Dictionary<string, int>
  16692. {
  16693. { "SGR", costTypeHotelNumbers.SGR },
  16694. { "TBR", costTypeHotelNumbers.TBR },
  16695. { "JSES", costTypeHotelNumbers.JSES },
  16696. { "SUITE", costTypeHotelNumbers.SUITE }
  16697. };
  16698. var flights = new Dictionary<string, int>
  16699. {
  16700. { "经济舱", mainPrice.JJCRS },
  16701. { "公务舱", mainPrice.GWCRS },
  16702. { "头等舱", mainPrice.TDCRS }
  16703. };
  16704. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16705. {
  16706. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16707. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16708. { "头等舱", new[] { "SUITE", "JSES" } }
  16709. };
  16710. var result = new Dictionary<string, int>();
  16711. foreach (var flight in flights.Keys)
  16712. {
  16713. // 获取当前舱位的匹配规则
  16714. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16715. {
  16716. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16717. }
  16718. }
  16719. var allPrice = 0.00M;
  16720. #region right计算
  16721. int airRowIndex = 35;
  16722. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16723. {
  16724. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16725. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16726. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16727. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16728. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16729. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16730. }
  16731. else
  16732. {
  16733. hideRowsList.Add(airRowIndex);
  16734. }
  16735. airRowIndex += 2;
  16736. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16737. {
  16738. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16739. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16740. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16741. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16742. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16743. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16744. }
  16745. else
  16746. {
  16747. hideRowsList.Add(airRowIndex);
  16748. }
  16749. airRowIndex += 2;
  16750. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16751. {
  16752. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16753. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16754. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16755. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16756. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16757. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16758. }
  16759. else
  16760. {
  16761. hideRowsList.Add(airRowIndex);
  16762. }
  16763. airRowIndex += 2;
  16764. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16765. {
  16766. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16767. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16768. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16769. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16770. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16771. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16772. }
  16773. else
  16774. {
  16775. hideRowsList.Add(airRowIndex);
  16776. }
  16777. airRowIndex += 2;
  16778. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16779. {
  16780. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16781. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16782. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16783. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16784. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16785. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16786. }
  16787. else
  16788. {
  16789. hideRowsList.Add(airRowIndex);
  16790. }
  16791. airRowIndex += 2;
  16792. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16793. {
  16794. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16795. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16796. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16797. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16798. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16799. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16800. }
  16801. else
  16802. {
  16803. hideRowsList.Add(airRowIndex);
  16804. }
  16805. airRowIndex += 2;
  16806. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16807. {
  16808. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16809. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16810. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16811. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16812. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16813. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16814. }
  16815. else
  16816. {
  16817. hideRowsList.Add(airRowIndex);
  16818. }
  16819. airRowIndex += 2;
  16820. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16821. {
  16822. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16823. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16824. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16825. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16826. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16827. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16828. }
  16829. else
  16830. {
  16831. hideRowsList.Add(airRowIndex);
  16832. }
  16833. airRowIndex += 2;
  16834. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16835. {
  16836. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16837. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16838. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16839. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16840. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16841. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16842. }
  16843. else
  16844. {
  16845. hideRowsList.Add(airRowIndex);
  16846. }
  16847. #endregion
  16848. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  16849. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  16850. var ws = designer.Workbook.Worksheets[0];
  16851. foreach (var Rowindex in hideRowsList)
  16852. {
  16853. ws.Cells.HideRows(Rowindex, 2);
  16854. }
  16855. designer.Process();
  16856. designer.Workbook.Save(savePaht);
  16857. return Ok(JsonView(true, "生成成功!", new
  16858. {
  16859. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16860. }));
  16861. }
  16862. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  16863. {
  16864. foreach (var roomType in roomTypes)
  16865. {
  16866. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16867. {
  16868. hotelRooms[roomType]--;
  16869. flights[flightType]--;
  16870. if (roomType == "TBR")
  16871. {
  16872. flights[flightType]--; // 双人间在减少1
  16873. }
  16874. string key = flightType + roomType;
  16875. if (result.Keys.Contains(key))
  16876. {
  16877. result[key]++;
  16878. }
  16879. else
  16880. {
  16881. result.Add(key, 1);
  16882. }
  16883. }
  16884. }
  16885. }
  16886. private class AirHotelPrice
  16887. {
  16888. public string Name { get; set; }
  16889. public decimal Price { get; set; }
  16890. public int Count { get; set; }
  16891. }
  16892. private class HotelSum
  16893. {
  16894. internal decimal SGR { get; set; }
  16895. internal decimal TBR { get; set; }
  16896. internal decimal JSES { get; set; }
  16897. internal decimal SUITE { get; set; }
  16898. internal decimal AllPrice {
  16899. get { return SGR + TBR + JSES + SUITE; }
  16900. }
  16901. }
  16902. [HttpPost]
  16903. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  16904. {
  16905. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16906. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16907. if (di == null)
  16908. {
  16909. return Ok(JsonView(false, "团组不存在!"));
  16910. }
  16911. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>()
  16912. .Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  16913. .ToList();
  16914. var groupHotelNumber = _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16915. .Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  16916. .ToList();
  16917. var groupHotelNumberDefault = groupHotelNumber.FirstOrDefault(x => x.Type == "Default");
  16918. HotelSum hotelSumP = new ();
  16919. if (groupCost.Any())
  16920. {
  16921. hotelSumP.SGR = groupHotelNumberDefault.SGR > 0 ? groupCost.Sum(x => x.SGR) * groupHotelNumberDefault.SGR : 0 ;
  16922. hotelSumP.TBR = groupHotelNumberDefault.TBR > 0 ? groupCost.Sum(x => x.TBR) * groupHotelNumberDefault.TBR : 0;
  16923. hotelSumP.JSES = groupHotelNumberDefault.JSES > 0 ? groupCost.Sum(x => x.JS_ES) * groupHotelNumberDefault.JSES : 0;
  16924. hotelSumP.SUITE = groupHotelNumberDefault.SUITE > 0 ? groupCost.Sum(x => x.Suite) * groupHotelNumberDefault.SUITE : 0;
  16925. }
  16926. #region 地接系数
  16927. Func<int, decimal> coefficientByDJ = (number) =>
  16928. {
  16929. if (number < 1) return 0.00M;
  16930. return number switch
  16931. {
  16932. < 6 => 2.5M,
  16933. 6 => 2.4M,
  16934. 7 => 1.8M,
  16935. 8 => 2.0M,
  16936. 9 => 3.0M,
  16937. 10 => 1.75M,
  16938. > 10 => 1.9M,
  16939. };
  16940. };
  16941. #endregion
  16942. #region 酒店系数
  16943. #endregion
  16944. return Ok(JsonView(true, "查询成功", new
  16945. {
  16946. HotelSum = hotelSumP,
  16947. CoefficientByDJ = coefficientByDJ(di.VisitPNumber) // 示例调用
  16948. }));
  16949. }
  16950. #endregion
  16951. #region 酒店预订 New 2023-12-28 17:45
  16952. /// <summary>
  16953. /// 酒店预订
  16954. /// 酒店费用列表 根据团组Id查询
  16955. /// </summary>
  16956. /// <param name="_dto"></param>
  16957. /// <returns></returns>
  16958. [HttpPost]
  16959. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16960. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  16961. {
  16962. #region 参数验证
  16963. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16964. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16965. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16966. #region 团组操作权限验证 76 酒店预定模块
  16967. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16968. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16969. #endregion
  16970. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16971. #region 页面操作权限验证
  16972. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16973. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16974. #endregion
  16975. #endregion
  16976. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  16977. }
  16978. /// <summary>
  16979. /// 酒店预订
  16980. /// 基础数据
  16981. /// </summary>
  16982. /// <param name="_dto"></param>
  16983. /// <returns></returns>
  16984. [HttpPost]
  16985. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16986. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  16987. {
  16988. #region 参数验证
  16989. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16990. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16991. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16992. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16993. #region 页面操作权限验证
  16994. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16995. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16996. #endregion
  16997. #region 团组操作权限验证 76 酒店预定模块
  16998. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16999. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17000. #endregion
  17001. #endregion
  17002. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  17003. }
  17004. /// <summary>
  17005. /// 酒店预订
  17006. /// 创建 入住卷号码
  17007. /// </summary>
  17008. /// <param name="_dto"></param>
  17009. /// <returns></returns>
  17010. [HttpPost]
  17011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17012. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  17013. {
  17014. #region 参数验证
  17015. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17016. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17017. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17018. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17019. #region 页面操作权限验证
  17020. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17021. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17022. #endregion
  17023. #region 团组操作权限验证 76 酒店预定模块
  17024. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17025. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17026. #endregion
  17027. #endregion
  17028. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  17029. if (data.Code != 0)
  17030. {
  17031. return Ok(JsonView(false, data.Msg));
  17032. }
  17033. return Ok(JsonView(true, data.Msg, data.Data));
  17034. }
  17035. /// <summary>
  17036. /// 酒店预订
  17037. /// 详情
  17038. /// </summary>
  17039. /// <param name="_dto"></param>
  17040. /// <returns></returns>
  17041. [HttpPost]
  17042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17043. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  17044. {
  17045. #region 参数验证
  17046. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  17047. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17048. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  17049. #region 团组操作权限验证 76 酒店预定模块
  17050. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17051. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17052. #endregion
  17053. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17054. #region 页面操作权限验证
  17055. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17056. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17057. #endregion
  17058. #endregion
  17059. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  17060. }
  17061. /// <summary>
  17062. /// 酒店预订
  17063. /// Add Or Edit
  17064. /// </summary>
  17065. /// <param name="_dto"></param>
  17066. /// <returns></returns>
  17067. [HttpPost]
  17068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17069. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  17070. {
  17071. #region 参数验证
  17072. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17073. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17074. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17075. #region 团组操作权限验证 76 酒店预定模块
  17076. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17077. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17078. #endregion
  17079. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17080. #region 页面操作权限验证
  17081. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17082. if (_dto.Id == 0) // Add
  17083. {
  17084. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17085. }
  17086. else if (_dto.Id > 1) // Edit
  17087. {
  17088. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17089. }
  17090. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  17091. #endregion
  17092. #endregion
  17093. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17094. if (_view.Code != 200)
  17095. {
  17096. return Ok(_view);
  17097. }
  17098. #region 成本无酒店价格数据进入超支
  17099. _sqlSugar.BeginTran();
  17100. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17101. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17102. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17103. for (int i = 0; i < groupCost.Count; i++)
  17104. {
  17105. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17106. {
  17107. groupCost[i].Date = groupCost[i - 1].Date;
  17108. }
  17109. }
  17110. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17111. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17112. List<Fin_GroupExtraCostDto_OP>();
  17113. if (start_Bool && end_Bool)
  17114. {
  17115. while (start_Time < end_Time)
  17116. {
  17117. foreach (var item in groupCost_Grp)
  17118. {
  17119. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17120. {
  17121. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17122. {
  17123. extraCostList.Add(new
  17124. Fin_GroupExtraCostDto_OP
  17125. {
  17126. Area = _dto.AreaId,
  17127. coefficient = 1.5M,
  17128. createUser = _dto.UserId,
  17129. currency = _dto.CardPriceCurrency,
  17130. diId = _dto.DiId,
  17131. ManagerConfirm = 0,
  17132. SupervisorConfirm = 0,
  17133. SYsupervisorConfirm = 0,
  17134. editType = 1,
  17135. PortType = 1,
  17136. price = _dto.CardPrice,
  17137. PriceCount = 1,
  17138. priceType = 1027,
  17139. priceDetailType = 1044,
  17140. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17141. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17142. });
  17143. }
  17144. }
  17145. }
  17146. start_Time = start_Time.AddDays(1);
  17147. }
  17148. }
  17149. if (extraCostList.Any())
  17150. {
  17151. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17152. }
  17153. _sqlSugar.CommitTran();
  17154. #endregion
  17155. #region 应用推送
  17156. try
  17157. {
  17158. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17159. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17160. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17161. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17162. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17163. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17164. var diId = _dto.DiId;
  17165. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17166. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17167. #region 操作记录
  17168. var opInfo = new Crm_TableOperationRecord()
  17169. {
  17170. TableName = "Grp_HotelReservations",
  17171. PortType = _dto.PortType,
  17172. DataId = hotelId,
  17173. CreateUserId = _dto.UserId
  17174. };
  17175. //var opStatus = OperationEnum.NoOperation;
  17176. if (_dto.Id < 1) //添加操作
  17177. {
  17178. opInfo.OperationItem = OperationEnum.Add;
  17179. }
  17180. else if (_dto.Id > 0)
  17181. {
  17182. opInfo.OperationItem = OperationEnum.Edit;
  17183. }
  17184. string opRemark = string.Empty;
  17185. if (ccpInfo != null)
  17186. {
  17187. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17188. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17189. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17190. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17191. }
  17192. opInfo.Remark = opRemark;
  17193. await _tableorRep.AddAsync(opInfo);
  17194. #endregion
  17195. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17196. //2024-10-21 新增LZ UID
  17197. var userIds = new List<int>() { 21 };
  17198. string title = $"费用审核";
  17199. string content = "";
  17200. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17201. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17202. try
  17203. {
  17204. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17205. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17206. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17207. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17208. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17209. }
  17210. catch (Exception ex)
  17211. {
  17212. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17213. }
  17214. }
  17215. catch (Exception ex)
  17216. {
  17217. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17218. }
  17219. try
  17220. {
  17221. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17222. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17223. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17224. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17225. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17226. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17227. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17228. //自动审核
  17229. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17230. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17231. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17232. //2024-10-21 新增LZ UID
  17233. var userIds = new List<int>() { 21 };
  17234. string title = $"系统通知";
  17235. var diId = _dto.DiId;
  17236. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17237. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17238. string content = "";
  17239. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17240. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17241. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17242. }
  17243. catch (Exception ex)
  17244. {
  17245. }
  17246. #endregion
  17247. return Ok(_view);
  17248. }
  17249. /// <summary>
  17250. /// 酒店自动审核测试
  17251. /// Add Or Edit
  17252. /// </summary>
  17253. /// <param name="diid"></param>
  17254. /// <param name="dataId"></param>
  17255. /// <returns></returns>
  17256. [HttpPost]
  17257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17258. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17259. {
  17260. #region 应用推送
  17261. try
  17262. {
  17263. //自动审核
  17264. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17265. }
  17266. catch (Exception ex)
  17267. {
  17268. return Ok(JsonView(false, ex.Message));
  17269. }
  17270. #endregion
  17271. return Ok(JsonView(false, "操作成功"));
  17272. }
  17273. /// <summary>
  17274. /// 酒店预订
  17275. /// Del
  17276. /// </summary>
  17277. /// <param name="_dto"></param>
  17278. /// <returns></returns>
  17279. [HttpPost]
  17280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17281. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17282. {
  17283. #region 参数验证
  17284. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17285. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17286. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17287. #region 团组操作权限验证 76 酒店预定模块
  17288. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17289. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17290. #endregion
  17291. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17292. #region 页面操作权限验证
  17293. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17294. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17295. #endregion
  17296. #endregion
  17297. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  17298. #region 操作记录
  17299. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17300. {
  17301. TableName = "Grp_HotelReservations",
  17302. PortType = _dto.PortType,
  17303. OperationItem = OperationEnum.Del,
  17304. DataId = _dto.Id,
  17305. CreateUserId = _dto.UserId
  17306. });
  17307. #endregion
  17308. return Ok(data);
  17309. }
  17310. /// <summary>
  17311. /// 酒店预订
  17312. /// 生成VOUCHER
  17313. /// 2024.05.06 之前版本
  17314. /// </summary>
  17315. /// <param name="_dto"></param>
  17316. /// <returns></returns>
  17317. [HttpPost]
  17318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17319. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  17320. {
  17321. try
  17322. {
  17323. #region 参数验证
  17324. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17325. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17326. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17327. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  17328. #region 团组操作权限验证 76 酒店预定模块
  17329. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17330. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17331. #endregion
  17332. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17333. #region 页面操作权限验证
  17334. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17335. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17336. #endregion
  17337. #endregion
  17338. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  17339. //判断数据是否完整
  17340. if (hr != null)
  17341. {
  17342. if (!string.IsNullOrEmpty(hr.DetermineNo))
  17343. {
  17344. string strFileName = "HotelStatement/";
  17345. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17346. if (dele != null)
  17347. strFileName += dele.TourCode;
  17348. //载入模板
  17349. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  17350. Document doc = new Document(sss);
  17351. DocumentBuilder builder = new DocumentBuilder(doc);
  17352. #region 替换Word模板书签内容
  17353. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  17354. //入住卷预定号码
  17355. if (doc.Range.Bookmarks["VNO"] != null)
  17356. {
  17357. Bookmark mark = doc.Range.Bookmarks["VNO"];
  17358. mark.Text = hr.CheckNumber;
  17359. }
  17360. //酒店时间
  17361. if (doc.Range.Bookmarks["Date"] != null)
  17362. {
  17363. Bookmark mark = doc.Range.Bookmarks["Date"];
  17364. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17365. }
  17366. //团号
  17367. if (doc.Range.Bookmarks["TNo"] != null)
  17368. {
  17369. Bookmark mark = doc.Range.Bookmarks["TNo"];
  17370. mark.Text = dele.TourCode;
  17371. }
  17372. //预定号码
  17373. if (doc.Range.Bookmarks["BookingId"] != null)
  17374. {
  17375. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  17376. mark.Text = hr.ReservationsNo;
  17377. }
  17378. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  17379. {
  17380. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  17381. mark.Text = hr.DetermineNo;
  17382. }
  17383. //酒店城市
  17384. if (doc.Range.Bookmarks["City"] != null)
  17385. {
  17386. Bookmark mark = doc.Range.Bookmarks["City"];
  17387. mark.Text = hr.City;
  17388. }
  17389. //酒店名称
  17390. if (doc.Range.Bookmarks["HName"] != null)
  17391. {
  17392. Bookmark mark = doc.Range.Bookmarks["HName"];
  17393. mark.Text = hr.HotelName;
  17394. }
  17395. //酒店地址
  17396. if (doc.Range.Bookmarks["Address"] != null)
  17397. {
  17398. Bookmark mark = doc.Range.Bookmarks["Address"];
  17399. mark.Text = hr.HotelAddress;
  17400. }
  17401. //酒店电话
  17402. if (doc.Range.Bookmarks["Tel"] != null)
  17403. {
  17404. Bookmark mark = doc.Range.Bookmarks["Tel"];
  17405. mark.Text = hr.HotelTel;
  17406. }
  17407. //酒店传真
  17408. if (doc.Range.Bookmarks["Fax"] != null)
  17409. {
  17410. Bookmark mark = doc.Range.Bookmarks["Fax"];
  17411. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17412. {
  17413. mark.Text = hr.HotelFax;
  17414. }
  17415. }
  17416. //入住时间
  17417. if (doc.Range.Bookmarks["CIn"] != null)
  17418. {
  17419. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17420. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17421. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17422. }
  17423. //退房时间
  17424. if (doc.Range.Bookmarks["COut"] != null)
  17425. {
  17426. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17427. Bookmark mark = doc.Range.Bookmarks["COut"];
  17428. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17429. }
  17430. //客户名称
  17431. if (doc.Range.Bookmarks["GName"] != null)
  17432. {
  17433. string guestName = "";
  17434. string[] clients = Array.Empty<string>();
  17435. if (hr.GuestName.Contains(","))
  17436. {
  17437. clients = hr.GuestName.Split(",");
  17438. }
  17439. else
  17440. {
  17441. clients = new string[] { hr.GuestName };
  17442. }
  17443. List<int> clientIds_int = new List<int>();
  17444. if (clients.Length > 0)
  17445. {
  17446. foreach (var item in clients)
  17447. {
  17448. if (item.IsNumeric())
  17449. {
  17450. clientIds_int.Add(int.Parse(item));
  17451. }
  17452. }
  17453. }
  17454. if (clientIds_int.Count > 0)
  17455. {
  17456. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  17457. foreach (var client in _clientDatas)
  17458. {
  17459. //男
  17460. if (client.Sex == 0) guestName += $"Mr.";
  17461. //女
  17462. else if (client.Sex == 1) guestName += $"Ms.";
  17463. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17464. {
  17465. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17466. }
  17467. //guestName += $"{client.Pinyin},";
  17468. }
  17469. if (guestName.Length > 0)
  17470. {
  17471. guestName = guestName.Substring(0, guestName.Length - 1);
  17472. }
  17473. }
  17474. else
  17475. {
  17476. guestName = hr.GuestName;
  17477. }
  17478. Bookmark mark = doc.Range.Bookmarks["GName"];
  17479. mark.Text = guestName;
  17480. }
  17481. //房间介绍
  17482. if (doc.Range.Bookmarks["ROOM"] != null)
  17483. {
  17484. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  17485. mark.Text = hr.RoomExplanation;
  17486. }
  17487. //报价描述
  17488. if (doc.Range.Bookmarks["NOTE"] != null)
  17489. {
  17490. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  17491. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  17492. if (ss != null)
  17493. mark.Text = ss.Name;
  17494. }
  17495. //入住时间
  17496. if (doc.Range.Bookmarks["CheckIn"] != null)
  17497. {
  17498. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17499. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  17500. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17501. }
  17502. //退房时间
  17503. if (doc.Range.Bookmarks["CheckOut"] != null)
  17504. {
  17505. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17506. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  17507. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17508. }
  17509. //日期
  17510. if (doc.Range.Bookmarks["DT"] != null)
  17511. {
  17512. Bookmark mark = doc.Range.Bookmarks["DT"];
  17513. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17514. }
  17515. //名称
  17516. if (doc.Range.Bookmarks["VName"] != null)
  17517. {
  17518. Bookmark mark = doc.Range.Bookmarks["VName"];
  17519. mark.Text = hr.HotelName;
  17520. }
  17521. //号码
  17522. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17523. {
  17524. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17525. mark.Text = hr.CheckNumber;
  17526. }
  17527. #endregion
  17528. strFileName += "VOUCHER.doc";
  17529. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17530. doc.Save(fileDir);
  17531. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17532. return Ok(JsonView(true, "操作成功!", Url));
  17533. }
  17534. else
  17535. {
  17536. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17537. }
  17538. }
  17539. else
  17540. {
  17541. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17542. }
  17543. }
  17544. catch (Exception ex)
  17545. {
  17546. return Ok(JsonView(false, ex.Message));
  17547. }
  17548. }
  17549. /// <summary>
  17550. /// 酒店预订
  17551. /// 生成VOUCHER
  17552. /// 2024.05.06 之后版本
  17553. /// </summary>
  17554. /// <param name="_dto"></param>
  17555. /// <returns></returns>
  17556. [HttpPost]
  17557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17558. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17559. {
  17560. #region 参数验证
  17561. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17562. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17563. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17564. #region 团组操作权限验证 76 酒店预定模块
  17565. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17566. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17567. #endregion
  17568. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17569. #region 页面操作权限验证
  17570. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17571. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17572. #endregion
  17573. #endregion
  17574. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17575. //判断数据是否完整
  17576. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17577. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17578. string strFileName = "HotelStatement/";
  17579. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17580. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17581. #region 数据处理
  17582. List<int> guestIds = new List<int>();
  17583. //int index = 0;
  17584. foreach (var item in hrDtas)
  17585. {
  17586. if (item.GuestName.Contains(","))
  17587. {
  17588. string[] guestIdArr = item.GuestName.Split(',');
  17589. foreach (var guestIdStr in guestIdArr)
  17590. {
  17591. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17592. if (guestBool)
  17593. {
  17594. guestIds.Add(guestId);
  17595. }
  17596. }
  17597. }
  17598. else guestNames += item.GuestName;
  17599. var voucherInfo = new HotelVoucherInfoView()
  17600. {
  17601. HotelName = item.HotelName,
  17602. CheckInDate = item.CheckInDate,
  17603. CheckOutDate = item.CheckOutDate,
  17604. ConfirmationNumber = item.DetermineNo.Trim(),
  17605. RoomType = item.RoomExplanation
  17606. };
  17607. vouchers.Add(voucherInfo);
  17608. }
  17609. if (guestIds.Count > 0)
  17610. {
  17611. guestIds = guestIds.Distinct().ToList();
  17612. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17613. if (guestDatas.Count > 0)
  17614. {
  17615. guestNames = "";
  17616. foreach (var guest in guestDatas)
  17617. {
  17618. string guestName = "";
  17619. if (guest.Sex == 0) guestName += @"MR.";
  17620. else if (guest.Sex == 1) guestName += @"MS.";
  17621. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17622. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17623. guestNames += @$"{guestName.Trim()}、";
  17624. }
  17625. if (guestNames.Length > 0)
  17626. {
  17627. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17628. }
  17629. }
  17630. }
  17631. #endregion
  17632. //载入模板
  17633. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17634. Document doc = new Document(sss);
  17635. DocumentBuilder builder = new DocumentBuilder(doc);
  17636. if (doc.Range.Bookmarks["GuestName"] != null)
  17637. {
  17638. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17639. mark.Text = guestNames;
  17640. }
  17641. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17642. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17643. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17644. for (int i = 1; i <= vouchers.Count; i++)
  17645. {
  17646. HotelVoucherInfoView hviv = vouchers[i - 1];
  17647. builder.MoveToCell(0, i, 0, 0);
  17648. builder.Write(hviv.HotelName);
  17649. builder.MoveToCell(0, i, 1, 0);
  17650. builder.Write(hviv.CheckInDate);
  17651. builder.MoveToCell(0, i, 2, 0);
  17652. builder.Write(hviv.CheckOutDate);
  17653. builder.MoveToCell(0, i, 3, 0);
  17654. builder.Write(hviv.RoomType);
  17655. builder.MoveToCell(0, i, 4, 0);
  17656. builder.Write(hviv.ConfirmationNumber);
  17657. }
  17658. //删除多余行
  17659. int currRowIndex = vouchers.Count + 1;
  17660. int delRows = 21 - currRowIndex;
  17661. if (delRows > 0)
  17662. {
  17663. for (int i = 0; i < delRows; i++)
  17664. {
  17665. table.Rows.RemoveAt(currRowIndex);
  17666. //cultivateRowIndex++;
  17667. }
  17668. }
  17669. strFileName += "VOUCHER.docx";
  17670. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17671. doc.Save(fileDir);
  17672. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17673. return Ok(JsonView(true, "操作成功!", Url));
  17674. }
  17675. /// <summary>
  17676. /// 酒店预订
  17677. /// 生成VOUCHER 批量生成
  17678. /// New
  17679. /// </summary>
  17680. /// <param name="_dto"></param>
  17681. /// <returns></returns>
  17682. [HttpPost]
  17683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17684. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17685. {
  17686. #region 参数验证
  17687. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17688. if (_dto.PageId < 1) _dto.PageId = 28;
  17689. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17690. #region 团组操作权限验证 76 酒店预定模块
  17691. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17692. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17693. #endregion
  17694. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17695. #region 页面操作权限验证
  17696. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17697. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17698. #endregion
  17699. #endregion
  17700. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17701. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17702. .OrderBy(x => x.CheckInDate)
  17703. .ToListAsync();
  17704. //判断数据是否完整
  17705. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17706. string strFileName = "HotelStatement/";
  17707. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17708. if (dele != null)
  17709. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17710. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17711. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17712. .Where(it => it.IsDel == 0)
  17713. .ToListAsync();
  17714. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17715. for (int i = 0; i < hrDtas.Count; i++)
  17716. {
  17717. string guestNames = string.Empty;
  17718. List<int> guestIds = new List<int>();
  17719. var item = hrDtas[i];
  17720. //处理客户姓名
  17721. if (item.GuestName.Contains(","))
  17722. {
  17723. string[] guestIdArr = item.GuestName.Split(',');
  17724. foreach (var guestIdStr in guestIdArr)
  17725. if (int.TryParse(guestIdStr, out int guestId))
  17726. guestIds.Add(guestId);
  17727. }
  17728. else
  17729. {
  17730. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17731. if (guestIdBool)
  17732. {
  17733. guestIds.Add(guestId);
  17734. }
  17735. //NaN
  17736. if (item.GuestName.Contains("NaN"))
  17737. {
  17738. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17739. }
  17740. }
  17741. if (guestIds.Count > 0)
  17742. {
  17743. guestIds = guestIds.Distinct().ToList();
  17744. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17745. if (guestDatas1.Count > 0)
  17746. {
  17747. guestNames = "";
  17748. foreach (var guest in guestDatas1)
  17749. {
  17750. string guestName = "";
  17751. if (guest.Sex == 0) guestName += @"MR.";
  17752. else if (guest.Sex == 1) guestName += @"MS.";
  17753. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17754. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17755. guestNames += @$"{guestName.Trim()}、";
  17756. }
  17757. if (guestNames.Length > 0)
  17758. {
  17759. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17760. }
  17761. }
  17762. }
  17763. //if (!string.IsNullOrEmpty(guestNames))
  17764. //{
  17765. hrDtas[i].GuestName = guestNames;
  17766. //}
  17767. }
  17768. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17769. Document doc = new Document();
  17770. DocumentBuilder builder = new DocumentBuilder(doc);
  17771. try
  17772. {
  17773. builder.MoveToDocumentStart();
  17774. foreach (var item in hrDtas)
  17775. {
  17776. //标题
  17777. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17778. builder.ParagraphFormat.LineSpacing = 1;
  17779. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17780. builder.ParagraphFormat.Style.Font.Size = 9;
  17781. builder.ParagraphFormat.Style.Font.Bold = true;
  17782. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17783. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17784. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17785. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17786. builder.ParagraphFormat.LineSpacing = 1;
  17787. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17788. builder.ParagraphFormat.Style.Font.Size = 9;
  17789. builder.ParagraphFormat.Style.Font.Bold = true;
  17790. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17791. builder.StartTable();
  17792. // 设置边框颜色
  17793. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17794. //设置边框样式
  17795. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17796. //表格
  17797. #region 第一行
  17798. builder.InsertCell();
  17799. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17800. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17801. //builder.CellFormat.AllowAutoFit = false;
  17802. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17803. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17804. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17805. builder.CellFormat.WrapText = true; //自动换行
  17806. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17807. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17808. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17809. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17810. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17811. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17812. builder.Write("TOUR NO:");
  17813. builder.InsertCell();
  17814. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17815. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17816. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17817. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17818. builder.ParagraphFormat.Style.Font.Bold = false;
  17819. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17820. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17821. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17822. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17823. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17824. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17825. builder.Write($"{dele?.TourCode ?? "-"}");
  17826. builder.InsertCell();
  17827. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17828. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17829. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17830. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17831. builder.ParagraphFormat.Style.Font.Bold = false;
  17832. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17833. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17834. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17835. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17836. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17837. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17838. builder.Write($"CITY:");
  17839. builder.InsertCell();
  17840. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17841. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17842. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17843. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17844. builder.ParagraphFormat.Style.Font.Bold = false;
  17845. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17846. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17847. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17848. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17849. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17850. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17851. builder.Write($"{item.City}");
  17852. builder.EndRow();
  17853. #endregion
  17854. #region 第二行
  17855. builder.InsertCell();
  17856. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17857. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17858. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17859. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17860. builder.ParagraphFormat.Style.Font.Bold = false;
  17861. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17862. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17863. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17864. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17865. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17866. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17867. builder.Write("CONFIRMATION NO:");
  17868. builder.InsertCell();
  17869. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17870. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17871. builder.ParagraphFormat.Style.Font.Size = 8;
  17872. builder.ParagraphFormat.Style.Font.Bold = false;
  17873. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17874. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17875. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17876. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17877. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17878. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17879. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17880. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17881. builder.Write($"{item.DetermineNo}");
  17882. builder.InsertCell();
  17883. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17884. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17885. builder.InsertCell();
  17886. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17887. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17888. builder.EndRow();
  17889. #endregion
  17890. #region 第三行
  17891. builder.InsertCell();
  17892. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17893. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17894. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17895. builder.ParagraphFormat.Style.Font.Bold = false;
  17896. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17897. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17898. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17899. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17900. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17901. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17902. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17903. builder.Write($"HOTEL NAME:");
  17904. builder.InsertCell();
  17905. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17906. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17907. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17908. builder.ParagraphFormat.Style.Font.Bold = false;
  17909. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17910. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17911. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17912. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17913. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17914. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17915. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17916. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17917. builder.Write($"{item.HotelName}");
  17918. builder.InsertCell();
  17919. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17920. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17921. builder.InsertCell();
  17922. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17923. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17924. builder.EndRow();
  17925. #endregion
  17926. #region 第四行
  17927. builder.InsertCell();
  17928. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17929. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17930. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17931. builder.ParagraphFormat.Style.Font.Bold = false;
  17932. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17933. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17934. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17935. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17936. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17937. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17938. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17939. builder.Write($"HOTEL ADDRESS:");
  17940. builder.InsertCell();
  17941. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17942. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17943. builder.ParagraphFormat.Style.Font.Size = 8;
  17944. builder.ParagraphFormat.Style.Font.Bold = false;
  17945. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17946. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17947. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17948. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17949. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17950. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17951. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17952. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17953. builder.Write($"{item.HotelAddress}");
  17954. builder.InsertCell();
  17955. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17956. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17957. builder.InsertCell();
  17958. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17959. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17960. builder.EndRow();
  17961. #endregion
  17962. #region 第五行
  17963. builder.InsertCell();
  17964. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17965. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17966. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17967. builder.ParagraphFormat.Style.Font.Bold = false;
  17968. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17969. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17970. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17971. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17972. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17973. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17974. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17975. builder.Write("TEL:");
  17976. builder.InsertCell();
  17977. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17978. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17979. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17980. builder.ParagraphFormat.Style.Font.Bold = false;
  17981. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17982. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17983. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17984. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17985. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17986. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17987. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17988. builder.Write($"{item.HotelTel}");
  17989. builder.InsertCell();
  17990. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17991. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17992. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17993. builder.ParagraphFormat.Style.Font.Bold = false;
  17994. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17995. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17996. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17997. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17998. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17999. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18000. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18001. builder.Write($"FAX:");
  18002. builder.InsertCell();
  18003. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18004. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18005. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18006. builder.ParagraphFormat.Style.Font.Bold = false;
  18007. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18008. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18009. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18010. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18011. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18012. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18013. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18014. builder.Write($"{item.HotelFax}");
  18015. builder.EndRow();
  18016. #endregion
  18017. #region 第六行
  18018. builder.InsertCell();
  18019. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18020. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18021. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18022. builder.ParagraphFormat.Style.Font.Bold = false;
  18023. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18024. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18025. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18026. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18027. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18028. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18029. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18030. builder.Write("CHECK IN:");
  18031. builder.InsertCell();
  18032. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18033. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18034. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18035. builder.ParagraphFormat.Style.Font.Bold = false;
  18036. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18037. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18038. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18039. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18040. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18041. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18042. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18043. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  18044. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18045. builder.Write($"{checkInStr}");
  18046. builder.InsertCell();
  18047. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18048. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18049. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18050. builder.ParagraphFormat.Style.Font.Bold = false;
  18051. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18052. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18053. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18054. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18055. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18056. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18057. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18058. builder.Write($"CHECK OUT:");
  18059. builder.InsertCell();
  18060. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18061. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18062. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18063. builder.ParagraphFormat.Style.Font.Bold = false;
  18064. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18065. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18066. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18067. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18068. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18069. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18070. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18071. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  18072. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  18073. builder.Write($"{checkOutStr}");
  18074. builder.EndRow();
  18075. #endregion
  18076. #region 第七行
  18077. builder.InsertCell();
  18078. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18079. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18080. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18081. builder.ParagraphFormat.Style.Font.Bold = false;
  18082. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18083. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18084. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18085. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18086. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18087. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18088. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18089. builder.Write($"GUEST NAME:");
  18090. builder.InsertCell();
  18091. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18092. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18093. builder.ParagraphFormat.Style.Font.Size = 8;
  18094. builder.ParagraphFormat.Style.Font.Bold = false;
  18095. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18096. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18097. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18098. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18099. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18100. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18101. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18102. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18103. builder.Write($"{item.GuestName.Trim()}");
  18104. builder.InsertCell();
  18105. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18106. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18107. builder.InsertCell();
  18108. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18109. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18110. builder.EndRow();
  18111. #endregion
  18112. #region 第八行
  18113. builder.InsertCell();
  18114. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18115. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18116. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18117. builder.ParagraphFormat.Style.Font.Bold = false;
  18118. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18119. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18120. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18121. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18122. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18123. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18124. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18125. builder.Write($"ROOM TYPE:");
  18126. builder.InsertCell();
  18127. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18128. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18129. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18130. builder.ParagraphFormat.Style.Font.Bold = false;
  18131. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18132. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18133. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18134. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18135. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18136. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18137. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18138. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18139. builder.Write($"{item.RoomExplanation}");
  18140. builder.InsertCell();
  18141. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18142. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18143. builder.InsertCell();
  18144. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18145. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18146. builder.EndRow();
  18147. #endregion
  18148. #region 第九行
  18149. builder.InsertCell();
  18150. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18151. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18152. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18153. builder.ParagraphFormat.Style.Font.Bold = false;
  18154. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18155. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18156. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18157. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18158. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18159. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18160. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18161. builder.Write($"NOTE:");
  18162. builder.InsertCell();
  18163. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18164. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18165. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18166. builder.ParagraphFormat.Style.Font.Bold = false;
  18167. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18168. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18169. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18170. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18171. 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.");
  18172. builder.InsertCell();
  18173. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18174. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18175. builder.InsertCell();
  18176. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18177. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18178. builder.EndRow();
  18179. #endregion
  18180. builder.EndTable();
  18181. //换行
  18182. builder.Writeln("");
  18183. builder.Writeln("");
  18184. }
  18185. #region 获取文档中的所有表格 设置文字自适应
  18186. // 获取文档中的所有表格。
  18187. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18188. {
  18189. // 遍历表格中的所有行。
  18190. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18191. {
  18192. foreach (Cell cell in row.Cells)
  18193. {
  18194. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18195. cellFormat.Width = 0;
  18196. }
  18197. }
  18198. }
  18199. #endregion
  18200. #region 设置页眉
  18201. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18202. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18203. if (System.IO.File.Exists(voucherHeaderPath))
  18204. {
  18205. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18206. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18207. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18208. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18209. // 调整图片位置
  18210. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18211. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18212. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18213. shape.Left = 0; // 将图片距离页面左边缘的距离
  18214. shape.Width = 81; // 设置图片宽度
  18215. shape.Height = 36; // 设置图片高度
  18216. }
  18217. //靠右
  18218. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18219. //// 设置页脚上下边距
  18220. //builder.PageSetup.HeaderDistance = 42;
  18221. // 添加页眉线
  18222. Aspose.Words.Border borderHeader = null;
  18223. try
  18224. {
  18225. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18226. }
  18227. catch (Exception e)
  18228. {
  18229. // TODO Auto-generated catch block
  18230. //e.printStackTrace();
  18231. }
  18232. borderHeader.Shadow = true;
  18233. borderHeader.DistanceFromText = 2;
  18234. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18235. #endregion
  18236. }
  18237. catch (Exception ex)
  18238. {
  18239. }
  18240. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18241. doc.Save(fileDir);
  18242. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18243. return Ok(JsonView(true, "操作成功!", Url));
  18244. }
  18245. /// <summary>
  18246. /// 酒店预订
  18247. /// 生成 预定成本 Excel
  18248. /// </summary>
  18249. /// <param name="_dto"></param>
  18250. /// <returns></returns>
  18251. [HttpPost]
  18252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18253. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18254. {
  18255. #region 参数验证
  18256. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18257. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18258. if (!vadalitorRes.IsValid)
  18259. {
  18260. var errors = new StringBuilder();
  18261. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18262. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18263. }
  18264. #region 团组操作权限验证 76 酒店预定模块
  18265. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18266. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18267. #endregion
  18268. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18269. #region 页面操作权限验证
  18270. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18271. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18272. #endregion
  18273. #endregion
  18274. decimal _rate = 1.00M;
  18275. string _currency = string.Empty;
  18276. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18277. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18278. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18279. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18280. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18281. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18282. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18283. if (_GroupCostParameter == null)
  18284. {
  18285. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18286. bool isIntType = int.TryParse(_currency, out int currId);
  18287. if (isIntType)
  18288. {
  18289. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18290. }
  18291. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18292. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18293. if (currInfo == null)
  18294. {
  18295. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18296. }
  18297. else _rate = currInfo.Rate;
  18298. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18299. {
  18300. _rate = _GroupCostParameter.Rate;
  18301. }
  18302. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18303. //string strFileName = "HotelStatement/";
  18304. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18305. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18306. var rateDatas = new List<dynamic>();
  18307. #region 数据处理
  18308. foreach (var item in hrDtas)
  18309. {
  18310. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18311. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18312. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18313. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18314. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18315. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  18316. {
  18317. continue;
  18318. }
  18319. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18320. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  18321. string singleRoomFeeStr = string.Empty,
  18322. doubleRoomFeeStr = string.Empty,
  18323. suiteRoomFeeStr = string.Empty,
  18324. otherRoomFeeStr = string.Empty,
  18325. payMoneyStr = string.Empty,
  18326. cardPriceStr = string.Empty;
  18327. if (roomCurr.Equals("CNY"))
  18328. {
  18329. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  18330. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18331. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18332. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18333. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18334. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  18335. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  18336. }
  18337. else
  18338. {
  18339. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18340. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18341. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18342. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18343. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18344. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18345. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18346. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18347. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18348. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18349. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  18350. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  18351. if (ccpPaymentCurrency.Equals("CNY"))
  18352. {
  18353. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  18354. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18355. }
  18356. else
  18357. {
  18358. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  18359. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  18360. }
  18361. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  18362. if (hotelcardPriceCurrency.Equals("CNY"))
  18363. {
  18364. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18365. }
  18366. else
  18367. {
  18368. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  18369. }
  18370. }
  18371. string breakfastPriceStr = string.Empty,
  18372. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18373. governmentRentStr = string.Empty,
  18374. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18375. cityTaxStr = string.Empty,
  18376. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18377. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  18378. if (!string.IsNullOrEmpty(breakfastCurrency1))
  18379. {
  18380. if (breakfastCurrency1.Equals("CNY"))
  18381. {
  18382. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18383. }
  18384. else
  18385. {
  18386. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  18387. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  18388. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  18389. }
  18390. }
  18391. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18392. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  18393. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  18394. {
  18395. if (governmentRentCurrency.Equals("CNY"))
  18396. {
  18397. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18398. }
  18399. else
  18400. {
  18401. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  18402. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  18403. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  18404. }
  18405. }
  18406. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18407. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  18408. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  18409. {
  18410. if (cityTaxStrCurrency1.Equals("CNY"))
  18411. {
  18412. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18413. }
  18414. else
  18415. {
  18416. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18417. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18418. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18419. }
  18420. }
  18421. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18422. int payDId = roomInfo?.PayDId ?? 0;
  18423. pcfds.Add(new HotelReservations_PCFD_View()
  18424. {
  18425. City = item.City,
  18426. HotelName = item.HotelName,
  18427. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18428. // SingleRoomCount = item.SingleRoomCount,
  18429. SingleRoomPrice = singleRoomFeeStr,
  18430. // DoubleRoomCount = item.DoubleRoomCount,
  18431. DoubleRoomPrice = doubleRoomFeeStr,
  18432. //SuiteRoomCount = item.SuiteRoomCount,
  18433. SuiteRoomPrice = suiteRoomFeeStr,
  18434. OtherRoomPrice = otherRoomFeeStr,
  18435. //OtherRoomCount = item.OtherRoomCount,
  18436. BreakfastPrice = breakfastPriceStr,
  18437. GovernmentRent = governmentRentStr,
  18438. CityTax = cityTaxStr,
  18439. RoomExplanation = item.RoomExplanation,
  18440. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18441. PayTime = roomInfo?.ConsumptionDate,
  18442. BankNo = roomInfo?.BankNo,
  18443. PayMoney = payMoneyStr,
  18444. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18445. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18446. CardPrice = cardPriceStr,
  18447. Remark = ccpInfo.Remark
  18448. });
  18449. }
  18450. #endregion
  18451. //载入模板
  18452. WorkbookDesigner designer = new WorkbookDesigner();
  18453. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18454. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18455. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18456. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18457. var rateDatas1 = rateDatas.Distinct();
  18458. var rateStr = string.Empty;
  18459. foreach (var item in rateDatas1)
  18460. {
  18461. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18462. }
  18463. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18464. designer.SetDataSource("Opertor", userInfo.CnName);
  18465. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18466. dt.TableName = "ViewMyHotelReservations";
  18467. designer.SetDataSource(dt);
  18468. designer.Process();
  18469. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18470. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18471. designer.Workbook.Save(serverPath);
  18472. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18473. #region 删除指定行
  18474. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18475. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18476. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18477. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18478. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18479. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18480. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18481. cssIndex = dt.Columns["CityTax"].Ordinal,
  18482. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18483. remarkIndex = dt.Columns["Remark"].Ordinal;
  18484. //删除指定列
  18485. foreach (DataRow item in dt.Rows)
  18486. {
  18487. string singleStr = item["SingleRoomPrice"].ToString();
  18488. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18489. if (containsDigitButNotZero1) singleDel = false;
  18490. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18491. string doubleStr = item["DoubleRoomPrice"].ToString();
  18492. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18493. if (containsDigitButNotZero2) doubleDel = false;
  18494. string suiteStr = item["SuiteRoomPrice"].ToString();
  18495. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18496. if (containsDigitButNotZero3) suiteDel = false;
  18497. string otherStr = item["OtherRoomPrice"].ToString();
  18498. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18499. if (containsDigitButNotZero4) otherDel = false;
  18500. string zcStr = item["BreakfastPrice"].ToString();
  18501. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18502. if (containsDigitButNotZero5) zcDel = false;
  18503. string dsStr = item["GovernmentRent"].ToString();
  18504. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18505. if (containsDigitButNotZero6) dsDel = false;
  18506. string cssStr = item["CityTax"].ToString();
  18507. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18508. if (containsDigitButNotZero7) cssDel = false;
  18509. string cpStr = item["ConsumptionPatterns"].ToString();
  18510. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18511. string remarkStr = item["Remark"].ToString();
  18512. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18513. }
  18514. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18515. DeleteColumn(serverPath, cpIndex, cpDel);
  18516. DeleteColumn(serverPath, dsIndex, dsDel);
  18517. DeleteColumn(serverPath, cssIndex, cssDel);
  18518. DeleteColumn(serverPath, zcIndex, zcDel);
  18519. DeleteColumn(serverPath, otherIndex, otherDel);
  18520. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18521. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18522. DeleteColumn(serverPath, singleIndex, singleDel);
  18523. #endregion
  18524. //只保留第一个表格
  18525. DeleteSheet(serverPath);
  18526. return Ok(JsonView(true, "操作成功", url = rst));
  18527. }
  18528. else
  18529. {
  18530. _currency = _GroupCostParameter.Currency;
  18531. bool isIntType = int.TryParse(_currency, out int currId);
  18532. if (isIntType)
  18533. {
  18534. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18535. }
  18536. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18537. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18538. if (currInfo == null)
  18539. {
  18540. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18541. }
  18542. if (!_currency.ToUpper().Equals("CNY"))
  18543. {
  18544. _rate = _GroupCostParameter.Rate;
  18545. }
  18546. _rate = currInfo.Rate;
  18547. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18548. //string strFileName = "HotelStatement/";
  18549. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18550. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18551. #region 数据处理
  18552. foreach (var item in hrDtas)
  18553. {
  18554. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18555. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18556. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18557. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18558. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18559. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18560. string singleRoomFeeStr = string.Empty,
  18561. doubleRoomFeeStr = string.Empty,
  18562. suiteRoomFeeStr = string.Empty,
  18563. otherRoomFeeStr = string.Empty,
  18564. payMoneyStr = string.Empty,
  18565. cardPriceStr = string.Empty;
  18566. if (roomCurr.Equals(_currency))
  18567. {
  18568. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18569. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18570. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18571. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18572. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18573. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18574. }
  18575. else
  18576. {
  18577. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18578. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18579. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18580. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18581. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18582. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18583. }
  18584. string breakfastPriceStr = string.Empty,
  18585. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18586. governmentRentStr = string.Empty,
  18587. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18588. cityTaxStrStr = string.Empty,
  18589. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18590. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18591. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18592. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18593. int payDId = roomInfo?.PayDId ?? 0;
  18594. pcfds.Add(new HotelReservations_PCFD_View()
  18595. {
  18596. City = item.City,
  18597. HotelName = item.HotelName,
  18598. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18599. // SingleRoomCount = item.SingleRoomCount,
  18600. SingleRoomPrice = singleRoomFeeStr,
  18601. // DoubleRoomCount = item.DoubleRoomCount,
  18602. DoubleRoomPrice = doubleRoomFeeStr,
  18603. //SuiteRoomCount = item.SuiteRoomCount,
  18604. SuiteRoomPrice = suiteRoomFeeStr,
  18605. OtherRoomPrice = otherRoomFeeStr,
  18606. //OtherRoomCount = item.OtherRoomCount,
  18607. BreakfastPrice = breakfastPriceStr,
  18608. GovernmentRent = governmentRentStr,
  18609. CityTax = cityTaxStrStr,
  18610. RoomExplanation = item.RoomExplanation,
  18611. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18612. PayTime = roomInfo?.ConsumptionDate,
  18613. BankNo = roomInfo?.BankNo,
  18614. PayMoney = payMoneyStr,
  18615. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18616. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18617. CardPrice = cardPriceStr,
  18618. Remark = ccpInfo.Remark
  18619. });
  18620. }
  18621. #endregion
  18622. //载入模板
  18623. WorkbookDesigner designer = new WorkbookDesigner();
  18624. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18625. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18626. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18627. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18628. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18629. designer.SetDataSource("Opertor", userInfo.CnName);
  18630. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18631. dt.TableName = "ViewMyHotelReservations";
  18632. designer.SetDataSource(dt);
  18633. designer.Process();
  18634. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18635. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18636. designer.Workbook.Save(serverPath);
  18637. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18638. #region 删除指定行
  18639. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18640. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18641. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18642. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18643. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18644. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18645. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18646. cssIndex = dt.Columns["CityTax"].Ordinal,
  18647. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18648. remarkIndex = dt.Columns["Remark"].Ordinal;
  18649. //删除指定列
  18650. foreach (DataRow item in dt.Rows)
  18651. {
  18652. string singleStr = item["SingleRoomPrice"].ToString();
  18653. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18654. if (containsDigitButNotZero1) singleDel = false;
  18655. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18656. string doubleStr = item["DoubleRoomPrice"].ToString();
  18657. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18658. if (containsDigitButNotZero2) doubleDel = false;
  18659. string suiteStr = item["SuiteRoomPrice"].ToString();
  18660. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18661. if (containsDigitButNotZero3) suiteDel = false;
  18662. string otherStr = item["OtherRoomPrice"].ToString();
  18663. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18664. if (containsDigitButNotZero4) otherDel = false;
  18665. string zcStr = item["BreakfastPrice"].ToString();
  18666. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18667. if (containsDigitButNotZero5) zcDel = false;
  18668. string dsStr = item["GovernmentRent"].ToString();
  18669. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18670. if (containsDigitButNotZero6) dsDel = false;
  18671. string cssStr = item["CityTax"].ToString();
  18672. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18673. if (containsDigitButNotZero7) cssDel = false;
  18674. string cpStr = item["ConsumptionPatterns"].ToString();
  18675. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18676. string remarkStr = item["Remark"].ToString();
  18677. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18678. }
  18679. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18680. DeleteColumn(serverPath, cpIndex, cpDel);
  18681. DeleteColumn(serverPath, dsIndex, dsDel);
  18682. DeleteColumn(serverPath, cssIndex, cssDel);
  18683. DeleteColumn(serverPath, zcIndex, zcDel);
  18684. DeleteColumn(serverPath, otherIndex, otherDel);
  18685. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18686. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18687. DeleteColumn(serverPath, singleIndex, singleDel);
  18688. #endregion
  18689. //只保留第一个表格
  18690. DeleteSheet(serverPath);
  18691. return Ok(JsonView(true, "操作成功", url = rst));
  18692. }
  18693. //return Ok(JsonView(false));
  18694. }
  18695. /// <summary>
  18696. /// 删除指定列
  18697. /// </summary>
  18698. /// <param name="file"></param>
  18699. /// <param name="columnIndex"></param>
  18700. /// <param name="isDel"></param>
  18701. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18702. {
  18703. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18704. //wb.Save(file);
  18705. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18706. if (sheet1 != null)
  18707. {
  18708. if (isDel)
  18709. {
  18710. Cells cells = sheet1.Cells;
  18711. cells.DeleteColumn(columnIndex);
  18712. }
  18713. }
  18714. wb.Save(file);
  18715. }
  18716. /// <summary>
  18717. /// 删除sheet
  18718. /// </summary>
  18719. /// <param name="file"></param>
  18720. private void DeleteSheet(string file)
  18721. {
  18722. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18723. //wb.Save(file);
  18724. List<string> sheets = new List<string>();
  18725. foreach (var item in wb.Worksheets)
  18726. {
  18727. sheets.Add(item.Name);
  18728. }
  18729. if (sheets.Count > 0)
  18730. {
  18731. sheets.RemoveAt(0);//不删除第一个sheet
  18732. foreach (var item in sheets)
  18733. {
  18734. wb.Worksheets.RemoveAt(item);
  18735. }
  18736. }
  18737. wb.Save(file);
  18738. }
  18739. /// <summary>
  18740. /// 酒店预订
  18741. /// 确认单
  18742. /// </summary>
  18743. /// <param name="_dto"></param>
  18744. /// <returns></returns>
  18745. [HttpPost]
  18746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18747. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18748. {
  18749. try
  18750. {
  18751. #region 参数验证
  18752. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18753. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18754. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18755. #region 团组操作权限验证 76 酒店预定模块
  18756. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18757. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18758. #endregion
  18759. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18760. #region 页面操作权限验证
  18761. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18762. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18763. #endregion
  18764. #endregion
  18765. //团组信息
  18766. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18767. //酒店数据
  18768. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18769. if (listhoteldata.Count < 0)
  18770. {
  18771. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18772. }
  18773. //利datatable存储
  18774. DataTable dt = new DataTable();
  18775. dt.Columns.Add("CheckInDate", typeof(string));
  18776. dt.Columns.Add("City", typeof(string));
  18777. dt.Columns.Add("Hotel", typeof(string));
  18778. dt.Columns.Add("Room", typeof(string));
  18779. for (int i = 0; i < listhoteldata.Count; i++)
  18780. {
  18781. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18782. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18783. while (dayStart < dayEnd)
  18784. {
  18785. string temp = "";
  18786. DataRow row = dt.NewRow();
  18787. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18788. row["City"] = listhoteldata[i].City;
  18789. row["Hotel"] = listhoteldata[i].HotelName;
  18790. if (listhoteldata[i].SingleRoomCount > 0)
  18791. {
  18792. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18793. }
  18794. if (listhoteldata[i].DoubleRoomCount > 0)
  18795. {
  18796. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18797. }
  18798. if (listhoteldata[i].SuiteRoomCount > 0)
  18799. {
  18800. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18801. }
  18802. if (listhoteldata[i].OtherRoomCount > 0)
  18803. {
  18804. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18805. }
  18806. row["Room"] = temp;
  18807. dt.Rows.Add(row);
  18808. dayStart = dayStart.AddDays(1);
  18809. }
  18810. }
  18811. Dictionary<string, string> dic = new Dictionary<string, string>();
  18812. dic.Add("Dele", di.TeamName);
  18813. dic.Add("City", di.VisitCountry);
  18814. //模板路径
  18815. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18816. //载入模板
  18817. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18818. DocumentBuilder builder = new DocumentBuilder(doc);
  18819. foreach (var key in dic.Keys)
  18820. {
  18821. builder.MoveToBookmark(key);
  18822. builder.Write(dic[key]);
  18823. }
  18824. //获取word里所有表格
  18825. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18826. //获取所填表格的序数
  18827. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18828. var rowStart = tableOne.Rows[0]; //获取第1行
  18829. //循环赋值
  18830. for (int i = 0; i < dt.Rows.Count; i++)
  18831. {
  18832. builder.MoveToCell(0, i + 1, 0, 0);
  18833. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18834. builder.MoveToCell(0, i + 1, 1, 0);
  18835. builder.Write(dt.Rows[i]["City"].ToString());
  18836. builder.MoveToCell(0, i + 1, 2, 0);
  18837. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18838. builder.MoveToCell(0, i + 1, 3, 0);
  18839. builder.Write(dt.Rows[i]["Room"].ToString());
  18840. }
  18841. //删除多余行
  18842. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18843. {
  18844. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18845. }
  18846. string strFileName = di.TeamName + "酒店确认单.doc";
  18847. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18848. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18849. return Ok(JsonView(true, "成功", url));
  18850. }
  18851. catch (Exception ex)
  18852. {
  18853. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18854. }
  18855. }
  18856. #endregion
  18857. #region 团组状态
  18858. /// <summary>
  18859. /// 团组状态列表 Page
  18860. /// </summary>
  18861. /// <param name="dto">团组列表请求dto</param>
  18862. /// <returns></returns>
  18863. [HttpPost]
  18864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18865. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18866. {
  18867. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18868. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18869. {
  18870. string sqlWhere = string.Empty;
  18871. if (dto.IsSure == 0) //未完成
  18872. {
  18873. sqlWhere += string.Format(@" And IsSure = 0");
  18874. }
  18875. else if (dto.IsSure == 1) //已完成
  18876. {
  18877. sqlWhere += string.Format(@" And IsSure = 1");
  18878. }
  18879. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18880. {
  18881. string tj = dto.SearchCriteria;
  18882. 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}%')",
  18883. tj, tj, tj, tj, tj);
  18884. }
  18885. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  18886. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  18887. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  18888. From (
  18889. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  18890. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  18891. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  18892. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  18893. From Grp_DelegationInfo gdi
  18894. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  18895. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  18896. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  18897. Where gdi.IsDel = 0 {0}
  18898. ) temp ", sqlWhere);
  18899. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  18900. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  18901. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  18902. }
  18903. else
  18904. {
  18905. return Ok(JsonView(false, "查询失败"));
  18906. }
  18907. }
  18908. /// <summary>
  18909. /// 团组状态
  18910. /// 设置操作完成
  18911. /// </summary>
  18912. /// <param name="dto">团组列表请求dto</param>
  18913. /// <returns></returns>
  18914. [HttpPost]
  18915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18916. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  18917. {
  18918. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18919. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  18920. {
  18921. Id = dto.Id,
  18922. IsSure = 1
  18923. };
  18924. var result = await _sqlSugar.Updateable(_DelegationInfo)
  18925. .UpdateColumns(it => new { it.IsSure })
  18926. .WhereColumns(it => new { it.Id })
  18927. .ExecuteCommandAsync();
  18928. if (result > 0)
  18929. {
  18930. return Ok(JsonView(true, "操作完成!"));
  18931. }
  18932. return Ok(JsonView(false, "操作失败!"));
  18933. }
  18934. #endregion
  18935. #region 保险费用录入
  18936. /// <summary>
  18937. /// 根据团组Id查询保险费用列表
  18938. /// </summary>
  18939. /// <param name="dto"></param>
  18940. /// <returns></returns>
  18941. [HttpPost]
  18942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18943. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  18944. {
  18945. Result groupData = await _customersRep.CustomersByDiId(dto);
  18946. if (groupData.Code != 0)
  18947. {
  18948. return Ok(JsonView(false, groupData.Msg));
  18949. }
  18950. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18951. }
  18952. /// <summary>
  18953. /// 根据保险费用Id查询保险费用详细
  18954. /// </summary>
  18955. /// <param name="dto"></param>
  18956. /// <returns></returns>
  18957. [HttpPost]
  18958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18959. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  18960. {
  18961. try
  18962. {
  18963. Result groupData = await _customersRep.CustomersById(dto);
  18964. if (groupData.Code != 0)
  18965. {
  18966. return Ok(JsonView(false, groupData.Msg));
  18967. }
  18968. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18969. }
  18970. catch (Exception ex)
  18971. {
  18972. return Ok(JsonView(false, ex.Message));
  18973. }
  18974. }
  18975. /// <summary>
  18976. /// 保险费用录入页面初始化绑定
  18977. /// </summary>
  18978. /// <param name="dto"></param>
  18979. /// <returns></returns>
  18980. [HttpPost]
  18981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18982. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  18983. {
  18984. try
  18985. {
  18986. Result groupData = await _customersRep.CustomersInitialize(dto);
  18987. if (groupData.Code != 0)
  18988. {
  18989. return Ok(JsonView(false, groupData.Msg));
  18990. }
  18991. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18992. }
  18993. catch (Exception ex)
  18994. {
  18995. return Ok(JsonView(false, ex.Message));
  18996. }
  18997. }
  18998. /// <summary>
  18999. /// 保险费用操作(Status:1.新增,2.修改)
  19000. /// </summary>
  19001. /// <param name="dto"></param>
  19002. /// <returns></returns>
  19003. [HttpPost]
  19004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19005. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  19006. {
  19007. Result groupData = await _customersRep.OpCustomers(dto);
  19008. if (groupData.Code != 0)
  19009. {
  19010. return Ok(JsonView(false, groupData.Msg));
  19011. }
  19012. #region 应用推送
  19013. try
  19014. {
  19015. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  19016. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  19017. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  19018. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19019. //自动审核
  19020. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  19021. //2024-10-21 新增LZ UID
  19022. var userIds = new List<int>() { 21 };
  19023. string title = $"系统通知";
  19024. var diId = dto.DiId;
  19025. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19026. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19027. string content = "";
  19028. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19029. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19030. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19031. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  19032. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  19033. }
  19034. catch (Exception ex)
  19035. {
  19036. }
  19037. #endregion
  19038. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19039. }
  19040. /// <summary>
  19041. /// 保险文件上传
  19042. /// </summary>
  19043. /// <param name="file"></param>
  19044. /// <returns></returns>
  19045. [HttpPost]
  19046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19047. public async Task<IActionResult> UploadCus(IFormFile file)
  19048. {
  19049. try
  19050. {
  19051. if (file != null)
  19052. {
  19053. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19054. //文件名称
  19055. string projectFileName = file.FileName;
  19056. //上传的文件的路径
  19057. string filePath = "";
  19058. if (!Directory.Exists(fileDir))
  19059. {
  19060. Directory.CreateDirectory(fileDir);
  19061. }
  19062. //上传的文件的路径
  19063. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  19064. using (FileStream fs = System.IO.File.Create(filePath))
  19065. {
  19066. file.CopyTo(fs);
  19067. fs.Flush();
  19068. }
  19069. return Ok(JsonView(true, "上传成功!", projectFileName));
  19070. }
  19071. else
  19072. {
  19073. return Ok(JsonView(false, "上传失败!"));
  19074. }
  19075. }
  19076. catch (Exception ex)
  19077. {
  19078. return Ok(JsonView(false, ex.Message));
  19079. }
  19080. }
  19081. /// <summary>
  19082. /// 保险删除指定文件
  19083. /// </summary>
  19084. /// <param name="dto"></param>
  19085. /// <returns></returns>
  19086. [HttpPost]
  19087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19088. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  19089. {
  19090. try
  19091. {
  19092. string filePath = "";
  19093. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19094. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19095. //int id = 0;
  19096. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19097. // 删除该文件
  19098. try
  19099. {
  19100. System.IO.File.Delete(filePath);
  19101. 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()
  19102. {
  19103. Attachment = "",
  19104. }).ExecuteCommandAsync();
  19105. if (result != 0)
  19106. {
  19107. return Ok(JsonView(true, "成功!"));
  19108. }
  19109. else
  19110. {
  19111. return Ok(JsonView(false, "失败!"));
  19112. }
  19113. }
  19114. catch (Exception)
  19115. {
  19116. 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()
  19117. {
  19118. Attachment = "",
  19119. }).ExecuteCommandAsync();
  19120. if (result != 0)
  19121. {
  19122. return Ok(JsonView(true, "成功!"));
  19123. }
  19124. else
  19125. {
  19126. return Ok(JsonView(false, "失败!"));
  19127. }
  19128. }
  19129. }
  19130. catch (Exception ex)
  19131. {
  19132. return Ok(JsonView(false, "程序错误!"));
  19133. throw;
  19134. }
  19135. }
  19136. /// <summary>
  19137. /// 保险费用操作(删除)
  19138. /// </summary>
  19139. /// <param name="dto"></param>
  19140. /// <returns></returns>
  19141. [HttpPost]
  19142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19143. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19144. {
  19145. try
  19146. {
  19147. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19148. if (!res)
  19149. {
  19150. return Ok(JsonView(false, "删除失败"));
  19151. }
  19152. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19153. {
  19154. IsDel = 1,
  19155. DeleteUserId = dto.DeleteUserId,
  19156. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19157. }).ExecuteCommandAsync();
  19158. return Ok(JsonView(true, "删除成功!"));
  19159. }
  19160. catch (Exception ex)
  19161. {
  19162. return Ok(JsonView(false, "程序错误!"));
  19163. throw;
  19164. }
  19165. }
  19166. #endregion
  19167. #region 接团客户名单 PageId 104
  19168. /// <summary>
  19169. /// 接团客户名单
  19170. /// 迁移数据(慎用!)
  19171. /// </summary>
  19172. /// <returns></returns>
  19173. [HttpPost]
  19174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19175. public async Task<IActionResult> PostTourClientListChange()
  19176. {
  19177. try
  19178. {
  19179. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19180. //var groupClinetData1
  19181. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19182. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19183. int updateCount = 0;
  19184. if (oldOAClientList.Count > 0)
  19185. {
  19186. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19187. _sqlSugar.BeginTran();
  19188. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19189. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19190. foreach (var item in oldOAClientList)
  19191. {
  19192. int comId = 0;
  19193. string format = "yyyy-MM-dd HH:mm:ss";
  19194. string data11 = "1990-01-01 00:00";
  19195. var data1 = IsValidDate(item.OPdate, format);
  19196. if (data1) data11 = item.OPdate;
  19197. //客户公司验证
  19198. if (!string.IsNullOrEmpty(item.Company))
  19199. {
  19200. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19201. if (clientComInfo == null) // add
  19202. {
  19203. var addInfo = new Crm_CustomerCompany()
  19204. {
  19205. CompanyAbbreviation = "",
  19206. CompanyFullName = item.Company,
  19207. Address = "",
  19208. PostCodes = "",
  19209. LastedOpUserId = item.OPer,
  19210. LastedOpDt = Convert.ToDateTime(data11),
  19211. CreateUserId = item.OPer,
  19212. CreateTime = Convert.ToDateTime(data11),
  19213. IsDel = 0
  19214. };
  19215. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19216. if (comId1 > 0) comId = comId1;
  19217. }
  19218. else comId = clientComInfo.Id;
  19219. }
  19220. //客户人员验证
  19221. int clientId = 0;
  19222. string name = item.LastName + item.Name;
  19223. if (!string.IsNullOrEmpty(name))
  19224. {
  19225. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19226. if (clientInfo == null)
  19227. {
  19228. DateTime? dateTime = null;
  19229. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19230. if (isDt) dateTime = birthDayDt;
  19231. var addInfo1 = new Crm_DeleClient()
  19232. {
  19233. CrmCompanyId = comId,
  19234. DiId = -1,
  19235. LastName = item.LastName,
  19236. FirstName = item.Name,
  19237. OldName = "",
  19238. Pinyin = item.Pinyin,
  19239. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19240. Marriage = 0,
  19241. Phone = item.Phone,
  19242. Job = item.Job,
  19243. BirthDay = dateTime
  19244. };
  19245. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19246. if (clientId1 > 0) clientId = clientId1;
  19247. }
  19248. else clientId = clientInfo.Id;
  19249. }
  19250. if (clientId < 1)
  19251. {
  19252. continue;
  19253. }
  19254. int airType = 0;
  19255. if (item.AirType == "超经舱") airType = 459;
  19256. else if (item.AirType == "公务舱") airType = 458;
  19257. else if (item.AirType == "经济舱") airType = 460;
  19258. else if (item.AirType == "其他") airType = 565;
  19259. else if (item.AirType == "头等舱") airType = 457;
  19260. var _TourClientListEntity = new Grp_TourClientList()
  19261. {
  19262. DiId = item.Diid,
  19263. ClientId = clientId,
  19264. CreateUserId = item.OPer,
  19265. CreateTime = Convert.ToDateTime(data11),
  19266. Remark = item.Remark,
  19267. IsDel = item.Isdel,
  19268. ShippingSpaceTypeId = airType,
  19269. ShippingSpaceSpecialNeeds = item.AirRemark,
  19270. HotelSpecialNeeds = item.RoomType
  19271. };
  19272. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19273. if (_TourClientList > 0)
  19274. {
  19275. updateCount++;
  19276. }
  19277. }
  19278. _sqlSugar.CommitTran();
  19279. }
  19280. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19281. }
  19282. catch (Exception ex)
  19283. {
  19284. _sqlSugar.RollbackTran();
  19285. return Ok(JsonView(false, ex.Message));
  19286. }
  19287. //return Ok(JsonView(true));
  19288. }
  19289. private bool IsValidDate(string dateString, string format)
  19290. {
  19291. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  19292. }
  19293. /// <summary>
  19294. /// 接团客户名单
  19295. /// 根据团组Id查询List
  19296. /// </summary>
  19297. /// <param name="_dto"></param>
  19298. /// <returns></returns>
  19299. [HttpPost]
  19300. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19301. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  19302. {
  19303. #region 参数验证
  19304. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  19305. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  19306. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  19307. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19308. #region 页面操作权限验证
  19309. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19310. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19311. #endregion
  19312. #endregion
  19313. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  19314. if (viewData.Code != 0)
  19315. {
  19316. return Ok(JsonView(false, viewData.Msg));
  19317. }
  19318. return Ok(JsonView(viewData.Data));
  19319. }
  19320. /// <summary>
  19321. /// 接团客户名单
  19322. /// 基础数据 Init
  19323. /// </summary>
  19324. /// <param name="_dto"></param>
  19325. /// <returns></returns>
  19326. [HttpPost]
  19327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19328. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  19329. {
  19330. #region 参数验证
  19331. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19332. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19333. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19334. #region 页面操作权限验证
  19335. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19336. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19337. #endregion
  19338. #endregion
  19339. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  19340. }
  19341. /// <summary>
  19342. /// 接团客户名单
  19343. /// 根据 Id查询 Details
  19344. /// </summary>
  19345. /// <param name="_dto"></param>
  19346. /// <returns></returns>
  19347. [HttpPost]
  19348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19349. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  19350. {
  19351. #region 参数验证
  19352. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19353. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19354. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19355. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19356. #region 页面操作权限验证
  19357. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19358. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19359. #endregion
  19360. #endregion
  19361. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  19362. if (viewData.Code != 0)
  19363. {
  19364. return Ok(JsonView(false, viewData.Msg));
  19365. }
  19366. return Ok(JsonView(viewData.Data));
  19367. }
  19368. /// <summary>
  19369. /// 接团客户名单
  19370. /// Add Or Edit
  19371. /// </summary>
  19372. /// <param name="_dto"></param>
  19373. /// <returns></returns>
  19374. [HttpPost]
  19375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19376. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  19377. {
  19378. #region 参数验证
  19379. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19380. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19381. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19382. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19383. #region 页面操作权限验证
  19384. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19385. if (_dto.Id == 0) //添加
  19386. {
  19387. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19388. }
  19389. else if (_dto.Id >= 0) //修改
  19390. {
  19391. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  19392. }
  19393. #endregion
  19394. #endregion
  19395. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  19396. if (viewData.Code != 0)
  19397. {
  19398. return Ok(JsonView(false, viewData.Msg));
  19399. }
  19400. return Ok(JsonView(true));
  19401. }
  19402. /// <summary>
  19403. /// 接团客户名单
  19404. /// json字符串 AddMultiple(添加多个)
  19405. /// </summary>
  19406. /// <param name="_dto"></param>
  19407. /// <returns></returns>
  19408. [HttpPost]
  19409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19410. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19411. {
  19412. #region 参数验证
  19413. string jsonLabel = _dto.JsonLabel;
  19414. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19415. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19416. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19417. #region 页面操作权限验证
  19418. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19419. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19420. #endregion
  19421. #endregion
  19422. var request = new TourClientListAddMultipleDto();
  19423. request.DiId = _dto.DiId;
  19424. request.UserId = _dto.UserId;
  19425. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19426. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19427. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19428. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19429. var infos = new List<TourClientListInfo>();
  19430. foreach (var data in datas)
  19431. {
  19432. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19433. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19434. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19435. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19436. {
  19437. continue;
  19438. }
  19439. infos.Add(new TourClientListInfo()
  19440. {
  19441. IsAccompany = 1,
  19442. LastName = lastName,
  19443. FirstName = firstName,
  19444. Pinyin = lastNameEn + @"/" + firstNameEn,
  19445. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  19446. CompanyFullName = data.CompanyFullName,
  19447. Job = data.Job
  19448. });
  19449. }
  19450. if (infos.Any())
  19451. {
  19452. var viewData = await _tourClientListRep._AddMultiple(request);
  19453. if (viewData.Code != 0)
  19454. {
  19455. return Ok(JsonView(false, viewData.Msg));
  19456. }
  19457. return Ok(JsonView(true));
  19458. }
  19459. return Ok(JsonView(false));
  19460. }
  19461. /// <summary>
  19462. /// 接团客户名单
  19463. /// AddMultiple(添加多个)
  19464. /// </summary>
  19465. /// <param name="_dto"></param>
  19466. /// <returns></returns>
  19467. [HttpPost]
  19468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19469. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19470. {
  19471. #region 参数验证
  19472. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19473. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19474. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19475. #region 页面操作权限验证
  19476. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19477. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19478. #endregion
  19479. #endregion
  19480. var viewData = await _tourClientListRep._AddMultiple(_dto);
  19481. if (viewData.Code != 0)
  19482. {
  19483. return Ok(JsonView(false, viewData.Msg));
  19484. }
  19485. return Ok(JsonView(true));
  19486. }
  19487. /// <summary>
  19488. /// 接团客户名单
  19489. /// Del
  19490. /// </summary>
  19491. /// <param name="_dto"></param>
  19492. /// <returns></returns>
  19493. [HttpPost]
  19494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19495. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  19496. {
  19497. #region 参数验证
  19498. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19499. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19500. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19501. #region 页面操作权限验证
  19502. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19503. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19504. #endregion
  19505. #endregion
  19506. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19507. if (viewData.Code != 0)
  19508. {
  19509. return Ok(JsonView(false, viewData.Msg));
  19510. }
  19511. return Ok(JsonView(true));
  19512. }
  19513. /// <summary>
  19514. /// 接团客户名单
  19515. /// 文件下载 客户名单
  19516. /// </summary>
  19517. /// <param name="_dto"></param>
  19518. /// <returns></returns>
  19519. [HttpPost]
  19520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19521. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19522. {
  19523. #region 参数验证
  19524. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19525. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19526. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19527. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19528. #region 页面操作权限验证
  19529. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19530. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19531. #endregion
  19532. #endregion
  19533. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19534. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19535. From Grp_TourClientList tcl
  19536. Left Join
  19537. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19538. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19539. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19540. From Crm_DeleClient dc
  19541. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19542. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19543. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19544. Where dc.IsDel = 0) temp
  19545. On temp.DcId =tcl.ClientId
  19546. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19547. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19548. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19549. //载入模板
  19550. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19551. if (_dto.Language == 1)
  19552. {
  19553. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19554. }
  19555. //载入模板
  19556. var doc = new Document(tempPath);
  19557. DocumentBuilder builder = new DocumentBuilder(doc);
  19558. //获取word里所有表格
  19559. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19560. //获取所填表格的序数
  19561. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19562. var rowStart = tableOne.Rows[0]; //获取第1行
  19563. if (_dto.Language == 0)
  19564. {
  19565. //循环赋值
  19566. for (int i = 0; i < DcList.Count; i++)
  19567. {
  19568. EncryptionProcessor.DecryptProperties(DcList[i]);
  19569. builder.MoveToCell(0, i + 1, 0, 0);
  19570. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19571. builder.MoveToCell(0, i + 1, 1, 0);
  19572. int sex = DcList[i].Sex;
  19573. string sexStr = string.Empty;
  19574. if (sex == 0) sexStr = "男";
  19575. else if (sex == 1) sexStr = "女";
  19576. else sexStr = "未设置";
  19577. builder.Write(sexStr);
  19578. builder.MoveToCell(0, i + 1, 2, 0);
  19579. string birthDay = DcList[i].BirthDay;
  19580. string birthDayStr = string.Empty;
  19581. if (!string.IsNullOrEmpty(birthDay))
  19582. {
  19583. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19584. }
  19585. builder.Write(birthDayStr);
  19586. builder.MoveToCell(0, i + 1, 3, 0);
  19587. string company = "";
  19588. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19589. {
  19590. company = DcList[i].CompanyFullName.ToString();
  19591. }
  19592. builder.Write(company);
  19593. builder.MoveToCell(0, i + 1, 4, 0);
  19594. builder.Write(DcList[i].Job);
  19595. }
  19596. }
  19597. else if (_dto.Language == 1)
  19598. {
  19599. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19600. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19601. List<string> transArrayStr = new List<string>();
  19602. string transStrRes1 = "";
  19603. for (int i = 0; i < DcList.Count; i++)
  19604. {
  19605. var dc = DcList[i];
  19606. EncryptionProcessor.DecryptProperties(dc);
  19607. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19608. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19609. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19610. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19611. else transStrRes1 += $"{str1}|";
  19612. }
  19613. #region AI转英文
  19614. string jsonValue = JsonConvert.SerializeObject(DcList);
  19615. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  19616. List<SeedMessages> messages = new List<SeedMessages>()
  19617. {
  19618. new SeedMessages
  19619. {
  19620. Role = KimiRole.user,
  19621. Content = jsonValue + text
  19622. }
  19623. };
  19624. KiMiApiClient client = new KiMiApiClient();
  19625. var kimiApiResult = await client.SeedMessage(messages);
  19626. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19627. string clients = kimiApiResult_JObject["content"].ToString();
  19628. string startStr = "```json", endStr = "```";
  19629. // 判断并清除开头部分
  19630. if (clients.StartsWith(startStr))
  19631. {
  19632. clients = clients.Remove(0, startStr.Length);
  19633. }
  19634. // 判断并清除结尾部分
  19635. if (clients.EndsWith(endStr))
  19636. {
  19637. clients = clients.Remove(clients.Length - endStr.Length);
  19638. }
  19639. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  19640. //循环赋值
  19641. for (int i = 0; i < en_Json.Count; i++)
  19642. {
  19643. var dc = en_Json[i];
  19644. var dc1 = DcList.Find(x => x.Id == dc.Id);
  19645. string PYName = dc.FirstName + " " + dc.LastName;
  19646. builder.MoveToCell(0, i + 1, 0, 0);
  19647. builder.Write(PYName);
  19648. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  19649. builder.MoveToCell(0, i + 1, 1, 0);
  19650. builder.Write(sex);
  19651. DateTime birthDt;
  19652. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  19653. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19654. builder.MoveToCell(0, i + 1, 2, 0);
  19655. builder.Write(birthday);
  19656. string company = string.Empty, job = string.Empty;
  19657. company = dc.CompanyFullName;
  19658. job = dc.Job;
  19659. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  19660. {
  19661. //查询对照表
  19662. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  19663. if (tempCec != null)
  19664. {
  19665. company = tempCec.enName;
  19666. }
  19667. }
  19668. builder.MoveToCell(0, i + 1, 3, 0);
  19669. builder.Write(company);
  19670. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  19671. {
  19672. //查询对照表
  19673. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  19674. if (tempPec != null)
  19675. {
  19676. job = tempPec.enName;
  19677. }
  19678. }
  19679. builder.MoveToCell(0, i + 1, 4, 0);
  19680. builder.Write(job);
  19681. }
  19682. #endregion
  19683. #region 旧翻译英文处理
  19684. ////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";
  19685. //string transStrRes = "";
  19686. //if (transStrRes1.Length > 0)
  19687. //{
  19688. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19689. //}
  19690. ////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
  19691. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19692. ////List<string> transArray = new List<string> { };
  19693. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  19694. //if (transStrRes.Contains("|"))
  19695. //{
  19696. // string[] transArray1 = transStrRes.Split('|');
  19697. // if (transArray1.Length > 0)
  19698. // {
  19699. // foreach (var item in transArray1)
  19700. // {
  19701. // if (item.Contains("&"))
  19702. // {
  19703. // string[] transArray2 = item.Split('&');
  19704. // int index = 0;
  19705. // string companyName = "", job = "";
  19706. // if (transArray2.Length > 0)
  19707. // {
  19708. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  19709. // if (1 < transArray2.Length) companyName = transArray2[1];
  19710. // if (2 < transArray2.Length) job = transArray2[2];
  19711. // }
  19712. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19713. // }
  19714. // }
  19715. // }
  19716. //}
  19717. ////循环赋值
  19718. //for (int i = 0; i < DcList.Count; i++)
  19719. //{
  19720. // string PYName = "";
  19721. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19722. // {
  19723. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19724. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  19725. // PYName = PY_First + " " + PY_Last;
  19726. // }
  19727. // else
  19728. // {
  19729. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19730. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19731. // PYName = PY_First + " " + PY_Last;
  19732. // }
  19733. // builder.MoveToCell(0, i + 1, 0, 0);
  19734. // builder.Write(PYName);
  19735. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19736. // builder.MoveToCell(0, i + 1, 1, 0);
  19737. // builder.Write(sex);
  19738. // DateTime birthDt;
  19739. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19740. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19741. // builder.MoveToCell(0, i + 1, 2, 0);
  19742. // builder.Write(birthday);
  19743. // string company = string.Empty, job = string.Empty;
  19744. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19745. // if (dcTransInfo != null)
  19746. // {
  19747. // company = dcTransInfo.CompanyName;
  19748. // job = dcTransInfo.Job;
  19749. // }
  19750. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19751. // {
  19752. // //查询对照表
  19753. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19754. // if (tempCec != null)
  19755. // {
  19756. // company = tempCec.enName;
  19757. // }
  19758. // //翻译
  19759. // else
  19760. // {
  19761. // }
  19762. // }
  19763. // builder.MoveToCell(0, i + 1, 3, 0);
  19764. // builder.Write(company);
  19765. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19766. // {
  19767. // //查询对照表
  19768. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19769. // if (tempPec != null)
  19770. // {
  19771. // job = tempPec.enName;
  19772. // }
  19773. // //翻译
  19774. // else
  19775. // {
  19776. // }
  19777. // }
  19778. // builder.MoveToCell(0, i + 1, 4, 0);
  19779. // builder.Write(job);
  19780. //}
  19781. #endregion
  19782. }
  19783. //删除多余行
  19784. while (tableOne.Rows.Count > DcList.Count + 1)
  19785. {
  19786. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19787. }
  19788. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19789. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19790. doc.Save(fileDir);
  19791. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19792. return Ok(JsonView(true, "操作成功!", Url));
  19793. }
  19794. private class TranslateInfo
  19795. {
  19796. public int Index { get; set; }
  19797. public string CompanyName { get; set; }
  19798. public string Job { get; set; }
  19799. }
  19800. [HttpPost]
  19801. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19802. {
  19803. if (files.Count == 0)
  19804. {
  19805. return Ok(JsonView(false, "文件为空"));
  19806. }
  19807. KiMiApiClient KiMiApi = new KiMiApiClient();
  19808. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19809. if (seedConter.Count == 0)
  19810. {
  19811. return Ok(JsonView(false, "上传结果为空!"));
  19812. }
  19813. var messages = new List<SeedMessages>
  19814. {
  19815. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19816. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19817. };
  19818. messages.InsertRange(1, seedConter);
  19819. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19820. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19821. string clients = kimiApiResult_JObject["content"].ToString();
  19822. string startStr = "```json", endStr = "```";
  19823. // 判断并清除开头部分
  19824. if (clients.StartsWith(startStr))
  19825. {
  19826. clients = clients.Remove(0, startStr.Length);
  19827. }
  19828. // 判断并清除结尾部分
  19829. if (clients.EndsWith(endStr))
  19830. {
  19831. clients = clients.Remove(clients.Length - endStr.Length);
  19832. }
  19833. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19834. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19835. {
  19836. {"姓", "LastName" },
  19837. {"名", "FirstName" },
  19838. {"姓名拼音", "Pinyin" },
  19839. {"性别", "Sex" },
  19840. {"单位", "CompanyFullName" },
  19841. {"职务", "Job" },
  19842. {"出生日期", "Birthday" },
  19843. };
  19844. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19845. foreach (var item in clients_JObject)
  19846. {
  19847. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19848. foreach (var field in clientFieldMap.Keys)
  19849. {
  19850. if (item.TryGetValue(field, out JToken value))
  19851. {
  19852. var getValue = value.ToString();
  19853. System.Type type = cdc.GetType();
  19854. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19855. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19856. propertyInfo.SetValue(cdc, propertyValue);
  19857. }
  19858. }
  19859. crmClients.Add(cdc);
  19860. }
  19861. return Ok(JsonView(new
  19862. {
  19863. fileCount = files.Count,
  19864. UploadCount = seedConter.Count,
  19865. ApiResult = clients,
  19866. CrmClients = crmClients
  19867. }));
  19868. }
  19869. #endregion
  19870. #region 团组倒推表
  19871. /// <summary>
  19872. /// 倒推表基础数据
  19873. /// Init
  19874. /// </summary>
  19875. /// <returns></returns>
  19876. [HttpPost]
  19877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19878. public async Task<IActionResult> PostInvertedListInit()
  19879. {
  19880. var viewData = await _invertedListRep._Init();
  19881. if (viewData.Code != 0)
  19882. {
  19883. return Ok(JsonView(false, viewData.Msg));
  19884. }
  19885. return Ok(JsonView(viewData.Data));
  19886. }
  19887. /// <summary>
  19888. /// 倒推表
  19889. /// Info
  19890. /// </summary>
  19891. /// <param name="dto"></param>
  19892. /// <returns></returns>
  19893. [HttpPost]
  19894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19895. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  19896. {
  19897. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  19898. if (viewData.Code != 0)
  19899. {
  19900. return Ok(JsonView(false, viewData.Msg));
  19901. }
  19902. return Ok(JsonView(viewData.Data));
  19903. }
  19904. /// <summary>
  19905. /// 倒推表
  19906. /// Create
  19907. /// </summary>
  19908. /// <param name="dto"></param>
  19909. /// <returns></returns>
  19910. [HttpPost]
  19911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19912. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  19913. {
  19914. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  19915. if (viewData.Code != 0)
  19916. {
  19917. return Ok(JsonView(false, viewData.Msg));
  19918. }
  19919. return Ok(JsonView(viewData.Data));
  19920. }
  19921. /// <summary>
  19922. /// 倒推表
  19923. /// Update
  19924. /// </summary>
  19925. /// <param name="dto"></param>
  19926. /// <returns></returns>
  19927. [HttpPost]
  19928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19929. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  19930. {
  19931. var viewData = await _invertedListRep._Update(dto);
  19932. if (viewData.Code != 0)
  19933. {
  19934. return Ok(JsonView(false, viewData.Msg));
  19935. }
  19936. return Ok(JsonView(viewData.Data));
  19937. }
  19938. /// <summary>
  19939. /// 倒推表
  19940. /// File Download
  19941. /// </summary>
  19942. /// <param name="dto"></param>
  19943. /// <returns></returns>
  19944. [HttpPost]
  19945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19946. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  19947. {
  19948. var info2 = await _invertedListRep._Info(1, dto.DiId);
  19949. if (info2.Code != 0)
  19950. {
  19951. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  19952. }
  19953. var info1 = info2.Data as InvertedListInfoView;
  19954. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  19955. string teamName = "";
  19956. if (info != null) teamName = info.TeamName;
  19957. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  19958. var doc = new Document();
  19959. var builder = new DocumentBuilder(doc);
  19960. #region old insert
  19961. ////载入模板
  19962. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  19963. //Document doc = new Document(tempPath);
  19964. //DocumentBuilder builder = new DocumentBuilder(doc);
  19965. //利用键值对存放数据
  19966. //Dictionary<string, string> dic = new Dictionary<string, string>();
  19967. //dic.Add("TeamName", teamName);
  19968. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  19969. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  19970. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  19971. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  19972. //dic.Add("SQRemark", info1.ApprovalRemark);
  19973. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  19974. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  19975. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  19976. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  19977. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  19978. //dic.Add("QZRemark", info1.VisaInformationRemark);
  19979. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  19980. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  19981. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  19982. //dic.Add("CQRemark", info1.IssueVisaRemark);
  19983. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  19984. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  19985. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  19986. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  19987. //#region 填充word模板书签内容
  19988. //foreach (var key in dic.Keys)
  19989. //{
  19990. // builder.MoveToBookmark(key);
  19991. // builder.Write(dic[key]);
  19992. //}
  19993. //#endregion
  19994. #endregion
  19995. #region New Insert
  19996. string titleFont = $"仿宋",
  19997. contentFont = $"仿宋";
  19998. var fontColor = Color.FromArgb(64, 64, 64);
  19999. //设置标题 团组名称
  20000. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20001. builder.Font.Name = titleFont;
  20002. builder.Font.Color = fontColor;
  20003. builder.Font.Size = 12;
  20004. builder.Font.Bold = true;
  20005. builder.Writeln(teamName);
  20006. //设置副标题 团组出访时间
  20007. builder.Font.Size = 12;
  20008. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  20009. builder.Writeln();
  20010. var backgroundColor = Color.FromArgb(199, 199, 199);
  20011. var table = builder.StartTable();
  20012. builder.InsertCell();
  20013. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  20014. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  20015. builder.CellFormat.Borders.LineWidth = 1;
  20016. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  20017. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  20018. builder.RowFormat.Height = 40;
  20019. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20020. builder.Font.Name = contentFont;
  20021. builder.Font.Size = 12;
  20022. builder.Font.Bold = true;
  20023. builder.Font.Color = fontColor;
  20024. builder.Write("时间");
  20025. builder.InsertCell();
  20026. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  20027. builder.Write("流程");
  20028. builder.InsertCell();
  20029. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  20030. builder.Write("说明");
  20031. builder.EndRow();
  20032. //报批资料准备
  20033. if (info1.IsSelectedAirportd)
  20034. {
  20035. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  20036. }
  20037. //报批/提供送签资料
  20038. if (info1.IsSelectedApprovalData)
  20039. {
  20040. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  20041. }
  20042. //出批件护照办理
  20043. if (info1.IsSelectedIssueApproval)
  20044. {
  20045. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  20046. }
  20047. //签证资料准备
  20048. if (info1.IsSelectedVisaInfo)
  20049. {
  20050. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  20051. }
  20052. //送签
  20053. if (info1.IsSelectedSendVisa)
  20054. {
  20055. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  20056. }
  20057. //出签
  20058. if (info1.IsSelectedIssueVisa)
  20059. {
  20060. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  20061. }
  20062. //机票
  20063. if (info1.IsSelectedAirTicket)
  20064. {
  20065. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  20066. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  20067. }
  20068. //酒店
  20069. if (info1.IsSelectedHotel)
  20070. {
  20071. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  20072. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  20073. }
  20074. //开行前会
  20075. if (info1.IsSelectedPreTripMeeting)
  20076. {
  20077. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  20078. }
  20079. //送机
  20080. if (info1.IsSelectedAirportdDropOff)
  20081. {
  20082. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  20083. }
  20084. builder.EndTable();
  20085. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  20086. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  20087. for (int i = 0; i < table.Rows.Count; i++)
  20088. {
  20089. var row = table.Rows[i];
  20090. //设置宽度
  20091. row.Cells[0].CellFormat.Width = 20.00;
  20092. row.Cells[1].CellFormat.Width = 30.00;
  20093. row.Cells[2].CellFormat.Width = 50.00;
  20094. if (i != 0)
  20095. {
  20096. //边框设置
  20097. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20098. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20099. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20100. }
  20101. }
  20102. #region 页脚插入图片
  20103. // 创建页脚
  20104. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20105. doc.FirstSection.HeadersFooters.Add(footer);
  20106. Paragraph para = new Paragraph(doc);
  20107. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20108. footer.AppendChild(para);
  20109. builder.MoveTo(para);
  20110. string imagePath = "./Images/FMGJ_Log.png";
  20111. builder.InsertImage(imagePath);
  20112. #endregion
  20113. #endregion
  20114. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20115. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20116. string filePath = fileDir + $@"InvertedList/{fileName}";
  20117. doc.Save(filePath);
  20118. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20119. return Ok(JsonView(true, "操作成功!", Url));
  20120. }
  20121. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20122. {
  20123. var fontColor = Color.FromArgb(64, 64, 64);
  20124. builder.InsertCell();
  20125. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20126. builder.RowFormat.Height = 40;
  20127. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20128. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20129. builder.Font.Name = fontName;
  20130. builder.Font.Size = 8;
  20131. builder.Font.Bold = true;
  20132. builder.Font.Color = fontColor;
  20133. builder.Write(dateTime);
  20134. builder.InsertCell();
  20135. builder.Font.Size = 9;
  20136. builder.Font.Bold = true;
  20137. builder.Font.Color = fontColor;
  20138. builder.Write(content);
  20139. builder.InsertCell();
  20140. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20141. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20142. builder.Font.Size = 9;
  20143. builder.Font.Bold = false;
  20144. builder.Font.Color = fontColor;
  20145. builder.Write(reamrk);
  20146. builder.EndRow();
  20147. }
  20148. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20149. {
  20150. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20151. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20152. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20153. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20154. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20155. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20156. }
  20157. #endregion
  20158. #region 会务倒推表
  20159. /// <summary>
  20160. /// 会务倒推表
  20161. /// Init
  20162. /// </summary>
  20163. /// <returns></returns>
  20164. [HttpPost]
  20165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20166. public async Task<IActionResult> InforRetrogressTableInit()
  20167. {
  20168. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20169. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20170. return Ok(JsonView(false, groupData.Msg));
  20171. }
  20172. /// <summary>
  20173. /// 会务倒推表
  20174. /// ExcelDownload
  20175. /// </summary>
  20176. /// <param name="dto"></param>
  20177. /// <returns></returns>
  20178. [HttpPost]
  20179. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20181. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20182. {
  20183. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20184. var validatorRes = await validator.ValidateAsync(dto);
  20185. if (!validatorRes.IsValid)
  20186. {
  20187. StringBuilder sb = new StringBuilder();
  20188. foreach (var item in validatorRes.Errors)
  20189. {
  20190. sb.AppendLine(item.ErrorMessage);
  20191. }
  20192. return Ok(JsonView(false, sb.ToString()));
  20193. }
  20194. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20195. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20196. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20197. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20198. #region Excel
  20199. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20200. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20201. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20202. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20203. var fileNamePrefix = string.Empty;
  20204. if (days >= 30)
  20205. {
  20206. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20207. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20208. }
  20209. else if (days < 30 && days > 7)
  20210. {
  20211. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20212. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20213. }
  20214. else if (days <= 7)
  20215. {
  20216. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20217. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20218. }
  20219. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20220. fileName = CommonFun.ValidFileName(fileName);
  20221. //载入模板
  20222. WorkbookDesigner designer = new WorkbookDesigner();
  20223. designer.Workbook = new Workbook(tempPath);
  20224. designer.Process();
  20225. if (!Directory.Exists(savePath))
  20226. {
  20227. Directory.CreateDirectory(savePath);
  20228. }
  20229. string serverPath = $"{savePath}{fileName}";
  20230. designer.Workbook.Save(serverPath);
  20231. string rst = $"{servicePath}{ftpPath}{fileName}";
  20232. #endregion
  20233. return Ok(JsonView(new { url = rst }));
  20234. }
  20235. #endregion
  20236. #region 三公签证费用(签证费、代办费)
  20237. /// <summary>
  20238. /// 三公签证费用(签证费、代办费)
  20239. /// List
  20240. /// </summary>
  20241. /// <returns></returns>
  20242. [HttpPost]
  20243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20244. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20245. {
  20246. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  20247. if (_view.Code != 0)
  20248. {
  20249. return Ok(JsonView(false, _view.Msg));
  20250. }
  20251. return Ok(JsonView(true, "操作成功!", _view.Data));
  20252. }
  20253. /// <summary>
  20254. /// 三公签证费用(签证费、代办费)
  20255. /// Add Or Update
  20256. /// </summary>
  20257. /// <returns></returns>
  20258. [HttpPost]
  20259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20260. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20261. {
  20262. var _view = await _visaFeeInfoRep._Update(_dto);
  20263. if (_view.Code != 0)
  20264. {
  20265. return Ok(JsonView(false, _view.Msg));
  20266. }
  20267. return Ok(JsonView(true, _view.Msg));
  20268. }
  20269. #endregion
  20270. #region 酒店询价
  20271. /// <summary>
  20272. /// 酒店询价
  20273. /// Init
  20274. /// </summary>
  20275. /// <returns></returns>
  20276. [HttpPost]
  20277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20278. public async Task<IActionResult> PostHotelInquiryInit()
  20279. {
  20280. var res = await _hotelInquiryRep._Init();
  20281. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20282. return Ok(JsonView(true, res.Msg, res.Data));
  20283. }
  20284. /// <summary>
  20285. /// 酒店询价
  20286. /// page Item
  20287. /// </summary>
  20288. /// <param name="_dto"></param>
  20289. /// <returns></returns>
  20290. [HttpPost]
  20291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20292. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20293. {
  20294. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20295. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20296. var view = res.Data as PageDataViewBase;
  20297. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20298. }
  20299. /// <summary>
  20300. /// 酒店询价
  20301. /// info
  20302. /// </summary>
  20303. /// <param name="_dto"></param>
  20304. /// <returns></returns>
  20305. [HttpPost]
  20306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20307. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  20308. {
  20309. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  20310. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20311. return Ok(JsonView(true, res.Msg, res.Data));
  20312. }
  20313. /// <summary>
  20314. /// 酒店询价
  20315. /// Add Or Edit
  20316. /// </summary>
  20317. /// <param name="_dto"></param>
  20318. /// <returns></returns>
  20319. [HttpPost]
  20320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20321. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  20322. {
  20323. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  20324. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20325. return Ok(JsonView(true, res.Msg, res.Data));
  20326. }
  20327. /// <summary>
  20328. /// 酒店询价
  20329. /// Del
  20330. /// </summary>
  20331. /// <param name="_dto"></param>
  20332. /// <returns></returns>
  20333. [HttpPost]
  20334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20335. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  20336. {
  20337. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  20338. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20339. return Ok(JsonView(true, res.Msg, res.Data));
  20340. }
  20341. #endregion
  20342. #region 下载匹配op行程单
  20343. /// <summary>
  20344. /// 匹配op行程单
  20345. /// Init
  20346. /// </summary>
  20347. /// <param name="dto">团组列表请求dto</param>
  20348. /// <returns></returns>
  20349. [HttpPost]
  20350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20351. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  20352. {
  20353. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20354. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20355. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  20356. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  20357. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  20358. .Where(it => it.IsDel == 0)
  20359. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  20360. .OrderByDescending(it => it.VisitStartDate)
  20361. .ToList();
  20362. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  20363. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20364. var diids = groupInfos.Select(it => it.Id).ToList();
  20365. List<string> countrys = new List<string>();
  20366. foreach (var item in country)
  20367. {
  20368. var data = _groupRepository.FormartTeamName(item);
  20369. var dataArray = _groupRepository.GroupSplitCountry(data);
  20370. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20371. }
  20372. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  20373. List<string> areaArray = new List<string>(); //GetGroupCityLine
  20374. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  20375. foreach (var item in areaItem)
  20376. {
  20377. string areaStr = item.Value;
  20378. if (!string.IsNullOrEmpty(areaStr))
  20379. {
  20380. string[] str1 = areaStr.Split("-");
  20381. if (str1.Length > 0)
  20382. {
  20383. areaArray.AddRange(str1);
  20384. }
  20385. }
  20386. }
  20387. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  20388. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  20389. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  20390. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  20391. .ToList();
  20392. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  20393. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  20394. .Where(it => countriesIds.Contains(it.Id))
  20395. .Select(it => new { it.Id, Name = it.Name_CN })
  20396. .ToList();
  20397. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  20398. .Select(it => it.TeamName).ToList();
  20399. stopwatch.Stop();
  20400. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  20401. }
  20402. ///// <summary>
  20403. ///// 匹配op行程单
  20404. ///// Init 查询区域数据
  20405. ///// </summary>
  20406. ///// <param name="dto">团组列表请求dto</param>
  20407. ///// <returns></returns>
  20408. //[HttpPost]
  20409. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20410. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20411. //{
  20412. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20413. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20414. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20415. // if (string.IsNullOrEmpty(countriesDataStr))
  20416. // {
  20417. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20418. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20419. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20420. // }
  20421. // else
  20422. // {
  20423. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20424. // }
  20425. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20426. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20427. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20428. // List<dynamic> childList = new List<dynamic>();
  20429. // int parentId = dto.CountriesId;
  20430. // if (provinceData.Count > 1)
  20431. // {
  20432. // foreach (var item1 in provinceData)
  20433. // {
  20434. // List<dynamic> childList1 = new List<dynamic>();
  20435. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20436. // foreach (var item2 in citiesData1)
  20437. // {
  20438. // List<dynamic> childList2 = new List<dynamic>();
  20439. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20440. // foreach (var item3 in countiesData1)
  20441. // {
  20442. // childList2.Add(new
  20443. // {
  20444. // id = item3.Id,
  20445. // parentId = item2.Id,
  20446. // level = "district",
  20447. // name = item3.Name_CN,
  20448. // });
  20449. // }
  20450. // childList1.Add(new
  20451. // {
  20452. // id = item2.Id,
  20453. // parentId = item1.Id,
  20454. // level = "city",
  20455. // name = item2.Name_CN,
  20456. // childList = childList2
  20457. // });
  20458. // }
  20459. // childList.Add(new
  20460. // {
  20461. // id = item1.Id,
  20462. // parentId = parentId,
  20463. // level = "province",
  20464. // name = item1.Name_CN,
  20465. // childList = childList1
  20466. // });
  20467. // }
  20468. // //城市
  20469. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20470. // foreach (var item2 in citiesData2)
  20471. // {
  20472. // List<dynamic> childList22 = new List<dynamic>();
  20473. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20474. // foreach (var item3 in countiesData1)
  20475. // {
  20476. // childList22.Add(new
  20477. // {
  20478. // id = item3.Id,
  20479. // parentId = item2.Id,
  20480. // level = "district",
  20481. // name = item3.Name_CN,
  20482. // });
  20483. // }
  20484. // childList.Add(new
  20485. // {
  20486. // id = item2.Id,
  20487. // parentId = parentId,
  20488. // level = "city",
  20489. // name = item2.Name_CN,
  20490. // childList = childList22
  20491. // });
  20492. // }
  20493. // }
  20494. // else
  20495. // {
  20496. // foreach (var item2 in citiesData)
  20497. // {
  20498. // string cname = item2.Name_CN;
  20499. // List<dynamic> childList1 = new List<dynamic>();
  20500. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20501. // foreach (var item3 in countiesData1)
  20502. // {
  20503. // childList1.Add(new
  20504. // {
  20505. // Id = item3.Id,
  20506. // parentId = item2.Id,
  20507. // level = "district",
  20508. // name = item3.Name_CN
  20509. // });
  20510. // }
  20511. // childList.Add(new
  20512. // {
  20513. // id = item2.Id,
  20514. // parentId = parentId,
  20515. // level = "city",
  20516. // name = item2.Name_CN,
  20517. // childList = childList1
  20518. // });
  20519. // }
  20520. // }
  20521. // stopwatch.Stop();
  20522. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20523. //}
  20524. /// <summary>
  20525. /// 匹配op行程单
  20526. /// 接团信息列表 Page
  20527. /// </summary>
  20528. /// <param name="dto">团组列表请求dto</param>
  20529. /// <returns></returns>
  20530. [HttpPost]
  20531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20532. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20533. {
  20534. var swatch = new Stopwatch();
  20535. swatch.Start();
  20536. #region 参数验证
  20537. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20538. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20539. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20540. #region 页面操作权限验证
  20541. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20542. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20543. #endregion
  20544. #endregion
  20545. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20546. {
  20547. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20548. //string sqlWhere = "";
  20549. if (!string.IsNullOrEmpty(dto.Country))
  20550. {
  20551. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20552. }
  20553. if (!string.IsNullOrEmpty(dto.Area))
  20554. {
  20555. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20556. }
  20557. if (!string.IsNullOrEmpty(dto.TeamName))
  20558. {
  20559. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20560. }
  20561. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20562. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20563. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20564. swatch.Stop();
  20565. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20566. }
  20567. else
  20568. {
  20569. return Ok(JsonView(false, "查询失败"));
  20570. }
  20571. }
  20572. /// <summary>
  20573. /// 匹配op行程单
  20574. /// 行程单下载
  20575. /// </summary>
  20576. /// <param name="dto">团组列表请求dto</param>
  20577. /// <returns></returns>
  20578. [HttpPost]
  20579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20580. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  20581. {
  20582. #region 参数验证
  20583. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20584. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20585. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20586. #region 页面操作权限验证
  20587. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20588. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  20589. #endregion
  20590. #endregion
  20591. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20592. {
  20593. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  20594. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  20595. }
  20596. else
  20597. {
  20598. return Ok(JsonView(false, "下载失败!"));
  20599. }
  20600. }
  20601. #endregion
  20602. #region 国家信息 数据 注释
  20603. //[HttpPost]
  20604. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  20605. //{
  20606. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  20607. // foreach (var item in dto)
  20608. // {
  20609. // infos.Add(new Grp_GroupsTaskAssignment()
  20610. // {
  20611. // DIId = item,
  20612. // CTId = 82,
  20613. // UId = 248,
  20614. // IsEnable = 1,
  20615. // CreateUserId = 233,
  20616. // CreateTime = DateTime.Now,
  20617. // IsDel = 0
  20618. // });
  20619. // infos.Add(new Grp_GroupsTaskAssignment()
  20620. // {
  20621. // DIId = item,
  20622. // CTId = 82,
  20623. // UId = 286,
  20624. // IsEnable = 1,
  20625. // CreateUserId = 233,
  20626. // CreateTime = DateTime.Now,
  20627. // IsDel = 0
  20628. // });
  20629. // }
  20630. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20631. // return Ok("操作成功");
  20632. //}
  20633. //public class paramJsonDto
  20634. //{
  20635. // public List<CountriesInfo> str { get; set; }
  20636. //}
  20637. //[HttpPost]
  20638. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20639. //{
  20640. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20641. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20642. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20643. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20644. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20645. // _sqlSugar.BeginTran();
  20646. // int countitiesIndex = 0;
  20647. // foreach (var item in dto.str)
  20648. // {
  20649. // dynamic data = item.c;
  20650. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20651. // if (data != null)
  20652. // {
  20653. // countitiesIndex++;
  20654. // foreach (var item1 in data)
  20655. // {
  20656. // string cnname = item1.cn;
  20657. // string enname = item1.en;
  20658. // Sys_Cities provinceInfo = new Sys_Cities()
  20659. // {
  20660. // CountriesId = countriesId,
  20661. // Name_CN = cnname,
  20662. // Name_EN = enname,
  20663. // ParentId = 0,
  20664. // IsCapital = 1,
  20665. // CreateUserId = 208,
  20666. // CreateTime = DateTime.Now,
  20667. // IsDel = 0
  20668. // };
  20669. // if (item1.lv == "province") //省份
  20670. // {
  20671. // provinceInfo.Level = 1;
  20672. // int provinceId = 0;
  20673. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20674. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20675. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20676. // var data1 = item1.c;
  20677. // foreach (var item2 in data1)
  20678. // {
  20679. // if (item2.lv == "city")
  20680. // {
  20681. // string citycnname = item2.cn;
  20682. // string cityenname = item2.en;
  20683. // Sys_Cities cityInfo = new Sys_Cities()
  20684. // {
  20685. // CountriesId = countriesId,
  20686. // ParentId = provinceId,
  20687. // Level = 2,
  20688. // Name_CN = citycnname,
  20689. // Name_EN = cityenname,
  20690. // IsCapital = 1,
  20691. // CreateUserId = 208,
  20692. // CreateTime = DateTime.Now,
  20693. // IsDel = 0
  20694. // };
  20695. // if (item2.c != null)
  20696. // {
  20697. // int cityId = 0;
  20698. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20699. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20700. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20701. // foreach (var item3 in item2.c)
  20702. // {
  20703. // if (item3.lv == "district")
  20704. // {
  20705. // var districtInfo = new Sys_Cities()
  20706. // {
  20707. // CountriesId = countriesId,
  20708. // Name_CN = item3.cn,
  20709. // Name_EN = item3.en,
  20710. // Level = 3,
  20711. // ParentId = cityId,
  20712. // IsCapital = 1,
  20713. // CreateUserId = 208,
  20714. // CreateTime = DateTime.Now,
  20715. // IsDel = 0
  20716. // };
  20717. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20718. // //{
  20719. // districts.Add(districtInfo);
  20720. // //}
  20721. // }
  20722. // }
  20723. // }
  20724. // else
  20725. // {
  20726. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20727. // //{
  20728. // cities.Add(cityInfo);
  20729. // //}
  20730. // }
  20731. // }
  20732. // }
  20733. // }
  20734. // else if (item1.lv == "city")//城市
  20735. // {
  20736. // provinceInfo.Level = 2;
  20737. // if (item1.c != null)
  20738. // {
  20739. // int cityId = 0;
  20740. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20741. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20742. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20743. // foreach (var item3 in item1.c)
  20744. // {
  20745. // if (item3.lv == "district")
  20746. // {
  20747. // var districtInfo = new Sys_Cities()
  20748. // {
  20749. // CountriesId = countriesId,
  20750. // Name_CN = item3.cn,
  20751. // Name_EN = item3.en,
  20752. // Level = 3,
  20753. // ParentId = cityId,
  20754. // IsCapital = 1,
  20755. // CreateUserId = 208,
  20756. // CreateTime = DateTime.Now,
  20757. // IsDel = 0
  20758. // };
  20759. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20760. // //{
  20761. // districts.Add(districtInfo);
  20762. // //}
  20763. // }
  20764. // }
  20765. // }
  20766. // else
  20767. // {
  20768. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20769. // //{
  20770. // cities.Add(provinceInfo);
  20771. // //}
  20772. // }
  20773. // }
  20774. // }
  20775. // }
  20776. // }
  20777. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20778. // cities = cities.Distinct().ToList();
  20779. // districts = districts.Distinct().ToList();
  20780. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20781. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20782. // cities.AddRange(districts);
  20783. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20784. // //_sqlSugar.RollbackTran();
  20785. // _sqlSugar.CommitTran();
  20786. // return Ok(JsonView(false, "操作成功!"));
  20787. //}
  20788. //[HttpPost]
  20789. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20790. //{
  20791. // List<CountitiesInfo> infos = dto.MyProperty;
  20792. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20793. // _sqlSugar.BeginTran();
  20794. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20795. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20796. // foreach (var item in infos)
  20797. // {
  20798. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20799. // if (countryInfo != null)
  20800. // {
  20801. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20802. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20803. // if (cityInfo1 != null)
  20804. // {
  20805. // cityInfo1.IsCapital = 0;
  20806. // cityInfos.Add(cityInfo1);
  20807. // }
  20808. // }
  20809. // }
  20810. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20811. // .UpdateColumns(it => it.IsCapital)
  20812. // .WhereColumns(it => it.Id)
  20813. // .ExecuteCommand();
  20814. // //_sqlSugar.RollbackTran();
  20815. // _sqlSugar.CommitTran();
  20816. // return Ok(JsonView(false, "操作成功!"));
  20817. //}
  20818. //public class CounrtiesDto
  20819. //{
  20820. // public List<CountitiesInfo> MyProperty { get; set; }
  20821. //}
  20822. //public class CountitiesInfo
  20823. //{
  20824. // /// <summary>
  20825. // /// 圣约翰
  20826. // /// </summary>
  20827. // public string capital_name_chinese { get; set; }
  20828. // /// <summary>
  20829. // ///
  20830. // /// </summary>
  20831. // public string capital_name { get; set; }
  20832. // /// <summary>
  20833. // ///
  20834. // /// </summary>
  20835. // public string country_type { get; set; }
  20836. // /// <summary>
  20837. // /// 安提瓜和巴布达
  20838. // /// </summary>
  20839. // public string country_name_chinese { get; set; }
  20840. // /// <summary>
  20841. // /// 安提瓜和巴布达
  20842. // /// </summary>
  20843. // public string country_name_chinese_short { get; set; }
  20844. // /// <summary>
  20845. // /// 安提瓜和巴布达
  20846. // /// </summary>
  20847. // public string country_name_chinese_UN { get; set; }
  20848. // /// <summary>
  20849. // ///
  20850. // /// </summary>
  20851. // public string country_name_english_abbreviation { get; set; }
  20852. // /// <summary>
  20853. // ///
  20854. // /// </summary>
  20855. // public string country_name_english_formal { get; set; }
  20856. // /// <summary>
  20857. // ///
  20858. // /// </summary>
  20859. // public string country_name_english_UN { get; set; }
  20860. // /// <summary>
  20861. // ///
  20862. // /// </summary>
  20863. // public string continent_name { get; set; }
  20864. // /// <summary>
  20865. // ///
  20866. // /// </summary>
  20867. // public string subregion_name { get; set; }
  20868. // /// <summary>
  20869. // ///
  20870. // /// </summary>
  20871. // public string country_code2 { get; set; }
  20872. // /// <summary>
  20873. // ///
  20874. // /// </summary>
  20875. // public string country_code3 { get; set; }
  20876. // /// <summary>
  20877. // ///
  20878. // /// </summary>
  20879. // public string phone_code { get; set; }
  20880. //}
  20881. //public class CountriesInfo : BasicInfo
  20882. //{
  20883. // public List<CitiesInfo> c { get; set; }
  20884. //}
  20885. //public class CitiesInfo : BasicInfo
  20886. //{
  20887. // public List<AreaInfo> c { get; set; }
  20888. //}
  20889. //public class AreaInfo : BasicInfo
  20890. //{
  20891. // public List<AreaInfo> c { get; set; }
  20892. //}
  20893. //public class BasicInfo
  20894. //{
  20895. // public string code { get; set; }
  20896. // public string cn { get; set; }
  20897. // public string lv { get; set; }
  20898. // public string en { get; set; }
  20899. //}
  20900. #endregion
  20901. #region 查看邀请方
  20902. /// <summary>
  20903. /// 查看邀请方
  20904. /// 邀请方信息 Init
  20905. /// </summary>
  20906. /// <param name="dto"></param>
  20907. /// <returns></returns>
  20908. [HttpPost]
  20909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20910. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  20911. {
  20912. string sqlWhere = string.Empty;
  20913. if (!string.IsNullOrEmpty(dto.Search))
  20914. {
  20915. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  20916. }
  20917. string sql = string.Format($@"Select
  20918. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  20919. Id,
  20920. UnitName
  20921. From Res_InvitationOfficialActivityData
  20922. Where IsDel = 0
  20923. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  20924. RefAsync<int> total = 0;
  20925. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20926. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  20927. }
  20928. /// <summary>
  20929. /// 查看邀请方
  20930. /// 国家信息 Init
  20931. /// </summary>
  20932. /// <param name="dto"></param>
  20933. /// <returns></returns>
  20934. [HttpPost]
  20935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20936. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  20937. {
  20938. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  20939. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20940. var diids = groupInfos.Select(it => it.Id).ToList();
  20941. List<string> countrys = new List<string>();
  20942. foreach (var item in country)
  20943. {
  20944. var data = _groupRepository.FormartTeamName(item);
  20945. var dataArray = _groupRepository.GroupSplitCountry(data);
  20946. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20947. }
  20948. countrys = countrys.Distinct().ToList();
  20949. for (int i = 0; i < countrys.Count; i++)
  20950. {
  20951. string item = countrys[i];
  20952. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  20953. {
  20954. countrys.Remove(item);
  20955. i--;
  20956. }
  20957. }
  20958. RefAsync<int> total = 0;
  20959. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  20960. .Where(it => countrys.Contains(it.Name_CN))
  20961. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20962. .Select(it => new { id = it.Id, name = it.Name_CN })
  20963. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20964. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20965. }
  20966. /// <summary>
  20967. /// 查看邀请方
  20968. /// 城市信息 Init
  20969. /// </summary>
  20970. /// <param name="dto"></param>
  20971. /// <returns></returns>
  20972. [HttpPost]
  20973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20974. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  20975. {
  20976. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  20977. RefAsync<int> total = 0;
  20978. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  20979. .Where(it => it.CountriesId == dto.CountiesId)
  20980. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20981. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  20982. .Select(it => new { id = it.Id, name = it.Name_CN })
  20983. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20984. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20985. }
  20986. /// <summary>
  20987. /// 查看邀请方
  20988. /// 团组名称 Init
  20989. /// </summary>
  20990. /// <param name="dto"></param>
  20991. /// <returns></returns>
  20992. [HttpPost]
  20993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20994. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  20995. {
  20996. var watch = new Stopwatch();
  20997. watch.Start();
  20998. RefAsync<int> total = 0;
  20999. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  21000. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  21001. .Where((oa, di) => oa.IsDel == 0)
  21002. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  21003. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  21004. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  21005. .Distinct()
  21006. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21007. watch.Stop();
  21008. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  21009. }
  21010. /// <summary>
  21011. /// 查看邀请方
  21012. /// 团组 & 邀请方信息
  21013. /// </summary>
  21014. /// <param name="dto"></param>
  21015. /// <returns></returns>
  21016. [HttpPost]
  21017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21018. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  21019. {
  21020. var watch = new Stopwatch();
  21021. watch.Start();
  21022. RefAsync<int> total = 0;
  21023. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  21024. .AS("Grp_DelegationInfo")
  21025. .Includes(x => x.InvitingInfos)
  21026. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  21027. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  21028. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  21029. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  21030. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  21031. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  21032. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21033. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  21034. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  21035. infos.ForEach(x =>
  21036. {
  21037. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  21038. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  21039. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  21040. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  21041. });
  21042. watch.Stop();
  21043. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  21044. }
  21045. #endregion
  21046. #region 报批行程
  21047. /// <summary>
  21048. /// 报批行程初始化
  21049. /// </summary>
  21050. /// <param name="dto"></param>
  21051. /// <returns></returns>
  21052. [HttpPost]
  21053. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  21054. {
  21055. const int chiNumber = 5;
  21056. var jw = JsonView(false);
  21057. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  21058. var group = groupList.First();
  21059. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  21060. group = groupList.First(x => x.Id == diid);
  21061. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21062. .Where(x => x.DiId == diid && x.IsDel == 0)
  21063. .ToArray();
  21064. var count = 1;
  21065. foreach (var item in blackCodeList)
  21066. {
  21067. if (string.IsNullOrWhiteSpace(item.Title))
  21068. {
  21069. item.Title = "未设置名称数据" + count;
  21070. }
  21071. count++;
  21072. }
  21073. ;
  21074. if (group == null)
  21075. {
  21076. jw.Msg = "暂无团组!";
  21077. return Ok(jw);
  21078. }
  21079. var data = new
  21080. {
  21081. groupList = groupList.Select(x => new
  21082. {
  21083. x.TeamName,
  21084. x.Id
  21085. }),
  21086. content = new ArrayList(),
  21087. groupInfo = new
  21088. {
  21089. group.VisitDays,
  21090. group.TourCode,
  21091. group.VisitPNumber,
  21092. group.TeamName,
  21093. group.Id,
  21094. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21095. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21096. group.ClientUnit
  21097. },
  21098. blackCodeList = blackCodeList.Select(x => new
  21099. {
  21100. x.Title,
  21101. x.Id
  21102. }),
  21103. FileTempList = new ArrayList()
  21104. {
  21105. new { Index = 1,FileName = "旧模板" },
  21106. new { Index = 2,FileName = "省外办" },
  21107. new { Index = 3,FileName = "市外办" },
  21108. }
  21109. };
  21110. var resultArr = new ArrayList();
  21111. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21112. #region 默认不生成行程
  21113. //if (content.Count == 0)
  21114. //{
  21115. // var stay = "-";
  21116. // var cityPath = "-";
  21117. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21118. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21119. // .ToList();
  21120. // //添加城市路径以及住宿地
  21121. // //黑屏代码数据
  21122. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21123. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21124. // {
  21125. // jw = JsonView(true, "黑屏代码有误!", data);
  21126. // return Ok(jw);
  21127. // }
  21128. // data = data with
  21129. // {
  21130. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21131. // {
  21132. // x.Title,
  21133. // x.Id,
  21134. // }).ToArray())
  21135. // };
  21136. // foreach (DataRow row in dtBlack.Rows)
  21137. // {
  21138. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21139. // {
  21140. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21141. // return Ok(jw);
  21142. // }
  21143. // }
  21144. // //黑屏代码获取时间区间
  21145. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21146. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21147. // _sqlSugar.BeginTran();
  21148. // for (int i = 0; i < timeArr.Count; i++)
  21149. // {
  21150. // stay = "-";
  21151. // cityPath = "-";
  21152. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21153. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21154. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21155. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21156. // if (tbSelect.Length > 0)
  21157. // {
  21158. // List<string> threeCodeStr = new List<string>();
  21159. // foreach (var item in tbSelect)
  21160. // {
  21161. // var threeCode = item["Three"].ToString() ?? "";
  21162. // if (threeCode.Length == 6)
  21163. // {
  21164. // var start = threeCode.Substring(0, 3);
  21165. // var end = threeCode.Substring(3, 3);
  21166. // if (threeCodeStr.Count == 0)
  21167. // {
  21168. // threeCodeStr.Add(start);
  21169. // threeCodeStr.Add(end);
  21170. // }
  21171. // else
  21172. // {
  21173. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21174. // {
  21175. // threeCodeStr.Add(end);
  21176. // }
  21177. // else
  21178. // {
  21179. // threeCodeStr.Add(start);
  21180. // threeCodeStr.Add(end);
  21181. // }
  21182. // }
  21183. // }
  21184. // }
  21185. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21186. // var last = threeCodeStr.Last();
  21187. // foreach (var item in threeCodeStr)
  21188. // {
  21189. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21190. // if (item.Equals(last))
  21191. // {
  21192. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21193. // }
  21194. // }
  21195. // cityPath = cityPath.Trim('-');
  21196. // }
  21197. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21198. // appro.Diid = diid ?? -1;
  21199. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21200. // appro.Id = thisId;
  21201. // appro.CreateUserId = dto.UserId;
  21202. // appro.CreateTime = DateTime.Now;
  21203. // content.Add(appro);
  21204. // }
  21205. // _sqlSugar.CommitTran();
  21206. //}
  21207. #endregion
  21208. foreach (var x in content)
  21209. {
  21210. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21211. if (chiList.Count < chiNumber)
  21212. {
  21213. for (int i = chiList.Count; i < chiNumber; i++)
  21214. {
  21215. chiList.Add(new Grp_ApprovalTravelDetails());
  21216. }
  21217. }
  21218. resultArr.Add(new
  21219. {
  21220. x.Id,
  21221. x.Date,
  21222. x.Diid,
  21223. chiList = chiList.Select(x1 => new
  21224. {
  21225. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21226. x1.Details,
  21227. x1.ParentId,
  21228. x1.Id
  21229. })
  21230. });
  21231. }
  21232. data = data with
  21233. {
  21234. content = resultArr,
  21235. };
  21236. jw = JsonView(true, "获取成功!", data);
  21237. return Ok(jw);
  21238. }
  21239. /// <summary>
  21240. /// 报批行程删除
  21241. /// </summary>
  21242. /// <param name="dto"></param>
  21243. /// <returns></returns>
  21244. [HttpPost]
  21245. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21246. {
  21247. var jw = JsonView(false);
  21248. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21249. if (group == null)
  21250. {
  21251. jw.Msg = "团组参数有误!";
  21252. return Ok(jw);
  21253. }
  21254. try
  21255. {
  21256. _sqlSugar.BeginTran();
  21257. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21258. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21259. {
  21260. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21261. DeleteUserId = dto.uesrId,
  21262. IsDel = 1
  21263. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21264. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21265. {
  21266. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21267. DeleteUserId = dto.uesrId,
  21268. IsDel = 1
  21269. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21270. _sqlSugar.CommitTran();
  21271. jw = JsonView(true, "删除成功");
  21272. }
  21273. catch (Exception ex)
  21274. {
  21275. jw = JsonView(false, ex.Message);
  21276. }
  21277. return Ok(jw);
  21278. }
  21279. /// <summary>
  21280. /// 报批行程保存
  21281. /// </summary>
  21282. /// <param name="dto"></param>
  21283. /// <returns></returns>
  21284. [HttpPost]
  21285. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21286. {
  21287. var jw = JsonView(false);
  21288. var Find = dto.Arr.Find(x => x.id == 0);
  21289. if (Find != null)
  21290. {
  21291. jw.Msg = "生成的ID为0!";
  21292. return Ok(jw);
  21293. }
  21294. foreach (var item in dto.Arr)
  21295. {
  21296. foreach (var chi in item.chiList)
  21297. {
  21298. if (chi.parentId == 0)
  21299. {
  21300. chi.parentId = item.id;
  21301. }
  21302. }
  21303. }
  21304. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21305. _sqlSugar.BeginTran();
  21306. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  21307. {
  21308. var parentIds = dto.Arr.Select(x => x.id).ToList();
  21309. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  21310. {
  21311. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21312. DeleteUserId = dto.UserId,
  21313. IsDel = 1
  21314. }).ExecuteCommand();
  21315. }
  21316. try
  21317. {
  21318. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  21319. {
  21320. CreateTime = DateTime.Now,
  21321. CreateUserId = dto.UserId,
  21322. Details = x.details,
  21323. ParentId = x.parentId,
  21324. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21325. Remark = "",
  21326. IsDel = 0
  21327. }).ToList()).ExecuteCommand();
  21328. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  21329. {
  21330. Id = x.id,
  21331. Details = x.details,
  21332. ParentId = x.parentId,
  21333. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21334. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  21335. {
  21336. Details = x.Details,
  21337. ParentId = x.ParentId,
  21338. Time = x.Time
  21339. }).ExecuteCommand();
  21340. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  21341. {
  21342. Id = x.id,
  21343. Date = x.date,
  21344. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  21345. {
  21346. Date = x.Date
  21347. }).ExecuteCommand();
  21348. _sqlSugar.CommitTran();
  21349. jw = JsonView(true, "保存成功!");
  21350. }
  21351. catch (Exception ex)
  21352. {
  21353. _sqlSugar.RollbackTran();
  21354. jw = JsonView(false, "保存失败!" + ex.Message);
  21355. }
  21356. return Ok(jw);
  21357. }
  21358. /// <summary>
  21359. /// 报批行程生成
  21360. /// </summary>
  21361. /// <param name="dto"></param>
  21362. /// <returns></returns>
  21363. [HttpPost]
  21364. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  21365. {
  21366. var jw = JsonView(false);
  21367. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21368. if (group == null)
  21369. {
  21370. jw.Msg = "暂无该团组!";
  21371. return Ok(jw);
  21372. }
  21373. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  21374. //黑屏代码数据
  21375. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  21376. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21377. {
  21378. jw.Msg = "黑屏代码有误!";
  21379. return Ok(jw);
  21380. }
  21381. foreach (DataRow row in dtBlack.Rows)
  21382. {
  21383. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21384. {
  21385. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  21386. return Ok(jw);
  21387. }
  21388. }
  21389. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  21390. var resultArr = new ArrayList();
  21391. //if (officialActivitiesArr.Count == 0)
  21392. //{
  21393. // jw.Msg = "暂无公务出访信息!";
  21394. // return Ok(jw);
  21395. //}
  21396. try
  21397. {
  21398. _sqlSugar.BeginTran();
  21399. DeleteApprovalJourney(new
  21400. Domain.Dtos.Groups.DeleteApprovalJourney
  21401. {
  21402. Diid = dto.Diid,
  21403. uesrId = dto.Userid
  21404. });
  21405. var stay = "-";
  21406. var cityPath = "-";
  21407. var arriveCountry = string.Empty;
  21408. //添加城市路径以及住宿地
  21409. //黑屏代码获取时间区间
  21410. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21411. var empty = "【未收入该三字码!请机票同事录入】";
  21412. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21413. #region 配置公务活动时间
  21414. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21415. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21416. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21417. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21418. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21419. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21420. {
  21421. 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" }),
  21422. 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"}),
  21423. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21424. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21425. };
  21426. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21427. {
  21428. 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" }),
  21429. 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"}),
  21430. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21431. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21432. };
  21433. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21434. {
  21435. 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" }),
  21436. 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"}),
  21437. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21438. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21439. };
  21440. #endregion
  21441. var nextDayNum = 0;
  21442. for (int i = 0; i < timeArr.Count; i++)
  21443. {
  21444. stay = "-";
  21445. cityPath = "-";
  21446. var chiarr = new List<Grp_ApprovalTravelDetails>();
  21447. DateTime NewData = DateTime.Parse(timeArr[i]);
  21448. //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();
  21449. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21450. if (nextDayNum > 0)
  21451. {
  21452. nextDayNum--;
  21453. }
  21454. if (tbSelect.Length > 0)
  21455. {
  21456. List<string> threeCodeStr = new List<string>();
  21457. bool isTrade = false;
  21458. string trip = string.Empty;
  21459. foreach (var item in tbSelect)
  21460. {
  21461. if (nextDayNum == 0)
  21462. {
  21463. nextDayNum = Convert.ToInt32(item["Sign"]);
  21464. }
  21465. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21466. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21467. var takeOffTime = DateTime.Parse(timeArr[i]);
  21468. var fallToTime = DateTime.Parse(timeArr[i]);
  21469. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21470. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21471. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21472. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21473. if (nextDayNum > 0)
  21474. {
  21475. fallToTime = fallToTime.AddDays(nextDayNum);
  21476. }
  21477. trip = string.Empty;
  21478. var start = string.Empty;
  21479. var end = string.Empty;
  21480. var threeCode = item["Three"].ToString() ?? "";
  21481. if (threeCode.Length == 6)
  21482. {
  21483. start = threeCode.Substring(0, 3);
  21484. end = threeCode.Substring(3, 3);
  21485. if (threeCodeStr.Count == 0)
  21486. {
  21487. threeCodeStr.Add(start);
  21488. threeCodeStr.Add(end);
  21489. }
  21490. else
  21491. {
  21492. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21493. {
  21494. threeCodeStr.Add(end);
  21495. }
  21496. else
  21497. {
  21498. threeCodeStr.Add(start);
  21499. threeCodeStr.Add(end);
  21500. }
  21501. }
  21502. }
  21503. //处理机票信息
  21504. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  21505. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  21506. if (start_Object == null)
  21507. {
  21508. start_Object = new Res_ThreeCode()
  21509. {
  21510. AirPort = empty,
  21511. AirPort_En = empty,
  21512. City = empty,
  21513. Country = empty,
  21514. Four = empty,
  21515. Three = empty,
  21516. };
  21517. }
  21518. if (end_Object == null)
  21519. {
  21520. end_Object = new Res_ThreeCode()
  21521. {
  21522. AirPort = empty,
  21523. AirPort_En = empty,
  21524. City = empty,
  21525. Country = empty,
  21526. Four = empty,
  21527. Three = empty,
  21528. };
  21529. }
  21530. //机型判断
  21531. string airModel = item["AirModel"].ToString();
  21532. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21533. string flightTime = item["FlightTime"].ToString();
  21534. flightTime = ParseBlackTime(flightTime);
  21535. //航班号
  21536. string flightcode = item["Fliagtcode"].ToString();
  21537. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21538. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21539. if (aircompany == null)
  21540. {
  21541. aircompany = new Res_AirCompany
  21542. {
  21543. CnName = hsEmpty,
  21544. EnName = hsEmpty,
  21545. ShortCode = hsEmpty,
  21546. };
  21547. }
  21548. //航班前公务安排
  21549. if (tbSelect.First().Equals(item) && i != 0)
  21550. {
  21551. foreach (var takeoff in takeoffTimes)
  21552. {
  21553. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21554. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21555. {
  21556. foreach (var addTime in takeoff.Item2)
  21557. {
  21558. chiarr.Add(new Grp_ApprovalTravelDetails
  21559. {
  21560. Time = addTime,
  21561. CreateTime = DateTime.Now,
  21562. CreateUserId = dto.Userid,
  21563. ParentId = 0,
  21564. Details = "公务活动"
  21565. });
  21566. }
  21567. break;
  21568. }
  21569. }
  21570. }
  21571. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21572. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21573. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21574. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  21575. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21576. if (isTrade)
  21577. {
  21578. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  21579. trip += "(转机不出机场)。";
  21580. }
  21581. //else
  21582. //{
  21583. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  21584. //}
  21585. chiarr.Add(new Grp_ApprovalTravelDetails
  21586. {
  21587. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  21588. CreateTime = DateTime.Now,
  21589. CreateUserId = dto.Userid,
  21590. ParentId = 0,
  21591. Details = trip
  21592. });
  21593. //最后一条到达的时间安排公务
  21594. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  21595. {
  21596. bool isCheckCountry = false;
  21597. if (end_Object.Country != arriveCountry)
  21598. {
  21599. arriveCountry = end_Object.Country;
  21600. isCheckCountry = true;
  21601. }
  21602. if (nextDayNum == 0)
  21603. {
  21604. //需要入境的情况
  21605. if (isCheckCountry)
  21606. {
  21607. foreach (var fallTime in fallTimesCheckCountry)
  21608. {
  21609. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21610. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21611. {
  21612. foreach (var addTime in fallTime.Item2)
  21613. {
  21614. chiarr.Add(new Grp_ApprovalTravelDetails
  21615. {
  21616. Time = addTime,
  21617. CreateTime = DateTime.Now,
  21618. CreateUserId = dto.Userid,
  21619. ParentId = 0,
  21620. Details = "公务活动"
  21621. });
  21622. }
  21623. break;
  21624. }
  21625. }
  21626. }
  21627. else
  21628. {
  21629. foreach (var fallTime in fallTimesNotCheckCountry)
  21630. {
  21631. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21632. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21633. {
  21634. foreach (var addTime in fallTime.Item2)
  21635. {
  21636. chiarr.Add(new Grp_ApprovalTravelDetails
  21637. {
  21638. Time = addTime,
  21639. CreateTime = DateTime.Now,
  21640. CreateUserId = dto.Userid,
  21641. ParentId = 0,
  21642. Details = "公务活动"
  21643. });
  21644. }
  21645. break;
  21646. }
  21647. }
  21648. }
  21649. }
  21650. }
  21651. }
  21652. //添加乘车语句
  21653. //chiarr.Add(new Grp_ApprovalTravelDetails
  21654. //{
  21655. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21656. // CreateTime = DateTime.Now,
  21657. // CreateUserId = dto.Userid,
  21658. // ParentId = 0,
  21659. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21660. //});
  21661. //if (i != timeArr.Count - 1)
  21662. //{
  21663. // fallToTime = fallToTime.AddHours(2.5);
  21664. // foreach (var item in Times)
  21665. // {
  21666. // //排列公务时间
  21667. // if (fallToTime.Hour < item.Item1)
  21668. // {
  21669. // chiarr.Add(new Grp_ApprovalTravelDetails
  21670. // {
  21671. // Time = $"{item.Item2} - {item.Item3}",
  21672. // CreateTime = DateTime.Now,
  21673. // CreateUserId = dto.Userid,
  21674. // ParentId = 0,
  21675. // Details = "公务活动"
  21676. // });
  21677. // }
  21678. // }
  21679. //}
  21680. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21681. var last = threeCodeStr.Last();
  21682. foreach (var item in threeCodeStr)
  21683. {
  21684. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21685. if (item.Equals(last))
  21686. {
  21687. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21688. }
  21689. }
  21690. cityPath = cityPath.Trim('-');
  21691. }
  21692. else
  21693. {
  21694. foreach (var item in Times)
  21695. {
  21696. chiarr.Add(new Grp_ApprovalTravelDetails
  21697. {
  21698. Time = $"{item.Item2} - {item.Item3}",
  21699. CreateTime = DateTime.Now,
  21700. CreateUserId = dto.Userid,
  21701. ParentId = 0,
  21702. Details = "公务活动"
  21703. });
  21704. }
  21705. }
  21706. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21707. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21708. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21709. appro.Diid = dto.Diid;
  21710. appro.CreateUserId = dto.Userid;
  21711. appro.CreateTime = DateTime.Now;
  21712. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21713. appro.Id = thisId;
  21714. //foreach (var item in gwinfo)
  21715. //{
  21716. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21717. // chi.Details = "拜访" + item.Client;
  21718. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21719. // {
  21720. // chi.Details += "," + item.ReqSample;
  21721. // }
  21722. // chi.ParentId = thisId;
  21723. // chi.Time = item.Time;
  21724. // chiarr.Add(chi);
  21725. //}
  21726. if (chiarr.Count < 6)
  21727. {
  21728. for (int j = chiarr.Count; j < 6; j++)
  21729. {
  21730. chiarr.Add(new
  21731. Grp_ApprovalTravelDetails());
  21732. }
  21733. }
  21734. resultArr.Add(new
  21735. {
  21736. appro.Id,
  21737. appro.Date,
  21738. appro.Diid,
  21739. chiList = chiarr.Select(x1 => new
  21740. {
  21741. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21742. x1.Details,
  21743. x1.ParentId,
  21744. x1.Id
  21745. })
  21746. });
  21747. }
  21748. _sqlSugar.CommitTran();
  21749. jw = JsonView(true, "生成成功!", resultArr);
  21750. }
  21751. catch (Exception ex)
  21752. {
  21753. jw.Code = 400;
  21754. jw.Msg = "生成失败!" + ex.Message;
  21755. }
  21756. return Ok(jw);
  21757. }
  21758. /// <summary>
  21759. /// 报批行程word导出
  21760. /// </summary>
  21761. /// <param name="dto"></param>
  21762. /// <returns></returns>
  21763. [HttpPost]
  21764. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21765. {
  21766. var jw = JsonView(false);
  21767. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21768. if (group == null)
  21769. {
  21770. jw.Msg = "暂无该团组!";
  21771. return Ok(jw);
  21772. }
  21773. //模板路径
  21774. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21775. var fileName = string.Empty;
  21776. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21777. bool bold = false;
  21778. if (dto.FileIndex == 1)
  21779. {
  21780. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21781. }
  21782. else if (dto.FileIndex == 2)
  21783. {
  21784. fileName = "省外办-报批.docx";
  21785. bold = false;
  21786. titleFont = "方正黑体简体";
  21787. timeFont = "Times New Roman";
  21788. contentFont = "方正仿宋_GBK";
  21789. }
  21790. else if (dto.FileIndex == 3)
  21791. {
  21792. fileName = "市外办-报批.docx";
  21793. titleFont = "方正黑体简体";
  21794. timeFont = "Times New Roman";
  21795. contentFont = "方正仿宋简体";
  21796. }
  21797. tempPath = tempPath + fileName;
  21798. //载入模板
  21799. Document doc = new Document(tempPath);
  21800. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21801. //获取所填表格的序数
  21802. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21803. Aspose.Words.Tables.Row titleRowClone = null;
  21804. Aspose.Words.Tables.Row CenterRowClone = null;
  21805. int index = 0;
  21806. int indexChi = 0;
  21807. int SetIndex = 0;
  21808. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21809. //获取数据,放到datatable
  21810. foreach (var item in ApprovalTravelArr)
  21811. {
  21812. if (index > 0)
  21813. {
  21814. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21815. tableOne.AppendChild(titleRowClone);
  21816. }
  21817. var textTime = item.Date;
  21818. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21819. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21820. SetIndex++;
  21821. if (ChiRep.Count > 0)
  21822. {
  21823. foreach (var itemChi in ChiRep)
  21824. {
  21825. var txtTime = itemChi.Time;
  21826. var txtDetail = itemChi.Details;
  21827. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21828. {
  21829. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21830. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21831. //indexChi++;
  21832. //SetIndex++;
  21833. break;
  21834. }
  21835. if (indexChi > 0)
  21836. {
  21837. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21838. tableOne.AppendChild(CenterRowClone);
  21839. }
  21840. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21841. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21842. indexChi++;
  21843. SetIndex++;
  21844. }
  21845. }
  21846. //else
  21847. //{
  21848. // if (indexChi > 0)
  21849. // {
  21850. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21851. // tableOne.AppendChild(CenterRowClone);
  21852. // }
  21853. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21854. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21855. // indexChi++;
  21856. // SetIndex++;
  21857. //}
  21858. index++;
  21859. }
  21860. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21861. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21862. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21863. jw.Code = 200;
  21864. jw.Msg = "";
  21865. return Ok(jw);
  21866. }
  21867. private string ParseBlackTime(string time)
  21868. {
  21869. // 匹配可能只有分钟的情况
  21870. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21871. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21872. if (match.Success)
  21873. {
  21874. string hours = match.Groups[1].Value;
  21875. string minutes = match.Groups[2].Value;
  21876. // 如果小时部分为空,则只显示分钟
  21877. if (string.IsNullOrEmpty(hours))
  21878. {
  21879. return $"{minutes}分钟";
  21880. }
  21881. // 如果分钟部分为空,则只显示小时
  21882. else if (string.IsNullOrEmpty(minutes))
  21883. {
  21884. return $"{hours}小时";
  21885. }
  21886. // 否则显示完整格式
  21887. else
  21888. {
  21889. return $"{hours}小时{minutes}分钟";
  21890. }
  21891. }
  21892. else
  21893. {
  21894. return "未知时长";
  21895. }
  21896. }
  21897. private string intToString(int numberVal)
  21898. {
  21899. string numberval = numberVal.ToString();
  21900. Dictionary<char, string> Number = new Dictionary<char, string>();
  21901. Number.Add('1', "一");
  21902. Number.Add('2', "二");
  21903. Number.Add('3', "三");
  21904. Number.Add('4', "四");
  21905. Number.Add('5', "五");
  21906. Number.Add('6', "六");
  21907. Number.Add('7', "七");
  21908. Number.Add('8', "八");
  21909. Number.Add('9', "九");
  21910. string stringNumberVal = string.Empty;
  21911. for (int i = 0; i < numberval.Length; i++)
  21912. {
  21913. if (i == 0)
  21914. {
  21915. stringNumberVal += Number[numberval[i]];
  21916. }
  21917. else if (i >= 1)
  21918. {
  21919. if (numberval[i] == '0')
  21920. {
  21921. stringNumberVal = "十";
  21922. }
  21923. else
  21924. {
  21925. stringNumberVal += "十" + Number[numberval[i]];
  21926. }
  21927. }
  21928. }
  21929. return stringNumberVal;
  21930. }
  21931. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  21932. {
  21933. //获取table中的某个单元格,从0开始
  21934. Cell lshCell = table.Rows[rows].Cells[cells];
  21935. //将单元格中段落移除
  21936. foreach (Paragraph item in lshCell.Paragraphs)
  21937. {
  21938. lshCell.Paragraphs.Remove(item);
  21939. }
  21940. if (val.Contains("\r\n"))
  21941. {
  21942. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  21943. foreach (var item in spArr)
  21944. {
  21945. //新建一个段落
  21946. Paragraph p = new Paragraph(doc);
  21947. var r = new Run(doc, item);
  21948. //设置字体
  21949. if (!string.IsNullOrEmpty(font))
  21950. {
  21951. r.Font.Name = font;
  21952. }
  21953. r.Font.Bold = bold;
  21954. //把设置的值赋给之前新建的段落
  21955. p.AppendChild(r);
  21956. //将此段落加到单元格内
  21957. lshCell.AppendChild(p);
  21958. }
  21959. }
  21960. else
  21961. {
  21962. //新建一个段落
  21963. Paragraph p = new Paragraph(doc);
  21964. var r = new Run(doc, val);
  21965. //设置字体
  21966. if (!string.IsNullOrEmpty(font))
  21967. {
  21968. r.Font.Name = font;
  21969. }
  21970. r.Font.Bold = bold;
  21971. //把设置的值赋给之前新建的段落
  21972. p.AppendChild(r);
  21973. //将此段落加到单元格内
  21974. lshCell.AppendChild(p);
  21975. }
  21976. }
  21977. /// <summary>
  21978. /// 报批行程AI续写
  21979. /// </summary>
  21980. /// <returns></returns>
  21981. [HttpPost]
  21982. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  21983. {
  21984. var jw = JsonView(false);
  21985. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  21986. {
  21987. jw.Msg = "参数有误!";
  21988. return Ok(jw);
  21989. }
  21990. KiMiApiClient kiMi = new KiMiApiClient();
  21991. List<SeedMessages> messages = new List<SeedMessages>() {
  21992. new SeedMessages
  21993. {
  21994. Role = KimiRole.system,
  21995. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  21996. },
  21997. new SeedMessages
  21998. {
  21999. Role = KimiRole.user,
  22000. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  22001. }
  22002. };
  22003. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  22004. string data = kimi_result.Choices[0]?.Message.Content;
  22005. if (string.IsNullOrWhiteSpace(data))
  22006. {
  22007. jw.Data = "Ai续写失败!";
  22008. }
  22009. else
  22010. {
  22011. jw = JsonView(true, "success!", data);
  22012. }
  22013. return Ok(jw);
  22014. }
  22015. #endregion
  22016. #region 团组接待意见调查
  22017. /// <summary>
  22018. /// 团组接待意见调查 - 信息管理
  22019. /// 基础数据(团组)
  22020. /// </summary>
  22021. /// <returns></returns>
  22022. [HttpGet]
  22023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22024. public async Task<IActionResult> OpinionaireInit()
  22025. {
  22026. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  22027. .Select(x => new
  22028. {
  22029. x.Id,
  22030. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  22031. })
  22032. .OrderByDescending(x => x.Id)
  22033. .ToListAsync();
  22034. return Ok(JsonView(groupData, groupData.Count));
  22035. }
  22036. /// <summary>
  22037. /// 团组接待意见调查 - 信息管理
  22038. /// 列表
  22039. /// </summary>
  22040. /// <param name="groupId"></param>
  22041. /// <returns></returns>
  22042. [HttpGet("{groupId}")]
  22043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22044. public async Task<IActionResult> OpinionaireManageList(int groupId)
  22045. {
  22046. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22047. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  22048. .Select(x => new
  22049. {
  22050. x.Id,
  22051. x.TourGuideName,
  22052. x.CityName,
  22053. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  22054. x.CreateTime
  22055. })
  22056. .OrderBy(x => x.Id)
  22057. .ToListAsync();
  22058. return Ok(JsonView(data));
  22059. }
  22060. /// <summary>
  22061. /// 团组接待意见调查 - 信息管理
  22062. /// 保存
  22063. /// </summary>
  22064. /// <param name="dto"></param>
  22065. /// <returns></returns>
  22066. [HttpPost]
  22067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22068. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  22069. {
  22070. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22071. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22072. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22073. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  22074. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  22075. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  22076. _opinionaireRep.BeginTran();
  22077. if (addData != null && addData.Count > 0)
  22078. {
  22079. foreach (var item in addData)
  22080. {
  22081. item.CreateUserId = currUserInfo.UserId;
  22082. item.DiId = dto.DiId;
  22083. }
  22084. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  22085. }
  22086. if (updData != null && updData.Count > 0)
  22087. {
  22088. var upd = await _opinionaireRep._sqlSugar
  22089. .Updateable(updData)
  22090. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  22091. .WhereColumns(x => new { x.Id })
  22092. .ExecuteCommandAsync();
  22093. }
  22094. _opinionaireRep.CommitTran();
  22095. return Ok(JsonView("操作成功!"));
  22096. }
  22097. /// <summary>
  22098. /// 团组接待意见调查 - 信息管理
  22099. /// 删除
  22100. /// </summary>
  22101. /// <param name="id"></param>
  22102. /// <returns></returns>
  22103. [HttpDelete("{id}")]
  22104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22105. public async Task<IActionResult> OpinionaireManageDel(int id)
  22106. {
  22107. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22108. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22109. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22110. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22111. if (!del) return Ok(JsonView("操作失败!"));
  22112. return Ok(JsonView("操作成功!"));
  22113. }
  22114. /// <summary>
  22115. /// 团组接待意见调查 - 用户
  22116. /// 列表
  22117. /// </summary>
  22118. /// <param name="diId"></param>
  22119. /// <returns></returns>
  22120. [HttpGet("{diId}")]
  22121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22122. public async Task<IActionResult> OpinionaireUserList(int diId)
  22123. {
  22124. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22125. var sql = string.Format(@"
  22126. SELECT
  22127. o.Id,
  22128. o.DiId,
  22129. di.TeamName AS 'GroupName',
  22130. di.VisitPNumber AS 'PeopleNumber',
  22131. di.ClientName AS 'LeadGroup',
  22132. di.VisitCountry AS 'Travel',
  22133. di.VisitDays AS 'Days',
  22134. o.CityName,
  22135. o.TourGuideName,
  22136. o.Catering,
  22137. o.CateringReason,
  22138. o.Stay,
  22139. o.StayReason,
  22140. o.[Route],
  22141. o.RouteReason,
  22142. o.OfficialActivity,
  22143. o.OfficialActivityReason,
  22144. o.TourGuide,
  22145. o.TourGuideReason,
  22146. o.[Translate],
  22147. o.TranslateReason,
  22148. o.Trip,
  22149. o.TripReason,
  22150. o.ESFileName,
  22151. o.SignatureDate,
  22152. o.Remark
  22153. FROM
  22154. Grp_Opinionaire o
  22155. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22156. WHERE
  22157. o.IsDel = 0
  22158. AND o.DiId = {0}
  22159. ORDER BY
  22160. o.Id ASC", diId);
  22161. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22162. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22163. return Ok(JsonView(data));
  22164. }
  22165. /// <summary>
  22166. /// 团组接待意见调查 - 用户
  22167. /// 保存
  22168. /// </summary>
  22169. /// <param name="dto"></param>
  22170. /// <returns></returns>
  22171. [HttpPost]
  22172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22173. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22174. {
  22175. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22176. foreach (var item in dto)
  22177. {
  22178. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22179. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22180. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22181. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22182. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22183. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22184. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22185. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22186. }
  22187. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22188. if (!Directory.Exists(filePathBase))
  22189. {
  22190. Directory.CreateDirectory(filePathBase);
  22191. }
  22192. #region 上传文件
  22193. var filePaths = new List<string>();
  22194. foreach (var item in dto)
  22195. {
  22196. var file = item.File;
  22197. // 将文件保存到指定位置
  22198. var filePath = Path.Combine(filePathBase, file.FileName);
  22199. using (var stream = new FileStream(filePath, FileMode.Create))
  22200. {
  22201. await file.CopyToAsync(stream);
  22202. }
  22203. //验证文件是否上传成功
  22204. if (!System.IO.File.Exists(filePath))
  22205. {
  22206. foreach (var filePathStr in filePaths)
  22207. {
  22208. System.IO.File.Delete(filePathStr);
  22209. }
  22210. return Ok(JsonView(false, "文件上传失败!"));
  22211. }
  22212. item.ESFileName = file.FileName;
  22213. }
  22214. #endregion
  22215. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22216. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22217. .UpdateColumns(x => new
  22218. {
  22219. x.Catering,
  22220. x.CateringReason,
  22221. x.Stay,
  22222. x.StayReason,
  22223. x.Route,
  22224. x.RouteReason,
  22225. x.OfficialActivity,
  22226. x.OfficialActivityReason,
  22227. x.TourGuide,
  22228. x.TourGuideReason,
  22229. x.Translate,
  22230. x.TranslateReason,
  22231. x.Trip,
  22232. x.TripReason,
  22233. x.ESFileName,
  22234. x.SignatureDate,
  22235. x.Remark
  22236. })
  22237. .WhereColumns(x => new { x.Id })
  22238. .ExecuteCommandAsync();
  22239. if (upd < 1)
  22240. {
  22241. foreach (var filePathStr in filePaths)
  22242. {
  22243. System.IO.File.Delete(filePathStr);
  22244. }
  22245. return Ok(JsonView(false));
  22246. }
  22247. return Ok(JsonView(true));
  22248. }
  22249. #endregion
  22250. #region 团组餐厅相关信息
  22251. /// <summary>
  22252. /// 团组相关餐厅信息
  22253. /// 基础数据(团组)
  22254. /// </summary>
  22255. /// <returns></returns>
  22256. [HttpGet]
  22257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22258. public async Task<IActionResult> RestaurantInit()
  22259. {
  22260. return Ok(await _restaurantRep.InitAsync());
  22261. }
  22262. /// <summary>
  22263. /// 团组相关餐厅信息
  22264. /// Item
  22265. /// </summary>
  22266. /// <param name="dto"></param>
  22267. /// <returns></returns>
  22268. [HttpPost]
  22269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22270. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22271. {
  22272. int portType = dto.PortType,
  22273. groupId = dto.GroupId;
  22274. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22275. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22276. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22277. }
  22278. /// <summary>
  22279. /// 团组相关餐厅信息
  22280. /// List
  22281. /// </summary>
  22282. /// <param name="dto"></param>
  22283. /// <returns></returns>
  22284. [HttpPost]
  22285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22286. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22287. {
  22288. int portType = dto.PortType,
  22289. groupId = dto.GroupId;
  22290. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22291. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22292. var sql = string.Format(@" SELECT
  22293. ri.Id,
  22294. ri.GroupId,
  22295. ri.Date,
  22296. ri.StartTime,
  22297. ri.EndTime,
  22298. CASE WHEN ri.Type = 1 THEN '早餐'
  22299. WHEN ri.Type = 2 THEN '午餐'
  22300. WHEN ri.Type = 3 THEN '晚餐'
  22301. ELSE '其他'
  22302. END AS 'Type',
  22303. ri.Name,
  22304. ri.Address,
  22305. ri.Tel,
  22306. ri.Remark,
  22307. ri.CreateTime,
  22308. u.CnName AS CreateUserName
  22309. FROM
  22310. Grp_RestaurantInfo ri
  22311. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22312. WHERE
  22313. ri.IsDel = 0
  22314. AND ri.GroupId = {0}
  22315. ORDER BY
  22316. ri.Date ASC
  22317. ", groupId);
  22318. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22319. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22320. return Ok(JsonView(infos));
  22321. }
  22322. /// <summary>
  22323. /// 团组相关餐厅信息
  22324. /// Info
  22325. /// </summary>
  22326. /// <param name="dto"></param>
  22327. /// <returns></returns>
  22328. [HttpPost]
  22329. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22330. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  22331. {
  22332. int portType = dto.PortType,
  22333. id = dto.Id;
  22334. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22335. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22336. return Ok(await _restaurantRep.InfoAsync(portType, id));
  22337. }
  22338. /// <summary>
  22339. /// 团组相关餐厅信息
  22340. /// Op
  22341. /// </summary>
  22342. /// <param name="dto"></param>
  22343. /// <returns></returns>
  22344. [HttpPost]
  22345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22346. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  22347. {
  22348. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22349. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22350. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22351. return Ok(await _restaurantRep.OpAsync(dto));
  22352. }
  22353. /// <summary>
  22354. /// 团组相关餐厅信息
  22355. /// Del
  22356. /// </summary>
  22357. /// <param name="dto"></param>
  22358. /// <returns></returns>
  22359. [HttpPost]
  22360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22361. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22362. {
  22363. int userId = dto.DeleteUserId;
  22364. var id = dto.Id;
  22365. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22366. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22367. return Ok(await _restaurantRep.DelAsync(dto));
  22368. }
  22369. #endregion
  22370. /// <summary>
  22371. /// 123132123
  22372. /// </summary>
  22373. /// <param name="_dto"></param>
  22374. /// <returns></returns>
  22375. [HttpPost]
  22376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22377. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22378. {
  22379. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22380. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  22381. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  22382. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22383. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  22384. dicDetail.Add(789, 1034);
  22385. dicDetail.Add(790, 1035);
  22386. dicDetail.Add(791, 1036);
  22387. dicDetail.Add(792, 1037);
  22388. dicDetail.Add(793, 1038);
  22389. dicDetail.Add(794, 1039);
  22390. dicDetail.Add(795, 1040);
  22391. dicDetail.Add(796, 1041);
  22392. dicDetail.Add(797, 1042);
  22393. dicDetail.Add(798, 1043);
  22394. dicDetail.Add(801, 1044);
  22395. dicDetail.Add(802, 1045);
  22396. dicDetail.Add(803, 1046);
  22397. Dictionary<int, int> dic = new Dictionary<int, int>();
  22398. dic.Add(806, 1027);
  22399. dic.Add(807, 1028);
  22400. dic.Add(808, 1029);
  22401. dic.Add(809, 1030);
  22402. dic.Add(810, 1031);
  22403. dic.Add(811, 1032);
  22404. dic.Add(812, 1033);
  22405. foreach (var item in list_visa)
  22406. {
  22407. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  22408. temp.Coefficient = item.coefficient;
  22409. DateTime dtCrt;
  22410. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  22411. if (b1)
  22412. {
  22413. temp.CreateTime = dtCrt;
  22414. }
  22415. else
  22416. {
  22417. temp.CreateTime = DateTime.Now;
  22418. }
  22419. temp.CreateUserId = item.Operators;
  22420. temp.DeleteTime = "";
  22421. temp.DeleteUserId = 0;
  22422. temp.DiId = int.Parse(item.DIID);
  22423. temp.FilePath = item.FilePath;
  22424. temp.IsDel = item.IsDel;
  22425. temp.Price = item.Price;
  22426. temp.PriceCount = 1;
  22427. temp.PriceCurrency = item.Currency;
  22428. int detailId = 0;
  22429. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  22430. {
  22431. detailId = dicDetail[item.PriceTypeDetail];
  22432. }
  22433. temp.PriceDetailType = detailId;
  22434. temp.PriceDt = DateTime.Now;
  22435. temp.PriceName = item.PriceName;
  22436. temp.PriceSum = item.Price;
  22437. int tid = 0;
  22438. if (dic.ContainsKey(item.PriceType))
  22439. {
  22440. tid = dic[item.PriceType];
  22441. }
  22442. temp.PriceType = tid;
  22443. temp.Remark = item.Remark;
  22444. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  22445. }
  22446. return Ok(JsonView(true, "操作成功!"));
  22447. }
  22448. [HttpPost]
  22449. public IActionResult TimeTest()
  22450. {
  22451. var jw = JsonView(false, "error");
  22452. _sqlSugar.BeginTran();
  22453. try
  22454. {
  22455. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  22456. .Select(x => new Crm_NewClientData
  22457. {
  22458. Id = x.Id,
  22459. Client = x.Client,
  22460. Contact = x.Contact,
  22461. Location = x.Location,
  22462. })
  22463. .ToList();
  22464. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  22465. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  22466. Stopwatch stopwatch = new Stopwatch();
  22467. // 开始计时
  22468. stopwatch.Start();
  22469. foreach (var item in clientList)
  22470. {
  22471. EncryptionProcessor.DecryptProperties(item);
  22472. }
  22473. stopwatch.Stop();
  22474. jw.Code = 200;
  22475. jw.Data = stopwatch.ElapsedMilliseconds;
  22476. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  22477. }
  22478. catch (Exception ex)
  22479. {
  22480. jw.Code = 400;
  22481. jw.Msg = ex.Message;
  22482. }
  22483. return Ok(jw);
  22484. }
  22485. }
  22486. }